Jul-31-2023, 06:49 AM
(Jul-31-2023, 03:15 AM)deanhystad Wrote: There is a better way to associate label text with an int. Use a tk.variable.
import tkinter as tk def cmdinczoom(event): print(event) increment = {"Up": 1, "Right": 1, "Down": -1, "Left": -1}.get(event.keysym, 0) zoom.set(max(1, min(zoom.get() + increment, 16))) window = tk.Tk() zoom = tk.IntVar(window, 1) label = tk.Label(window, width=10, font=("Ariel", 16, "bold"), textvariable=zoom) label.pack(padx=20, pady=20) for key in ("<Left>", "<Right>", "<Up>", "<Down>"): window.bind(key, cmdinczoom) window.mainloop()Why does your key press callback function press a mouse button?
hello. I am using [url=https://github.com/TomSchimansky/TkinterMapView#create-polygon-from-position-
list]https://github.com/TomSchimansky/TkinterMapView#create-polygon-from-position-list[/url]
I wanted to keep track of zoom level on his app, view lvl on a label and use up and down arrow on keyboard to increase/decrease zoom level 1-16.
I didnt find any direct function in Schimansky app, so I thought I should do it programmatically