tkinter newbie question
KP
kai.peters at gmail.com
Mon Jan 25 09:14:41 EST 2016
On Sunday, 24 January 2016 20:20:07 UTC-8, KP wrote:
> See my code below (which works). I'd like to have the 2nd window as a class in a separate unit. How do I code that unit and how do I call it from my first unit?
>
> As always, thanks for all help!
>
>
>
>
> #!/usr/bin/env python
> """
> """
> from tkinter import *
> from settings import *
>
> class window1():
>
> def open_window2(self):
> t = Toplevel(self.root)
> t.title('New window')
> t.geometry('262x65+200+250')
> t.transient(self.root)
>
> def setup_menu(self):
> self.menubar = Menu(self.root)
> self.menu1 = Menu(self.menubar, tearoff=0 )
> self.menu1.add_command(label="Settings", accelerator='Ctrl+S', command=self.open_window2)
> self.menubar.add_cascade(label="Menu 1", menu=self.menu1)
> self.root.config(menu=self.menubar)
>
> def __init__(self):
> self.root = Tk()
> self.root.title('Window #1')
> self.setup_menu()
> self.root.geometry('800x600+200+200')
> #
> self.root.mainloop()
>
> if __name__ == '__main__':
>
> w1 = window1()
Thank you - much appreciated!
More information about the Python-list
mailing list