canvas size added to preferences and updated to dialog

This commit is contained in:
Huy Pham 2019-11-27 09:54:43 -08:00
parent 15e484c8c2
commit 1ca9aec247
4 changed files with 16 additions and 5 deletions

View file

@ -67,8 +67,15 @@ class Application(tk.Frame):
self.draw_status()
def draw_canvas(self):
width = self.guiconfig["preferences"]["width"]
height = self.guiconfig["preferences"]["height"]
self.canvas = CanvasGraph(
self, self.core, background="#cccccc", scrollregion=(0, 0, 1200, 1000)
self,
self.core,
width,
height,
background="#cccccc",
scrollregion=(0, 0, 1200, 1000),
)
self.canvas.pack(fill=tk.BOTH, expand=True)
scroll_x = ttk.Scrollbar(

View file

@ -78,6 +78,8 @@ def check_directory():
"editor": editor,
"terminal": terminal,
"gui3d": "/usr/local/bin/std3d.sh",
"width": 1000,
"height": 750,
},
"location": {
"x": 0.0,

View file

@ -14,8 +14,8 @@ class PreferencesDialog(Dialog):
self.theme = tk.StringVar(value=preferences["theme"])
self.terminal = tk.StringVar(value=preferences["terminal"])
self.gui3d = tk.StringVar(value=preferences["gui3d"])
self.width = tk.StringVar(value="1000")
self.height = tk.StringVar(value="800")
self.width = tk.StringVar(value=preferences["width"])
self.height = tk.StringVar(value=preferences["height"])
self.draw()
def draw(self):
@ -93,5 +93,7 @@ class PreferencesDialog(Dialog):
preferences["editor"] = self.editor.get()
preferences["gui3d"] = self.gui3d.get()
preferences["theme"] = self.theme.get()
preferences["width"] = self.width.get()
preferences["height"] = self.height.get()
self.app.save_config()
self.destroy()

View file

@ -39,7 +39,7 @@ class ScaleOption(enum.Enum):
class CanvasGraph(tk.Canvas):
def __init__(self, master, core, cnf=None, **kwargs):
def __init__(self, master, core, width, height, cnf=None, **kwargs):
if cnf is None:
cnf = {}
kwargs["highlightthickness"] = 0
@ -54,7 +54,7 @@ class CanvasGraph(tk.Canvas):
self.grid = None
self.canvas_management = CanvasComponentManagement(self, core)
self.setup_bindings()
self.draw_grid()
self.draw_grid(width, height)
self.core = core
self.helper = GraphHelper(self, core)
self.throughput_draw = Throughput(self, core)