TkinterMapView icon indicating copy to clipboard operation
TkinterMapView copied to clipboard

Path line color and line width options

Open sylvanoMTL opened this issue 3 years ago • 3 comments

I am looking at changing the line thickness and colors of GPS path, but I cannot see the option. Ideally I would like to change the line color with other metrics (e.g. speed, altitude...) , using rainbow or parula chart

Is there any methods to control these line options?

sylvanoMTL avatar Jun 27 '22 07:06 sylvanoMTL

You can change the color of a path by passing a colorattribute to .set_path(). Changing the width is currently not supported, but maybe I will implement this in the future.

TomSchimansky avatar Jul 06 '22 21:07 TomSchimansky

I'd also love to see a width argument for set_path. I see you can change the width of a drawn line in canvas_path.draw.

staceellis avatar Jul 26 '22 02:07 staceellis

here are the modifications to bring to canvas_path.py to change the line width:

class object constructuor: add a self.path_width:

class CanvasPath:
    def __init__(self,
                 map_widget: "TkinterMapView",
                 position_list,
                 color="#3E69CB",
                 width=9,
                 command=None,
                 name=None,
                 data: any = None):

        self.map_widget = map_widget
        self.position_list = position_list
        self.canvas_line_positions = []
        self.deleted = False

        self.path_color = color
        self.path_width = width
        self.command = command
        self.canvas_line = None
        self.name = name
        self.data = data

and change this: line 101

self.canvas_line = self.map_widget.canvas.create_line(self.canvas_line_positions,
                                                                      width=9, fill=self.path_color,
                                                                      capstyle=tkinter.ROUND, joinstyle=tkinter.ROUND,
                                                                      tag="path")

by this:


self.canvas_line = self.map_widget.canvas.create_line(self.canvas_line_positions,
                                                                      width=self.path_width, fill=self.path_color,
                                                                      capstyle=tkinter.ROUND, joinstyle=tkinter.ROUND,
                                                                      tag="path")

sylvanoMTL avatar Jul 28 '22 07:07 sylvanoMTL

I added width attribute now with version 1.17. color attribute was added a while ago.

TomSchimansky avatar Nov 02 '22 23:11 TomSchimansky