Tkinter Packing Strangeness: Buttons packed above others

Posted by Parand on Stack Overflow See other posts from Stack Overflow or by Parand
Published on 2010-06-03T00:59:14Z Indexed on 2010/06/03 1:04 UTC
Read the original article Hit count: 286

Filed under:
|

I'm sure I'm doing something obvious wrong here, but I can't see it. I end up with the "Should be on top" label packed at the bottom instead of at the top. What am I doing wrong?

from Tkinter import *

class SelectAction(Frame):
    buttons = {}

    def callback(self):
        print "Callback"

    def createWidgets(self):
        logo_label   = Label(text="Should be on top").pack(fill=X)

        for name, text, callback in (
            ('setup_account', 'Account Settings', self.callback),
            ('do_action', 'Do Something', self.callback),
        ):
            self.buttons[name] = Button(self, text=text, command=callback).pack(fill=X)

    def __init__(self, master=None):
        Frame.__init__(self, master)
        self.pack()
        self.createWidgets()

if __name__ == "__main__":
    root = Tk()    
    app = SelectAction(master=root)
    app.mainloop()
    root.destroy()

© Stack Overflow or respective owner

Related posts about python

Related posts about tkinter