here2share

# Tk_multiwin.py

Oct 24th, 2020
337
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Tk_multiwin.py
  2.  
  3. from tkinter import *
  4. from tkinter import ttk
  5.  
  6. win=Tk()
  7.  
  8. def create_frame1():
  9.     global show_frame2, frame1
  10.     frame1=ttk.Frame(win)
  11.     lbl=ttk.Label(frame1, text='Frame1', font='Times 35')
  12.     lbl.grid(row=0, column=0, columnspan=2)
  13.     bt_next=ttk.Button(frame1, text='Next', command=show_frame2)
  14.     bt_quit=ttk.Button(frame1, text='Quit', command=win.destroy)
  15.     bt_next.grid(row=1, column=1)
  16.     bt_quit.grid(row=1, column=0)
  17.  
  18. def show_frame1():
  19.     global frame2, frame1
  20.     frame2.grid_forget()
  21.     frame1.grid()
  22.  
  23. def create_frame2():
  24.     global show_frame3, show_frame1, frame2
  25.     frame2=ttk.Frame(win)
  26.     lbl=ttk.Label(frame2, text='Frame2', font='Times 35')
  27.     lbl.grid(row=0, column=0, columnspan=2)
  28.     bt_next=ttk.Button(frame2, text='Next', command=show_frame3)
  29.     bt_next.grid(row=1, column=1)
  30.     bt_back=ttk.Button(frame2, text='Back', command=show_frame1)
  31.     bt_back.grid(row=1, column=0)
  32.    
  33. def show_frame2():
  34.     global farme1, frame3, frame2
  35.     frame3.grid_forget()
  36.     frame1.grid_forget()
  37.     frame2.grid()
  38.  
  39. def create_frame3():
  40.     global show_frame2, frame3
  41.     frame3=ttk.Frame(win)
  42.     lbl=ttk.Label(frame3, text='Frame3', font='Times 35')
  43.     lbl.grid(row=0, column=0, columnspan=2)
  44.     bt_back=ttk.Button(frame3, text='Back', command=show_frame2)
  45.     bt_back.grid(row=1, column=0)
  46.     bt_quit=ttk.Button(frame3, text='Quit', command=win.destroy)
  47.     bt_quit.grid(row=1, column=1)
  48.  
  49. def show_frame3():
  50.     global frame2, frame3
  51.     frame2.grid_forget()
  52.     frame3.grid()
  53.  
  54. def main():
  55.     create_frame1()
  56.     create_frame2()
  57.     create_frame3()
  58.     show_frame1()
  59.  
  60. if __name__ == "__main__":
  61.     main()
RAW Paste Data