Jul-11-2018, 10:19 AM
Hi jollydragon
wuf ;-)
from functools import partial import tkinter APP_TITLE = "Main Window" APP_XPOS = 100 APP_YPOS = 100 APP_WIDTH = 350 APP_HEIGHT = 200 def mdfNames(mdf): mdf.destroy() def mdfPanel(): mdf = tkinter.Toplevel() mdf.title("Top Level Window") mdfSize = 220 mdf.geometry('%dx%d+%d+%d' % ( mdfSize, mdfSize, (mdf.winfo_screenwidth()-mdfSize)/2, (mdf.winfo_screenheight()-mdfSize)/2)) tkinter.Button(mdf, text="Start", command=partial(mdfNames, mdf) ).grid(row=7,column=1, columnspan=2) def main(): app_win = tkinter.Tk() app_win.title(APP_TITLE) app_win.geometry("+{}+{}".format(APP_XPOS, APP_YPOS)) app_win.geometry("{}x{}".format(APP_WIDTH, APP_HEIGHT)) app = mdfPanel() app_win.mainloop() if __name__ == '__main__': main()Replace the following:
command=mdfNames(mdf)By:
command=partial(mdfNames, mdf)Instead of partial you can of course also use the lambda function.
wuf ;-)