Skip to content

Commit

Permalink
Update canvasimage.py
Browse files Browse the repository at this point in the history
  • Loading branch information
FraidOfWater authored Nov 12, 2024
1 parent 176a29c commit dede3df
Showing 1 changed file with 67 additions and 11 deletions.
78 changes: 67 additions & 11 deletions canvasimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,12 @@ def __init__(self, master, imagewindowgeometry, viewer_colour, imageobj, gui):
def control_key_press(self, event):
if not self.gui.enter_toggle:
self.control_pressed = True
self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
self.gui.current_selection.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
#self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
#self.gui.current_selection.bar.configure(bg = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)

#self.gui.current_selection.canvas.itemconfig(self.gui.current_selection.sqr, fill=self.gui.imageborder_locked_colour)


self.canvas.bind('<Key>', lambda event: self.canvas.after_idle(self.keystroke, event))
self.canvas.focus_set()
Expand All @@ -242,29 +247,51 @@ def control_key_press(self, event):
def control_key_release(self, event):
if self.exit_lock:
self.control_pressed = False
self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)
self.gui.current_selection.configure(highlightbackground = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)
#self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)
#self.gui.current_selection.bar.configure(bg = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)

#self.gui.current_selection.canvas.itemconfig(self.gui.current_selection.sqr, fill=self.gui.imageborder_selected_colour)


self.last_state = "quickscroll"
self.gui.enter_toggle = False
elif not self.gui.enter_toggle:
self.control_pressed = False
self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)
self.gui.current_selection.configure(highlightbackground = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)
#self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)
#self.gui.current_selection.bar.configure(bg = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)

#self.gui.current_selection.canvas.itemconfig(self.gui.current_selection.sqr, fill=self.gui.imageborder_selected_colour)


#logger.debug(self.control_pressed)
self.last_state = "quickzoom"

def shift_key_press(self, event):
if not self.gui.enter_toggle:
self.control_pressed = True
self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
self.gui.current_selection.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
#self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
#self.gui.current_selection.bar.configure(bg = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)

#self.gui.current_selection.canvas.itemconfig(self.gui.current_selection.sqr, fill=self.gui.imageborder_locked_colour)


self.canvas.bind('<Key>', lambda event: self.canvas.after_idle(self.keystroke, event))
self.canvas.focus_set()
#logger.debug(self.control_pressed)

def shift_key_release(self, event):
if not self.gui.enter_toggle:
self.control_pressed = False
self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)

self.gui.current_selection.configure(highlightbackground = self.gui.imageborder_selected_colour,highlightcolor = self.gui.imageborder_selected_colour)
#self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)
#self.gui.current_selection.bar.configure(bg = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)

#self.gui.current_selection.canvas.itemconfig(self.gui.current_selection.sqr, fill=self.gui.imageborder_selected_colour)


#logger.debug(self.control_pressed)
self.last_state = "quickscroll"

Expand Down Expand Up @@ -632,11 +659,23 @@ def time_set(self, event):
flag = True
if self.gui.show_next.get() and flag and not self.gui.enter_toggle:
self.gui.enter_toggle = True
self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
self.gui.current_selection.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
#self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
#self.gui.current_selection.bar.configure(bg = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)

#self.gui.current_selection.canvas.itemconfig(self.gui.current_selection.sqr, fill=self.gui.imageborder_locked_colour)


self.canvas.bind('<Key>', lambda event: self.canvas.after_idle(self.keystroke, event))
else:
self.gui.enter_toggle = False
self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)
self.gui.current_selection.configure(highlightbackground = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)
#self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)
#self.gui.current_selection.bar.configure(bg = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)

#self.gui.current_selection.canvas.itemconfig(self.gui.current_selection.sqr, fill=self.gui.imageborder_selected_colour)


self.canvas.bind('<Key>', lambda event: self.canvas.after_idle(self.gui.navigator, event))

def __move_from(self, event): # Remember previous coordinates for scrolling with the mouse
Expand Down Expand Up @@ -747,7 +786,13 @@ def manual_wheel(self): # Fixes laggy panning on first picture
self.canvas.scale('all', x, y, scale, scale) # rescale all objects

def focus_canvasimage(self):
self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
self.gui.current_selection.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
#self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
#self.gui.current_selection.bar.configure(bg = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)

#self.gui.current_selection.canvas.itemconfig(self.gui.current_selection.sqr, fill=self.gui.imageborder_locked_colour)


self.canvas.bind('<Key>', lambda event: self.canvas.after_idle(self.keystroke, event))


Expand All @@ -757,13 +802,24 @@ def keystroke(self, event): # Scrolling and zooming with the keyboard
#On exiting the lock.
#Colour image yellow if we press enter while its selected
if event.keysym == "Return" and self.gui.show_next.get():
self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
self.gui.current_selection.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
#self.gui.current_selection.canvas.configure(highlightbackground = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)
#self.gui.current_selection.bar.configure(bg = self.gui.imageborder_locked_colour, highlightcolor = self.gui.imageborder_locked_colour)

#self.gui.current_selection.canvas.itemconfig(self.gui.current_selection.sqr, fill=self.gui.imageborder_locked_colour)


self.gui.enter_toggle = not self.gui.enter_toggle
self.last_state = "Return" #unsure what does

#if shift or cntrl not presed and image is unlocked, return og color and bind keys to navigator (grid viewer) (not canvasiamge)
if not self.gui.enter_toggle and self.gui.show_next.get() and not event.state & 0x4 and not event.state & 0x1:
self.gui.current_selection.canvas.configure(highlightcolor="blue", highlightbackground = "blue")
#self.gui.current_selection.canvas.configure(highlightcolor=self.gui.imageborder_selected_colour, highlightbackground = self.gui.imageborder_selected_colour)
self.gui.current_selection.configure(highlightcolor=self.gui.imageborder_selected_colour, highlightbackground = self.gui.imageborder_selected_colour)
#self.gui.current_selection.bar.configure(bg = self.gui.imageborder_selected_colour, highlightcolor = self.gui.imageborder_selected_colour)

#self.gui.current_selection.canvas.itemconfig(self.gui.current_selection.sqr, fill=self.gui.imageborder_selected_colour)

self.canvas.bind('<Key>', lambda event: self.canvas.after_idle(self.gui.navigator, event))
if self.last_state == "quickzoom" or self.last_state == "quickscroll": #if we used scroll or zooming, dont just bind but run once.
self.canvas.after_idle(self.gui.navigator, event)
Expand Down

0 comments on commit dede3df

Please sign in to comment.