Tkinter - How would I create buttons in a new window, which has been created by a function being called? Python 3 -



Tkinter - How would I create buttons in a new window, which has been created by a function being called? Python 3 -

from tkinter import * def begin(): root = tk() root.title("main window") root.geometry("1920x1080") homecoming #how button placed in window made function? root = tk() root.title("start page") root.geometry("1920x1080") beginbutton = button(app, text = "begin", command=begin, bg="green") beginbutton.grid(column = 2, row = 2, sticky = w) beginbutton.config(height = 10, width = 30 ) root.mainloop()

how create new buttons in new window, if new window beingness made by, in case function known "begin".

any response much appreciated!

i believe want modify root window rather create new one. here minimal working example:

from tkinter import * root = tk() class app: def __init__(self): root.title("start page") root.geometry("1920x1080") self.beginb = button(root, text="begin", command=self.begin, bg="green", height=10, width=30) self.beginb.grid(sticky = w) def begin(self): root.title("main window") self.beginb.destroy() del self.beginb self.gob = button(root, text='go on', command=self.go_on, bg='red') self.gob.grid(sticky=e) def go_on(self): self.label = label(root, text="you have continued") self.label.grid(row=1, sticky=s) app() root.mainloop()

an advantage of defining class can create forwards references. in code, had define begin function before create begin button. class, set after init, me more natural order. ofter case initialization code calls or binds more 1 function.

python windows tkinter

Comments

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -