-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgui.py
45 lines (32 loc) · 1.48 KB
/
gui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import tkinter as tk
from codeeditor import CodeEditor
from commandinterpretter import CommandInterpretter
from quickreference import QuickReference
from help import Help
class GUI(tk.Frame):
"""Represents the GUI of the application as a whole."""
def __init__(self, master=None):
super().__init__(master)
self._shift_button_pressed = False
self.create_widgets()
def create_widgets(self):
"""Creates the widgets of the GUI."""
self.pane = tk.PanedWindow(self, orient=tk.HORIZONTAL, sashrelief=tk.RAISED,sashwidth=10,sashpad=1)
self.pane.pack(fill=tk.BOTH, expand=True)
code_editor = CodeEditor(self.pane)
canvas = tk.Canvas(self.pane)
command_interpretter = CommandInterpretter(canvas)
code_editor.on_execute_script = lambda text: command_interpretter.execute_script(text)
code_editor.on_run_immediate = lambda text: command_interpretter.execute_commands_immediate(text)
self.help = Help(self.pane)
self.pane.add(code_editor, width=500)
self.pane.add(canvas)
self.pane.add(self.help)
# f1 should toggle visibility of quick reference
canvas.bind_all("<F1>", self.on_f1_pressed)
def on_f1_pressed(self, event):
"""Toggles the visibility of the help pane."""
if self.help.winfo_ismapped():
self.pane.remove(self.help)
else:
self.pane.add(self.help)