beginner python GUI question

C

Chris Hare

I hope I can explain this correctly.

I have a GUI, which is already being processed by a mainloop. I want to be able to open a second window so the user can interact with specific information in the second window. I pulled together this code example

from Tkinter import *

class Net:
def __init__(self,tkWin):
self.window = tkWin
def show(self,t):
self.l = Label(self.window,text=t)
self.l.grid()
button = Button(self.window, text="Again")
button.bind("<Button-1>", self.Again)
button.grid()
def Again(self,event):
win3 = Tk()
x = Net(win3)
x.show("window 3")

root = Tk()
root.title = "test"
f = Frame(root,bg="Yellow")
l = Label(f,text="window 1")
f.grid()
l.grid()

win2 = Tk()
x = Net(win2)
x.show("window 2")
if __name__ == "__main__":
root.mainloop()

Is this the right way to do things, or would you suggest something different?

Thanks,
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top