[pygtk] GUI design question / palette and horizontal panes

Facundo Batista facundobatista at gmail.com
Sat Mar 29 12:05:40 WST 2008


2008/3/28, Mark Mruss <selsine at gmail.com>:

>  I would like to like to have three horizontal panes likes you often
>  see in IDE or in glade itself. I can't seem to figure out how to
>  accomplish this? Do I simply add another horizontal pane into one of
>  the positions of a horizontal pane?

Yeap. It's tricky to whom add ScrollBars, though.

Check this code, where I have four panes arranged like a square, and
you can resize everything and works nicely (note: I just trimmed other
stuff from here, hope didn't break anything, but you'll get the idea):


class ExploitBody(gtk.HPaned):
    def __init__(self):
        super(ExploitBody,self).__init__()

        # left & right
        exploitvuln = self._buildExplVuln()
        interac = self._buildInteraction()

        # pack it all and show
        self.pack1(exploitvuln)
        self.pack2(interac)
        self.set_position(500)

        self.show()

    def _buildExplVuln(self):
        pan = gtk.HPaned()

        # left
        exploitlist = ExploitTree(self.w3af)
        scrollwin1 = gtk.ScrolledWindow()
        scrollwin1.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrollwin1.add_with_viewport(exploitlist)
        scrollwin1.show()

        # rigth
        interac = VulnerabTree(self.w3af, exploitlist)
        scrollwin2 = gtk.ScrolledWindow()
        scrollwin2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrollwin2.add_with_viewport(interac)
        scrollwin2.show()

        # pack it all and show
        pan.pack1(scrollwin1)
        pan.pack2(scrollwin2)
        pan.set_position(250)
        pan.show()
        return pan

    def _buildInteraction(self):
        pan = gtk.VPaned()

        # left
        shells = Shells()
        scrollwin1 = gtk.ScrolledWindow()
        scrollwin1.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrollwin1.add_with_viewport(shells)
        scrollwin1.show()

        # rigth
        proxies = Proxies()
        scrollwin2 = gtk.ScrolledWindow()
        scrollwin2.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        scrollwin2.add_with_viewport(proxies)
        scrollwin2.show()

        # pack it all and show
        pan.pack1(scrollwin1)
        pan.pack2(scrollwin2)
        pan.set_position(200)
        pan.show()
        return pan


Regards,

-- 
.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/


More information about the pygtk mailing list