/
view.py
71 lines (54 loc) · 2.09 KB
/
view.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from Globals import *
from pattern import Pattern
from GraphicalInterface import *
import wx
class View:
def __init__(self, controller):
self.controller = controller
# Create an instance of our customized Frame class - the GUI. (this is the view)
self.mainWindow = MainWindow(self.controller, "x0xb0x c0ntr0l")
self.currentPattern = None
def initialize(self):
pass
def destroy(self):
pass
##
#
# MODEL --> VIEW PROTOCOL
#
############################
#
# True means the serial port is connected, false if it is not.
#
def updateSerialStatus(self, state):
try:
if state == True:
self.mainWindow.statusBar.SetStatusText("Serial Port: Connected", 1)
else:
self.mainWindow.statusBar.SetStatusText("Serial Port: Disconnected", 1)
except Exception, e:
print 'Exception occured: ' + str(e)
def updateSelectedSerialPort(self, name):
menuId = self.mainWindow.portMenu.FindItem(name)
if menuId != wx.NOT_FOUND:
self.mainWindow.portMenu.Check(menuId, True)
def updateSerialPortNames(self, names):
for item in self.mainWindow.portMenu.GetMenuItems():
self.mainWindow.portMenu.Destroy(item)
for i in range(len(names)):
self.mainWindow.portMenu.Append(ID_SERIAL_PORT + i, names[i], kind = wx.ITEM_RADIO)
def updateCurrentPattern(self, pattern):
self.mainWindow.patternEditGrid.update(pattern)
def updateStatusText(self, string):
try:
self.mainWindow.statusBar.SetStatusText(string, 0)
except Exception, e:
print 'Exception occured: ' + str(e)
def displayModalStatusError(self, string):
print string
dlg = wx.MessageDialog(self.mainWindow, string, 'x0xb0x c0ntr0l', wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
def updateTempo(self, tempo):
self.mainWindow.tempoText.SetValue(str(tempo))
self.mainWindow.tempoSlider.SetValue(tempo)