pygui: created a singular func for ordering items on canvas by tags, updates so that drawing edges are behind nodes

This commit is contained in:
Blake Harnden 2020-05-16 14:12:08 -07:00
parent 50816b3b80
commit 91220078f1
5 changed files with 14 additions and 16 deletions

View file

@ -331,8 +331,6 @@ class CanvasEdge(Edge):
dst_pos = self.canvas.coords(self.dst)
self.move_dst(dst_pos)
self.check_wireless()
self.canvas.tag_raise(self.src)
self.canvas.tag_raise(self.dst)
logging.debug("Draw wired link from node %s to node %s", self.src, dst)
def is_wireless(self) -> bool:

View file

@ -139,7 +139,7 @@ class CanvasGraph(tk.Canvas):
self.show_ip6s.set(True)
# delete any existing drawn items
for tag in tags.COMPONENT_TAGS:
for tag in tags.RESET_TAGS:
self.delete(tag)
# set the private variables to default value
@ -591,6 +591,7 @@ class CanvasGraph(tk.Canvas):
if self.mode == GraphMode.EDGE and is_node:
pos = self.coords(selected)
self.drawing_edge = CanvasEdge(self, selected, pos, pos)
self.organize()
if self.mode == GraphMode.ANNOTATION:
if is_marker(self.annotation_type):
@ -866,10 +867,11 @@ class CanvasGraph(tk.Canvas):
self.wallpaper_scaled()
elif option == ScaleOption.TILED:
logging.warning("tiled background not implemented yet")
self.organize()
# raise items above wallpaper
for component in tags.ABOVE_WALLPAPER_TAGS:
self.tag_raise(component)
def organize(self) -> None:
for tag in tags.ORGANIZE_TAGS:
self.tag_raise(tag)
def set_wallpaper(self, filename: str):
logging.debug("setting wallpaper: %s", filename)

View file

@ -146,8 +146,7 @@ class Shape:
self.canvas.coords(self.id, self.x1, self.y1, x1, y1)
def shape_complete(self, x: float, y: float):
for component in tags.ABOVE_SHAPE:
self.canvas.tag_raise(component)
self.canvas.organize()
s = ShapeDialog(self.app, self)
s.show()

View file

@ -11,19 +11,21 @@ NODE = "node"
WALLPAPER = "wallpaper"
SELECTION = "selectednodes"
MARKER = "marker"
ABOVE_WALLPAPER_TAGS = [
ORGANIZE_TAGS = [
WALLPAPER,
GRIDLINE,
SHAPE,
SHAPE_TEXT,
EDGE,
LINK_LABEL,
WIRELESS_EDGE,
LINK_LABEL,
ANTENNA,
NODE,
NODE_LABEL,
SELECTION,
MARKER,
]
ABOVE_SHAPE = [GRIDLINE, EDGE, LINK_LABEL, WIRELESS_EDGE, ANTENNA, NODE, NODE_LABEL]
COMPONENT_TAGS = [
RESET_TAGS = [
EDGE,
NODE,
NODE_LABEL,