shape configuration, replace tunntel tool image

This commit is contained in:
Huy Pham 2019-12-04 09:28:16 -08:00
parent 41a9b88189
commit bbb8be6655
6 changed files with 27 additions and 21 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View file

Before

Width:  |  Height:  |  Size: 799 B

After

Width:  |  Height:  |  Size: 799 B

View file

@ -26,24 +26,8 @@ class ShapeDialog(Dialog):
self.bold = tk.IntVar(value=data.bold)
self.italic = tk.IntVar(value=data.italic)
self.underline = tk.IntVar(value=data.underline)
# else:
# self.fill_color = self.canvas.itemcget(self.id, "fill")
# self.shape_text = tk.StringVar(value="")
# self.font = tk.StringVar(value="Arial")
# self.font_size = tk.IntVar(value=12)
# self.text_color = "#000000"
# # self.fill_color = "#CFCFFF"
# self.border_color = "black"
# self.border_width = tk.IntVar(value=0)
# self.bold = tk.IntVar(value=0)
# self.italic = tk.IntVar(value=0)
# self.underline = tk.IntVar(value=0)
# print(self.fill_color)
self.fill = None
self.border = None
self.top.columnconfigure(0, weight=1)
self.draw()
@ -91,7 +75,7 @@ class ShapeDialog(Dialog):
frame.columnconfigure(2, weight=1)
label = ttk.Label(frame, text="Fill color")
label.grid(row=0, column=0, sticky="nsew")
self.fill = ttk.Label(frame, text=self.fill_color, background="#CFCFFF")
self.fill = ttk.Label(frame, text=self.fill_color, background=self.fill_color)
self.fill.grid(row=0, column=1, sticky="nsew", padx=3)
button = ttk.Button(frame, text="Color", command=self.choose_fill_color)
button.grid(row=0, column=2, sticky="nsew")
@ -173,7 +157,7 @@ class ShapeDialog(Dialog):
if self.underline.get() == 1:
f.append("underline")
if shape.text_id is None:
shape.text = self.canvas.create_text(
shape.text_id = self.canvas.create_text(
text_x, text_y, text=shape_text, fill=self.text_color, font=f
)
self.canvas.shapes[self.id].created = True
@ -181,4 +165,15 @@ class ShapeDialog(Dialog):
self.canvas.itemconfig(
shape.text_id, text=shape_text, fill=self.text_color, font=f
)
data = self.canvas.shapes[self.id].shape_data
data.text = shape_text
data.font = self.font.get()
data.font_size = int(self.font_size.get())
data.text_color = self.text_color
data.fill_color = self.fill_color
data.border_color = self.border_color
data.border_width = int(self.border_width.get())
data.bold = self.bold.get()
data.italic = self.italic.get()
data.underline = self.underline.get()
self.destroy()

View file

@ -361,6 +361,9 @@ class CanvasGraph(tk.Canvas):
:return: nothing
"""
logging.debug(f"click press: {event}")
self.delete(self.find_withtag("selectednodes"))
self.canvas_management.selected.clear()
selected = self.get_selected(event)
is_node = selected in self.find_withtag("node")
if self.mode == GraphMode.EDGE and is_node:
@ -447,7 +450,7 @@ class CanvasGraph(tk.Canvas):
selected = self.get_selected(event)
if selected is not None and "shape" in self.gettags(selected):
s = ShapeDialog(self.app, self.app, self.shapes[selected])
print(s)
s.show()
def add_node(self, x, y):
if self.selected is None or "shape" in self.gettags(self.selected):
@ -763,6 +766,9 @@ class CanvasNode:
return
x, y = self.canvas.canvas_xy(event)
self.move(x, y)
# for nid, bboxid in self.canvas.canvas_management.selected.items():
# if nid in self.canvas.nodes:
# self.canvas.nodes[nid].motion(event)
def select_multiple(self, event):
self.canvas.canvas_management.node_select(self, True)

View file

@ -87,7 +87,7 @@ class CanvasComponentManagement:
for shape_id in self.selected:
if "shape" in self.canvas.gettags(shape_id):
bbox_id = self.selected[node_id]
self.canvas.delete(shape_id)
self.canvas.shapes[shape_id].delete()
self.canvas.delete(bbox_id)
self.canvas.shapes.pop(shape_id)

View file

@ -46,7 +46,6 @@ class Shape:
top_x, top_y, top_x, top_y, tags="shape", dash="-"
)
self.canvas.tag_bind(self.id, "<ButtonRelease-1>", self.click_release)
# self.canvas.tag_bind(self.id, "<B1-Motion>", self.motion)
def shape_motion(self, x1, y1):
self.canvas.coords(self.id, self.x0, self.y0, x1, y1)
@ -69,5 +68,11 @@ class Shape:
self.id, x0 + delta_x, y0 + delta_y, x1 + delta_x, y1 + delta_y
)
self.canvas.canvas_management.node_drag(self, delta_x, delta_y)
if self.text_id is not None:
self.canvas.move(self.text_id, delta_x, delta_y)
self.cursor_x = event.x
self.cursor_y = event.y
def delete(self):
self.canvas.delete(self.id)
self.canvas.delete(self.text_id)