Bind the mouse to the scan methods.

Now you can scroll the star map by "grabbing" the background with the
left mouse button and dragging.  Super-cool that Tk(inter) makes this so
simple.
This commit is contained in:
Simon Forman 2024-04-15 21:48:30 -07:00
parent 7331580bfd
commit 97178b84a3
1 changed files with 7 additions and 1 deletions

8
ui.py
View File

@ -69,7 +69,13 @@ class App:
scrollY.grid(row=0, column=1, sticky=N+S)
scrollX.grid(row=1, column=0, sticky=E+W)
canvas.bind("<Configure>", self.handle_canvas_resize)
scrollX['troughcolor'] = scrollY['troughcolor'] = DARK_GRAY
scrollX['bg'] = scrollY['bg'] = '#ddf'
canvas.bind('<Configure>', self.handle_canvas_resize)
canvas.bind('<Button-1>', lambda event: canvas.scan_mark(event.x, event.y))
canvas.bind('<B1-Motion>', lambda event: canvas.scan_dragto(event.x, event.y, gain=7))
# Star System