Advertisement
here2share

# Tk_scalable.py

Dec 25th, 2021
1,317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. # Tk_scalable.py
  2.  
  3. from tkinter import *
  4. import tkinter.font as tkFont
  5.  
  6. root = Tk()
  7. root.title("Tk_scalable")
  8.  
  9. def exitclick():
  10.     root.destroy()
  11.  
  12. class FullScreenApp(object):
  13.     def __init__(self, master, **kwargs):
  14.         self.master = master
  15.         pad = 100
  16.         self._geom = '600x400+0+0'
  17.         master.geometry("{0}x{1}+0+0".format(
  18.             master.winfo_screenwidth() - pad, master.winfo_screenheight() - pad))
  19.         master.bind('<Escape>', self.toggle_geom)
  20.  
  21.     def toggle_geom(self, event):
  22.         geom = self.master.winfo_geometry()
  23.         print(geom, self._geom)
  24.         self.master.geometry(self._geom)
  25.         self._geom = geom
  26. 0
  27.  
  28. frame = Frame(root)
  29. frame.pack()
  30.  
  31. fontStyle = tkFont.Font(family="Lucida Grande", size=40)
  32. text_intro = "Press Escape !!!"
  33. label = Label(root, text=text_intro, font=fontStyle)
  34. label.place(relx=.5, rely=.5, anchor="center")
  35.  
  36. fontdefault = tkFont.Font(family="Lucida Grande", size=20)
  37. close_button = Button(root, text="Close", command=exitclick, height=2, width=8, font=fontdefault)
  38. close_button.place(relx=0.5, rely=0.8, anchor="center")
  39.  
  40. app = FullScreenApp(root)
  41.  
  42. root.mainloop()
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement