[pygtk] Multiple Objects problem

Peter Brooks peter at theneb.co.uk
Sat May 26 22:09:38 WST 2007


Hello all,
I have a deep background in java and I am now using python for some OSS
work, however I'm having some trouble with creating a settings dialog with
two unique Tree's of type ListStore.



In the following code, the functions get_streams() & get_jingles() each need
to create their own unique ScrollList object, however they seem to be
sharing something.

http://savonet.svn.sourceforge.net/viewvc/savonet/trunk/rocket/liguidsoap.p=
y?view=3Dmarkup


class settings:
    dialog =3D gtk.Dialog()

    def __init__(self,widget,data=3DNone):
    self.get_dialog()


    def get_dialog(self):

    flags =3D gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT
    buttons =3D (gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)
    dialog =3D gtk.Dialog("Settings",None,flags,buttons)
    dialog.set_size_request(600,400)

    dialog.show()
    button =3D gtk.Button("test")
    button.show()

    dialog.vbox.pack_start(self.get_notebook(),0)
    #if dialog.run() =3D=3D gtk.RESPONSE_ACCEPT:
    #    print "run"

    #dialog.destroy()
    return True

    def get_notebook(self):
    notebook =3D gtk.Notebook()
    notebook.show()
    blankFrame =3D gtk.Frame("This is a blank frame")
    blankFrame.show()

    frameTwo =3D gtk.Frame("This is a blank frame")
    frameTwo.show()

    notebook.append_page(blankFrame,gtk.Label("Layout"))

    notebook.append_page(self.get_jingles(),gtk.Label("Jingles"))
    notebook.append_page(self.get_streams(),gtk.Label("Streams"))
    notebook.append_page(frameTwo,gtk.Label("Users"))
    return notebook

    def get_streams(self):
    streams =3D gtk.Frame()
    streams.show()

    #Setup the scrollable list
    sl =3D self.scrollList( ("Name", "Status") )
    sl.append_row(["Local","Connected"])
    sl.append_row(["Sustain","Connected"])
    sl.append_row(["Main Stream - High Bandwidth","Connected"])
    sl.append_row(["Main Stream - Low Bandwidth","Connected"])

    buttons =3D gtk.HButtonBox()
    buttons.show()
    editButton =3D gtk.Button("Edit")
    editButton.show()

    buttons.pack_end(editButton)

    vBox =3D gtk.VBox(False,2)
    vBox.show()
    vBox.pack_start(sl)
    vBox.pack_end(buttons)

    streams.add(vBox)
    return streams

    def get_jingles(self):
    jingles =3D gtk.Frame()
    jingles.show()

    sl =3D self.scrollList( ("Name","Owner") )
    sl.append_row( ["Main","Studio Manager"] )

    buttons =3D gtk.HButtonBox()
    buttons.show()
    editButton =3D gtk.Button("Edit")
    editButton.show()
    accessButton =3D gtk.Button("Access")
    accessButton.show()

    buttons.pack_end(editButton)
    buttons.pack_end(accessButton)

    vBox =3D gtk.VBox(False,2)
    vBox.show()
    vBox.pack_start(sl)
    vBox.pack_start(buttons)

    jingles.add(vBox)

    return jingles

    class scrollList(gtk.ScrolledWindow):
    listModel =3D gtk.ListStore(gobject.TYPE_STRING,
                 gobject.TYPE_STRING)
    treeView =3D gtk.TreeView()
    columns =3D (gobject.TYPE_STRING,gobject.TYPE_STRING)


    def __init__(self,columns):
        gtk.ScrolledWindow.__init__(self)
        self.columns =3D columns
        self.set_size_request(1,280)
        self.show()

        self.treeView =3D gtk.TreeView()
        self.treeView.show()
        self.add(self.treeView)

        self.treeView.set_model(self.listModel)

        self.treeView.set_headers_visible(True)

        count =3D 0
        for i in columns:
            renderer=3Dgtk.CellRendererText()
            column=3Dgtk.TreeViewColumn(i,renderer,text=3Dcount)
            column.set_resizable(True)
            self.treeView.append_column(column)
            count+=3D1

    def append_row(self,row):
        self.listModel.append(row)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.daa.com.au/pipermail/pygtk/attachments/20070526/be17d29e/at=
tachment.htm


More information about the pygtk mailing list