Advertisement
here2share

# Tk_lift.py

Dec 25th, 2021 (edited)
1,181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. # Tk_lift.py
  2.  
  3. import tkinter as tk
  4. class Page(tk.Frame):
  5.     def __init__(self, master, text, height, width, *args, **kwargs):
  6.         tk.Frame.__init__(self, *args, borderwidth=20, **kwargs)
  7.         self.height = height
  8.         self.width = width
  9.         button = tk.Button(self, text=text, font=('Verdana', 20),
  10.                            command=lambda: self.callback())
  11.         button.pack(side="top", fill="both", expand=True)
  12.     def onlift(self):
  13.         root.geometry('{}x{}'.format(self.width, self.height))
  14.         self.lift()
  15.  
  16. class App(tk.Frame):
  17.     def __init__(self, *args, **kwargs):
  18.         tk.Frame.__init__(self, *args, **kwargs)
  19.  
  20.         p1 = Page(self, 'This is page 1 of 3', height=300, width=400)
  21.         p2 = Page(self, 'Here is page 2 of 3', height=400, width=400)
  22.         p3 = Page(self, 'Last page is 3 of 3', height=400, width=600)
  23.         p1.callback = p2.onlift
  24.         p2.callback = p3.onlift
  25.         p3.callback = p1.onlift
  26.  
  27.         p1.place(x=0, y=0, relwidth=1, relheight=1)
  28.         p2.place(x=0, y=0, relwidth=1, relheight=1)
  29.         p3.place(x=0, y=0, relwidth=1, relheight=1)
  30.  
  31.         p1.onlift()
  32.  
  33. root = tk.Tk()
  34. app = App(root)
  35. root.mainloop()
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement