-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.py
53 lines (44 loc) · 1.61 KB
/
controller.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
46
47
48
49
50
51
52
53
import wx
from constants import PyDraw_Constants
class PyDrawController:
def __init__(self, view):
self.view = view
self.mode = PyDraw_Constants.SQUARE_MODE
def set_circle_mode(self):
self.mode = PyDraw_Constants.CIRCLE_MODE
def set_line_mode(self):
self.mode = PyDraw_Constants.LINE_MODE
def set_square_mode(self):
self.mode = PyDraw_Constants.SQUARE_MODE
def set_text_mode(self):
self.mode = PyDraw_Constants.TEXT_MODE
def clear_drawing(self):
self.view.drawing_controller.clear()
def get_mode(self):
return self.mode
def command_menu_handler(self, command_event):
id = command_event.GetId()
if id == wx.ID_NEW:
print('Clear the drawing area')
self.clear_drawing()
elif id == wx.ID_OPEN:
print('Open a drawing file')
elif id == wx.ID_SAVE:
print('Save a drawing file')
elif id == wx.ID_EXIT:
print('Quite the application')
self.view.Close()
elif id == PyDraw_Constants.LINE_ID:
print('set drawing mode to line')
self.set_line_mode()
elif id == PyDraw_Constants.SQUARE_ID:
print('set drawing mode to square')
self.set_square_mode()
elif id == PyDraw_Constants.CIRCLE_ID:
print('set drawing mode to circle')
self.set_circle_mode()
elif id == PyDraw_Constants.TEXT_ID:
print('set drawing mode to Text')
self.set_text_mode()
else:
print('Unknown option', id)