rs6000

get_tk_frame_size

Nov 29th, 2020 (edited)
552
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #好用工具 測量tk 視窗大小
  2. #https://bit.ly/3lhYW8h
  3. import tkinter as tk
  4.  
  5. def go():
  6.  
  7.     txt = '視窗左上角座標為:({},{})\n 視窗高度為:{} 視窗寬度為:{}'.format(
  8.         root.winfo_x(), root.winfo_y(),  root.winfo_height(), root.winfo_width())
  9.     label1.configure(text=txt)
  10.     root.after(1, go)
  11.  
  12.  
  13. root = tk.Tk()
  14. root.geometry("400x200+100+50")
  15. label1 = tk.Label(root)
  16. label1.pack()
  17. go()
  18. root.mainloop()
RAW Paste Data