Monday, 30 September 2013

ttk widgets in frame not displayed

ttk widgets in frame not displayed

I'm having some difficulty with Python and ttk. I built a UI that works
correctly, but looks a bit cluttered. I wanted to add a frame so I could
add some padding and enable resizing and so on, but now none of the
widgets are displayed. My code is below.
Previously I was just passing parent as the parent to the widgets, which
did work. I've been working through a few tutorials, and I can't see
anything obviously wrong, though I'm sure it's something simple.
class Application:
def __init__(self, parent):
self.parent = parent
self.content = ttk.Frame(parent, padding=(3,3,12,12))
self.content.columnconfigure(1, weight=1)
self.content.rowconfigure(1, weight=1)
self.row1()
def row1(self):
self.enButton = ttk.Button(self.content, text="Enable",
command=self.enableCmd)
self.disButton = ttk.Button(self.content, text="Disable",
command=self.disableCmd)
self.enButton.grid(column=1, row=1)
self.disButton.grid(column=2, row=1)
self.disButton.state(['disabled'])
if __name__ == '__main__':
root = Tk()
root.title("Wilton Control Interface")
img = Image("photo", file="appicon.gif")
root.tk.call('wm','iconphoto',root._w,img)
app = Application(root)
root.mainloop()

No comments:

Post a Comment