Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- root = tk.Tk()
- x = int(root.winfo_screenwidth() //2)
- y = int(root.winfo_screenheight() //2)
- a = int((root.winfo_screenwidth() - x) // 2)
- b = int((root.winfo_screenheight() - y)// 2)
- root.wm_geometry("{0}x{1}+{2}+{3}".format(x,y,a,b))
- root.overrideredirect(1)
- def keydown(e):
- global a
- global b
- if e.char == 'w' or e.char == 'ц':
- b -= 50
- elif e.char == 's' or e.char == 'ы':
- b += 50
- elif e.char == 'd' or e.char == 'в':
- a += 50
- elif e.char == 'a' or e.char == 'ф':
- a -= 50
- root.wm_geometry("{0}x{1}+{2}+{3}".format(x,y,a,b))
- close = tk.Button(root, text="Close Window", command=lambda: root.destroy())
- close.pack(fill=tk.BOTH)
- root.bind('<KeyPress>', keydown)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement