def __init__(self, *args, **kwds):
# begin wxGlade: Dialogo_acceso_vcenter.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX
wx.Dialog.__init__(self, *args, **kwds)
self.label_7 = wx.StaticText(self, wx.ID_ANY, "Vcenter / esxi:")
self.nombre_vcenter = wx.TextCtrl(self, wx.ID_ANY, "")
self.label_9 = wx.StaticText(self, wx.ID_ANY, "Login:")
self.login_vcenter = wx.TextCtrl(self, wx.ID_ANY, "")
self.label_10 = wx.StaticText(self, wx.ID_ANY, "Password:")
self.passwor_vcenter = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_PASSWORD)
self.label_8 = wx.StaticText(self, wx.ID_ANY, "Puerto:")
self.puert_vcenter = wx.TextCtrl(self, wx.ID_ANY, "")
self.button_Exit = wx.Button(self, wx.ID_CANCEL, "Exit")
self.button_Connect = wx.Button(self, wx.ID_OK, "Conectar")
self.__set_properties()
self.__do_layout()
# end wxGlade
python类ID_CANCEL的实例源码
def buildDialog(filePath, resourceName, mayCancel, **defaults):
"""Return a configured wx.Dialog.
Assumes that the OK and Cancel buttons are named ID_OK & ID_CANCEL.
"""
res = loadXrc(filePath)
insureWxApp()
dlg = res.LoadDialog(None, resourceName)
assert isinstance(dlg, wx.Dialog)
dlg.Fit()
fetchWidget = dlg.FindWindowByName
bOk = dlg.FindWindowByName('ID_OK')
bCancel = dlg.FindWindowByName('ID_CANCEL')
bOk.SetId(wx.ID_OK)
bCancel.SetId(wx.ID_CANCEL)
if not mayCancel:
bCancel.Disable()
bCancel.Hide()
for name, value in defaults.items():
dlg.FindWindowByName(name).SetValue(value)
if not mayCancel:
dlg.Bind(wx.EVT_CHAR_HOOK, escapeSuppressor)
return dlg
def OnQuit(self,event,dbfile):
if _plat.startswith('linux'):
dlg = wx.MessageDialog(self, 'Really quit?','', wx.OK | wx.CANCEL | wx.ICON_ERROR)
val = dlg.ShowModal()
dlg.Show()
if val == wx.ID_CANCEL:
dlg.Destroy()
elif val == wx.ID_OK:
OKQuit = self.DBQuit(dbfile)
if OKQuit == 42:
self.Close()
elif _plat.startswith('darwin'):
pass
elif _plat.startswith('win'):
OKQuit = self.DBQuit(dbfile)
if OKQuit == 42:
self.Close()
sys.exit()#windows
self.Refresh()
def saveCap(self):
cap = self.src.getEEGSecs(self.getSessionTime(), filter=False)
saveDialog = wx.FileDialog(self, message='Save EEG data.',
wildcard='Pickle (*.pkl)|*.pkl|All Files|*',
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
try:
if saveDialog.ShowModal() == wx.ID_CANCEL:
return
cap.saveFile(saveDialog.GetPath())
except Exception:
wx.LogError('Save failed!')
raise
finally:
saveDialog.Destroy()
def mediaBrowse(self, event):
dialog = wx.DirDialog(self, 'Choose media directory', '',
style=wx.DD_DEFAULT_STYLE)
try:
if dialog.ShowModal() == wx.ID_CANCEL:
return
path = dialog.GetPath()
except Exception:
wx.LogError('Failed to open directory!')
raise
finally:
dialog.Destroy()
if len(path) > 0:
self.mediaPathTextCtrl.SetValue(path)
self.pg.mplayer.setCWD(path)
def beforeStop(self):
if not 'practice' in self.protocol:
cap = self.src.getEEGSecs(time.time() - self.startTime, filter=False)
fileName = self.subjectTextCtrl.GetValue() + '-' +\
self.protocol.replace(' ', '-') + '.pkl'
saveDialog = wx.FileDialog(self, message='Save EEG data.',
wildcard='Pickle (*.pkl)|*.pkl|All Files|*',
defaultFile=fileName,
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
try:
if saveDialog.ShowModal() == wx.ID_CANCEL:
return
cap.saveFile(saveDialog.GetPath())
except Exception:
wx.LogError('Save failed!')
raise
finally:
saveDialog.Destroy()
def saveCap(self):
cap = self.src.getEEGSecs(self.getSessionTime(), filter=False)
saveDialog = wx.FileDialog(self, message='Save EEG data.',
wildcard='Pickle (*.pkl)|*.pkl|All Files|*',
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
try:
if saveDialog.ShowModal() == wx.ID_CANCEL:
return
cap.saveFile(saveDialog.GetPath())
except Exception:
wx.LogError('Save failed!')
raise
finally:
saveDialog.Destroy()
def saveCap(self):
cap = self.src.getEEGSecs(self.getSessionTime(), filter=False)
saveDialog = wx.FileDialog(self, message='Save EEG data.',
wildcard='Pickle (*.pkl)|*.pkl|All Files|*',
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
try:
if saveDialog.ShowModal() == wx.ID_CANCEL:
return
cap.saveFile(saveDialog.GetPath())
except Exception:
wx.LogError('Save failed!')
raise
finally:
saveDialog.Destroy()
def saveMessages(self, event=None):
"""Save the message log to file.
"""
saveDialog = wx.FileDialog(self.scrolledPanel, message='Save Message Log',
wildcard='Text Files (*.txt)|*.txt|All Files|*',
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
try:
if saveDialog.ShowModal() == wx.ID_CANCEL:
return
with open(saveDialog.GetPath(), 'w') as fileHandle:
fileHandle.write(self.messageArea.GetValue())
except Exception as e:
wx.LogError('Save failed!')
raise
finally:
saveDialog.Destroy()
def loadFile(self, event=None):
openFileDialog = wx.FileDialog(None, message='Load EEG data.',
wildcard='JSON (*.json)|*.json|All Files|*',
style=wx.FD_OPEN)
try:
if openFileDialog.ShowModal() == wx.ID_CANCEL:
return wx.ID_CANCEL
except Exception:
wx.LogError('Save failed!')
raise
finally:
openFileDialog.Destroy()
cap = eeg.EEGFromJSON(openFileDialog.GetPath(), protocol='3minutes')
self.replayData = cap.data
self.setSampRate(cap.getSampRate())
self.setChans(cap.getChanNames())
def __init__(self, *args, **kwds):
# begin wxGlade: Dialog_snapshot.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
wx.Dialog.__init__(self, *args, **kwds)
self.label_1 = wx.StaticText(self, wx.ID_ANY, "Nombre:")
self.nombre_snap = wx.TextCtrl(self, wx.ID_ANY, "")
self.label_2 = wx.StaticText(self, wx.ID_ANY, u"Descripci\u00f3n:")
self.descripcion_snap = wx.TextCtrl(self, wx.ID_ANY, "")
self.checkbox_memory = wx.CheckBox(self, wx.ID_ANY, "memory")
self.checkbox_quiesce = wx.CheckBox(self, wx.ID_ANY, "quiesce")
self.snap_ok = wx.Button(self, wx.ID_OK, "OK")
self.snap_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
self.__set_properties()
self.__do_layout()
# end wxGlade
def __init__(self, *args, **kwds):
# begin wxGlade: LogicalVolumeDialog.__init__
wx.Dialog.__init__(self, *args, **kwds)
self.panel_1 = wx.Panel(self, wx.ID_ANY)
self.panel_4 = wx.Panel(self, wx.ID_ANY)
self.label_1 = wx.StaticText(self, wx.ID_ANY, _("Select Logical Volume: "), style=wx.ALIGN_CENTER_HORIZONTAL)
self.panel_7 = wx.Panel(self, wx.ID_ANY)
self.combo_logical_volumes = wx.ComboBox(self, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN)
self.panel_8 = wx.Panel(self, wx.ID_ANY)
self.panel_3 = wx.Panel(self, wx.ID_ANY)
self.panel_5 = wx.Panel(self, wx.ID_ANY)
self.button_select = wx.Button(self, wx.ID_OK, _("Select"))
self.panel_9 = wx.Panel(self, wx.ID_ANY)
self.button_cancel = wx.Button(self, wx.ID_CANCEL, _("Cancel"))
self.panel_6 = wx.Panel(self, wx.ID_ANY)
self.panel_2 = wx.Panel(self, wx.ID_ANY)
self.__set_properties()
self.__do_layout()
self.Bind(wx.EVT_BUTTON, self.button_select_click, id=wx.ID_OK)
self.Bind(wx.EVT_BUTTON, self.button_cancel_click, id=wx.ID_CANCEL)
# end wxGlade
self.PopulateVolumes()
def CheckSaveBeforeClosing(self, title=_("Close Project")):
"""Function displaying an question dialog if project is not saved"
:returns: False if closing cancelled.
"""
if not self.Controler.ProjectIsSaved():
dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"), title, wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION)
answer = dialog.ShowModal()
dialog.Destroy()
if answer == wx.ID_YES:
self.SaveProject()
elif answer == wx.ID_CANCEL:
return False
for idx in xrange(self.TabsOpened.GetPageCount()):
window = self.TabsOpened.GetPage(idx)
if not window.CheckSaveBeforeClosing():
return False
return True
# -------------------------------------------------------------------------------
# File Menu Functions
# -------------------------------------------------------------------------------
def __init__( self, parent, id, titlemsg ):
wx.Dialog.__init__( self, parent, id, title=titlemsg )
MechList = []
for m in parent.ScoreServer.MechList.List:
MechList.append( str(m.ID) + ": " + str(m.Name) )
self.MechText = wx.StaticText( self, -1, "Mech Selection:" )
self.MechChoice = wx.ListBox( self, -1, style=wx.LB_EXTENDED, choices=MechList )
self.CancelButton = wx.Button( self, wx.ID_CANCEL, "Cancel" )
self.OKButton = wx.Button( self, wx.ID_OK, "OK" )
TopSizer = wx.BoxSizer( wx.VERTICAL )
BtnSizer = wx.BoxSizer( wx.HORIZONTAL )
BtnSizer.Add( self.CancelButton, 0, wx.ALL, 5 )
BtnSizer.Add( self.OKButton, 0, wx.ALL, 5 )
TopSizer.Add( self.MechText, 0, wx.ALL, 5 )
TopSizer.Add( self.MechChoice, 0, wx.ALL, 5 )
TopSizer.Add( BtnSizer, 0, wx.ALL|wx.CENTER, 5 )
self.SetSizer( TopSizer )
TopSizer.Fit( self )
def __init__(self, *args, **kwds):
self.settings = kwds['settings']
del kwds['settings']
# begin wxGlade: TerminalSettingsDialog.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
self.checkbox_echo = wx.CheckBox(self, -1, "Local Echo")
self.checkbox_unprintable = wx.CheckBox(self, -1, "Show unprintable characters")
self.radio_box_newline = wx.RadioBox(self, -1, "Newline Handling", choices=["CR only", "LF only", "CR+LF"], majorDimension=0, style=wx.RA_SPECIFY_ROWS)
self.sizer_4_staticbox = wx.StaticBox(self, -1, "Input/Output")
self.button_ok = wx.Button(self, wx.ID_OK, "")
self.button_cancel = wx.Button(self, wx.ID_CANCEL, "")
self.__set_properties()
self.__do_layout()
# end wxGlade
self.__attach_events()
self.checkbox_echo.SetValue(self.settings.echo)
self.checkbox_unprintable.SetValue(self.settings.unprintable)
self.radio_box_newline.SetSelection(self.settings.newline)
def on_open(self, event):
"""
Recursively loads a KiCad schematic and all subsheets
"""
#self.save_component_type_changes()
open_dialog = wx.FileDialog(self, "Open KiCad Schematic", "", "",
"Kicad Schematics (*.sch)|*.sch",
wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if open_dialog.ShowModal() == wx.ID_CANCEL:
return
# Load Chosen Schematic
print("opening File:", open_dialog.GetPath())
# Store the path to the file history
self.filehistory.AddFileToHistory(open_dialog.GetPath())
self.filehistory.Save(self.config)
self.config.Flush()
self.load(open_dialog.GetPath())
def __init__(self, parent):
wx.Dialog.__init__(self, parent, -1, title=u"Logon", style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER)
vsizer = wx.BoxSizer(orient=wx.VERTICAL)
gb = wx.GridBagSizer()
gb.Add(wx.StaticText(self, -1, u"Username"), flag=wx.ALL|wx.EXPAND, border=10, pos=(0,0))
self._name = wx.TextCtrl(self, -1)
gb.Add(self._name, flag=wx.ALL|wx.EXPAND, border=10, pos=(0,1))
gb.Add(wx.StaticText(self, -1, u"Password"), flag=wx.ALL|wx.EXPAND, pos=(1,0), border=10)
self._pass = wx.TextCtrl(self, -1, style=wx.TE_PASSWORD)
gb.Add(self._pass, border=10, flag=wx.EXPAND|wx.ALL, pos=(1,1))
gb.AddGrowableCol(1)
butsz = wx.StdDialogButtonSizer()
okbut = wx.Button(self, wx.ID_OK, u"OK")
butsz.AddButton(okbut)
cbut = wx.Button(self, wx.ID_CANCEL, u"Cancel")
butsz.AddButton(cbut)
insp = wx.Button(self, wx.ID_HELP, u"Help")
butsz.AddButton(insp)
insp.Bind(wx.EVT_BUTTON, InspectionTool().Show)
butsz.Realize()
okbut.SetDefault()
vsizer.Add(gb, 0, wx.EXPAND)
vsizer.Add(butsz, 0, wx.EXPAND)
self.SetSizer(vsizer)
self.Fit()
def __init__(self, parent):
with iz.Dialog(init=self, title=u"Logon", orient=wx.VERTICAL, style=wx.DEFAULT_DIALOG_STYLE|wx.RESIZE_BORDER):
with iz.GridBagSizer(orient=wx.HORIZONTAL, proportion=1) as gb:
# Defaults for StaticText and TextCtrl are normally border=0,proportion=0,flag=0. Change them temporarily
# to avoid repeating the same options for each and every control:
with iz.StaticText.Default(border=10), iz.TextCtrl.Default(border=10, proportion=1, flag=wx.EXPAND):
# Now the sizer parameters can be omitted in the control definitions, since the defaults are
# now appropriate.
iz.StaticText(u"Username")
self._name = iz.TextCtrl().wx
iz.StaticText(u"Password", x=0)
self._pass = iz.TextCtrl(style=wx.TE_PASSWORD).wx
gb.AddGrowableCol(1)
with iz.StdDialogButtonSizer():
okbut = iz.Button(u"OK", id=wx.ID_OK).wx
iz.Button(u"Cancel", id=wx.ID_CANCEL)
insp = iz.Button(u"Help", id=wx.ID_HELP,border=10, EVT_BUTTON=InspectionTool().Show).wx
okbut.SetDefault()
self.Fit()
def OnOpen(self, event):
openFileDialog = wx.FileDialog(self, "Open i3 Config file", os.path.expanduser("~/.i3/"), "","i3 Config file |*", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if openFileDialog.ShowModal() == wx.ID_CANCEL:
return
cfg = Config(self.messager,openFileDialog.GetPath())
self.LoadConfig(cfg)
def OnCreateVariable(self,event):
openColourDialog = wx.ColourDialog(self)
if openColourDialog.ShowModal() == wx.ID_CANCEL:
return
openNameChooser = wx.TextEntryDialog(self,"What would you like your new colour variable to be called?")
if openNameChooser.ShowModal() == wx.ID_CANCEL:
return
proposed = openNameChooser.GetValue()
name = ""
seenChar = False
for character in proposed:
if not seenChar:
if character in string.ascii_letters:
name+=character
seenChar=True
elif character in string.ascii_letters+string.digits:
name+=character
if name=="":
i = 0
for name in self.config.setColours:
if name[:14]=="colourVariable":
i+=1
name = "colourVariable"+str(i)
name = "$"+name
self.config.setColourChanged(openColourDialog.GetColourData(),name)
self.LoadConfig(self.config)
def WorkSpace(self,e ):
'''
Load in a project.
'''
logging.exception(self.clargs)
dbfile = self.clargs['project']
if not os.path.isfile(dbfile):
dlg = wx.MessageDialog(self, 'Project not found. Browse for the file?',
'',wx.YES_NO | wx.YES_DEFAULT | wx.CANCEL | wx.ICON_QUESTION)
val = dlg.ShowModal()
if val == wx.ID_YES:
self.OpenFile(e,False)
elif val == wx.ID_CANCEL:
dlg.Destroy()
else:
self.OpenFile(False,dbfile)
self.bplay.SetBitmapLabel(self.bplayicon)
self.panel2.Refresh()
#update timeline view
self.Layout()
self.panel3.SetFocus()
def TakeSnapshot(self,e,args):
logging.exception('CAPTURE')
if self.camset == 1:
self.framlog += 1
#print(self.camhero)#DEBUG
vidcap = vlc.libvlc_video_take_snapshot(self.player,0,os.path.join(self.imgdir, str(self.framlog).zfill(3)+'.png'),0,0)
self.cur.execute('INSERT INTO Timeline VALUES(Null,?,?)', (str(self.framlog).zfill(3)+'.png',0))
# add graphically to timeline
img = self.MakeThumbnail(os.path.join(self.imgdir, str(self.framlog).zfill(3)+'.png'), self.thumbsize)
self.imageCtrl = wx.StaticBitmap(self.panel3, wx.ID_ANY, wx.BitmapFromImage(img),name=str(self.framlog).zfill(3)+'.png')
self.imageCtrl.SetBitmap(wx.BitmapFromImage(img))
self.imageCtrl.Bind( wx.EVT_LEFT_DOWN, self.OnLeftClick )
self.imageCtrl.Bind( wx.EVT_LEFT_UP, self.OnLeftRelease )
logging.exception(self.imageCtrl.GetId() )
self.hbox2.Add( self.imageCtrl, 0, wx.ALL, 5 )
# scroll right 100% to get close to new frame
self.panel3.Scroll(self.thumbsize,0)
self.Layout()
# draw new frame
self.hbox2.Layout()
self.panel3.Refresh()
# scroll WAY right again to show frame
self.panel3.Scroll(200,0)
# send the shot to onion skin
img = os.path.join(self.imgdir, str(self.framlog).zfill(3)+'.png')
self.OnionSkin(img)
logging.exception(self.framlog)
else:
dlg = wx.MessageDialog(self, 'Please select your camera first.','',wx.OK | wx.ICON_ERROR)
val = dlg.ShowModal()
if val == wx.ID_OK:
dlg.Destroy()
if val == wx.ID_CANCEL:
dlg.Destroy()
self.player.play()
self.brec.SetBitmapLabel(self.brecicon)
def __init__(self, parent, name, number, minnamelen, maxnamelen):
wxskinDialog.__init__(self, parent, -1, "Phonebook edit entry")
self.SetAutoLayout(True)
self.name = None
self.number = None
nameTextId = wx.NewId()
# Main window resizer object
border = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self, -1, "Enter the phonebook entry name, number and press OK.")
border.Add(label, 1, wx.ALL, 10)
#fgs = wx.FlexGridSizer(2,3,5,20)
fgs = wx.BoxSizer(wx.HORIZONTAL)
label = wx.StaticText(self, -1, "Name (max %d): " % maxnamelen)
fgs.Add(label, 1, wx.ALIGN_LEFT | wx.LEFT, 10)
self.nameCtrl = wx.TextCtrl(self, nameTextId, name, validator = pySIMvalidator(None, minnamelen, maxnamelen))
fgs.Add(self.nameCtrl, 1, wx.ALIGN_RIGHT | wx.RIGHT, 10)
border.Add(fgs, 1, wx.ALL)
fgs = wx.BoxSizer(wx.HORIZONTAL)
label = wx.StaticText(self, -1, "Number (max 20): ")
fgs.Add(label, 1, wx.ALIGN_LEFT | wx.LEFT, 10)
self.numberCtrl = wx.TextCtrl(self, -1, number, validator = pySIMvalidator("+*#pw0123456789", None, 20))
fgs.Add(self.numberCtrl, 1, wx.ALIGN_RIGHT | wx.RIGHT, 10)
border.Add(fgs, 1, wx.ALL)
buttons = wx.BoxSizer(wx.HORIZONTAL)
buttons.Add(wx.Button(self, ID_BUTTON_OK, "Okay"), 1, wx.ALIGN_LEFT | wx.ALL, 20)
buttons.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
border.Add(buttons, 1, wx.ALL)
wx.EVT_BUTTON(self, ID_BUTTON_OK, self.onOK)
wx.EVT_TEXT_ENTER(self, nameTextId, self.onOK)
self.SetAutoLayout(1);
self.SetSizer(border)
border.Fit(self)
self.Layout()
def __init__(self, parent, name):
wxskinDialog.__init__(self, parent, -1, "Phonebook import")
self.SetAutoLayout(True)
self.function = 0
# Main window resizer object
border = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self, -1, "Name '%s' already exists in SIM phonebook.\n\nDo you want to overwrite exisiting, duplicate or skip!?" % (name))
border.Add(label, 1, wx.ALL, 10)
buttons = wx.BoxSizer(wx.HORIZONTAL)
buttons.Add(wx.Button(self, ID_BUTTON_OVERWRITE, "Overwrite"), 1, wx.ALIGN_LEFT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_COPY, "Duplicate"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_SKIP, "Skip"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
border.Add(buttons, 1, wx.ALL)
self.applyAll = wx.CheckBox(self, ID_CHECKBOX_APPLY_ALL, " Apply to all", wx.Point(65, 40), wx.Size(150, 20), wx.NO_BORDER)
border.Add(self.applyAll, 1, wx.ALIGN_CENTER | wx.ALL)
wx.EVT_BUTTON(self, ID_BUTTON_OVERWRITE, self.onOverwrite)
wx.EVT_BUTTON(self, ID_BUTTON_COPY, self.onDuplicate)
wx.EVT_BUTTON(self, ID_BUTTON_SKIP, self.onSkip)
self.SetAutoLayout(1);
self.SetSizer(border)
border.Fit(self)
self.Layout()
def __init__(self, parent, name, number, minnamelen, maxnamelen):
wxskinDialog.__init__(self, parent, -1, "Phonebook edit entry")
self.SetAutoLayout(True)
self.name = None
self.number = None
nameTextId = wx.NewId()
# Main window resizer object
border = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self, -1, "Enter the phonebook entry name, number and press OK.")
border.Add(label, 1, wx.ALL, 10)
#fgs = wx.FlexGridSizer(2,3,5,20)
fgs = wx.BoxSizer(wx.HORIZONTAL)
label = wx.StaticText(self, -1, "Name (max %d): " % maxnamelen)
fgs.Add(label, 1, wx.ALIGN_LEFT | wx.LEFT, 10)
self.nameCtrl = wx.TextCtrl(self, nameTextId, name, validator = pySIMvalidator(None, minnamelen, maxnamelen))
fgs.Add(self.nameCtrl, 1, wx.ALIGN_RIGHT | wx.RIGHT, 10)
border.Add(fgs, 1, wx.ALL)
fgs = wx.BoxSizer(wx.HORIZONTAL)
label = wx.StaticText(self, -1, "Number (max 20): ")
fgs.Add(label, 1, wx.ALIGN_LEFT | wx.LEFT, 10)
self.numberCtrl = wx.TextCtrl(self, -1, number, validator = pySIMvalidator("+*#pw0123456789", None, 20))
fgs.Add(self.numberCtrl, 1, wx.ALIGN_RIGHT | wx.RIGHT, 10)
border.Add(fgs, 1, wx.ALL)
buttons = wx.BoxSizer(wx.HORIZONTAL)
buttons.Add(wx.Button(self, ID_BUTTON_OK, "Okay"), 1, wx.ALIGN_LEFT | wx.ALL, 20)
buttons.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
border.Add(buttons, 1, wx.ALL)
wx.EVT_BUTTON(self, ID_BUTTON_OK, self.onOK)
wx.EVT_TEXT_ENTER(self, nameTextId, self.onOK)
self.SetAutoLayout(1);
self.SetSizer(border)
border.Fit(self)
self.Layout()
def __init__(self, parent, name):
wxskinDialog.__init__(self, parent, -1, "Phonebook import")
self.SetAutoLayout(True)
self.function = 0
# Main window resizer object
border = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self, -1, "Name '%s' already exists in SIM phonebook.\n\nDo you want to overwrite exisiting, duplicate or skip!?" % (name))
border.Add(label, 1, wx.ALL, 10)
buttons = wx.BoxSizer(wx.HORIZONTAL)
buttons.Add(wx.Button(self, ID_BUTTON_OVERWRITE, "Overwrite"), 1, wx.ALIGN_LEFT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_COPY, "Duplicate"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, ID_BUTTON_SKIP, "Skip"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
buttons.Add(wx.Button(self, wx.ID_CANCEL, "Cancel"), 1, wx.ALIGN_RIGHT | wx.ALL, 20)
border.Add(buttons, 1, wx.ALL)
self.applyAll = wx.CheckBox(self, ID_CHECKBOX_APPLY_ALL, " Apply to all", wx.Point(65, 40), wx.Size(150, 20), wx.NO_BORDER)
border.Add(self.applyAll, 1, wx.ALIGN_CENTER | wx.ALL)
wx.EVT_BUTTON(self, ID_BUTTON_OVERWRITE, self.onOverwrite)
wx.EVT_BUTTON(self, ID_BUTTON_COPY, self.onDuplicate)
wx.EVT_BUTTON(self, ID_BUTTON_SKIP, self.onSkip)
self.SetAutoLayout(1);
self.SetSizer(border)
border.Fit(self)
self.Layout()
def OnResult(self, event):
if self.progressDialog:
self.progressDialog.EndModal(wx.ID_CANCEL)
self.progressDialog.Destroy()
data = event.data
if data:
self.statusbar.SetStatusText("Read %d logs" % len(data))
self.data = data
self.data_view = self.data
self.SetupGrid()
def saveResultText(self, resultText):
saveDialog = wx.FileDialog(self, message='Save Result Text.',
wildcard='Text (*.txt)|*.txt|All Files|*',
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
try:
if saveDialog.ShowModal() == wx.ID_CANCEL:
return
with open(saveDialog.GetPath(), 'w') as fd:
fd.write(resultText)
except Exception:
wx.LogError('Save failed!')
raise
finally:
saveDialog.Destroy()
def saveCap(self):
cap = self.src.getEEGSecs(self.getSessionTime(), filter=False)
saveDialog = wx.FileDialog(self, message='Save EEG data.',
wildcard='Pickle (*.pkl)|*.pkl|All Files|*',
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
try:
if saveDialog.ShowModal() == wx.ID_CANCEL:
return
cap.saveFile(saveDialog.GetPath())
except Exception:
wx.LogError('Save failed!')
raise
finally:
saveDialog.Destroy()
##def decimate(self, cap):
## #cap = cap.demean().bandpass(0.5, 10.0, order=3)
## cap = cap.copy().demean().bandpass(0.5, 12.0, order=3)
## # kind of a hack XXX - idfah
## if cap.getSampRate() > 32.0:
## decimationFactor = int(np.round(cap.getSampRate()/32.0))
## cap = cap.downsample(decimationFactor)
## return cap
def saveCap(self):
cap = self.src.getEEGSecs(self.getSessionTime(), filter=False)
saveDialog = wx.FileDialog(self, message='Save EEG data.',
wildcard='Pickle (*.pkl)|*.pkl|All Files|*',
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
try:
if saveDialog.ShowModal() == wx.ID_CANCEL:
return
cap.saveFile(saveDialog.GetPath())
except Exception:
wx.LogError('Save failed!')
raise
finally:
saveDialog.Destroy()