TomSchimansky / TkinterMapView

A python Tkinter widget to display tile based maps like OpenStreetMap or Google Satellite Images.
Creative Commons Zero v1.0 Universal
621 stars 85 forks source link

A little addition I made (text on mouseover) #83

Open floris-vos opened 1 year ago

floris-vos commented 1 year ago

I wanted to be able to have the text visible only on mouseover. SO I added an optionaltext parameter, and I added two commands, one for mouse in, one for mouse out.

In canvas_position_marker, I added this in the arguments for init: command2: Callable = None, command3: Callable = None, optionaltext = None,

Then this to init:

    self.commandmousein = command2
    self.commandmouseout = command3
    self.optionaltext = optionaltext

Then this to mouse enter, mouse leave:

def mouse_enter(self, event=None):
    if sys.platform == "darwin":
        self.map_widget.canvas.config(cursor="pointinghand")
    elif sys.platform.startswith("win"):
        self.map_widget.canvas.config(cursor="hand2")
    else:
        self.map_widget.canvas.config(cursor="hand2")  # not tested what it looks like on Linux!
    self.commandmousein(self)

def mouse_leave(self, event=None):
    self.map_widget.canvas.config(cursor="arrow")
    self.commandmouseout(self)