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
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