Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. import tkinter as tk
  2.  
  3. root = tk.Tk()
  4.  
  5. x = int(root.winfo_screenwidth() //2)
  6. y = int(root.winfo_screenheight() //2)
  7. a = int((root.winfo_screenwidth() - x) // 2)
  8. b = int((root.winfo_screenheight() - y)// 2)
  9. root.wm_geometry("{0}x{1}+{2}+{3}".format(x,y,a,b))
  10. root.overrideredirect(1)
  11.  
  12. def keydown(e):
  13.     global a
  14.     global b
  15.  
  16.     if e.char == 'w' or e.char == 'ц':
  17.         b -= 50
  18.     elif e.char == 's' or e.char == 'ы':
  19.         b += 50
  20.     elif e.char == 'd' or e.char == 'в':
  21.         a += 50
  22.     elif e.char == 'a' or e.char == 'ф':
  23.         a -= 50
  24.     root.wm_geometry("{0}x{1}+{2}+{3}".format(x,y,a,b))
  25.    
  26.  
  27. close = tk.Button(root, text="Close Window", command=lambda: root.destroy())
  28. close.pack(fill=tk.BOTH)
  29.  
  30. root.bind('<KeyPress>', keydown)
  31. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement