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()
python类ID_CANCEL的实例源码
def beforeStart(self):
"""Set things up for starting the source.
"""
if self.replayData is None:
try:
if self.loadFile() == wx.ID_CANCEL:
wx.LogError('Failed to load data!')
# maybe play some default data instead of bombing? XXX - idfah
raise Exception('Critical file load canceled.')
except Exception:
raise
self.shift = self.pollSize / float(self.sampRate)
self.pollDelay = -1.0
self.lastPollTime = -1.0
def saveFile(self):
self.refresh()
saveDialog = wx.FileDialog(self, message='Save Image',
wildcard='Portable Network Graphics (*.png)|*.png|All Files|*',
style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
try:
if saveDialog.ShowModal() != wx.ID_CANCEL:
img = self.drawingBuffer.ConvertToImage()
img.SaveFile(saveDialog.GetPath(), wx.BITMAP_TYPE_PNG)
except Exception as e:
wx.LogError('Save failed!')
raise
finally:
saveDialog.Destroy()
def __init__(self, *args, **kwds):
# begin wxGlade: Dialogo_user_pass.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
wx.Dialog.__init__(self, *args, **kwds)
self.label_3 = wx.StaticText(self, wx.ID_ANY, "Usuario:")
self.usuario = wx.TextCtrl(self, wx.ID_ANY, "")
self.label_4 = wx.StaticText(self, wx.ID_ANY, "Password:")
self.password = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_PASSWORD)
self.button_OK = wx.Button(self, wx.ID_OK, "OK")
self.button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")
self.__set_properties()
self.__do_layout()
# end wxGlade
def button_cancel_click(self, event): # wxGlade: ExtractionDialog.<event_handler>
print "Event handler 'button_cancel_click' not implemented!"
self.EndModal(wx.ID_CANCEL )
def audio_btn_click(self, e):
openFileDialog = wx.FileDialog(self, "Select caps folder", "", "", "MP3 files (*.mp3)|*.mp3", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
openFileDialog.SetMessage("Select an audio file from to use")
if openFileDialog.ShowModal() == wx.ID_CANCEL:
return 'none'
audio_track = openFileDialog.GetPath()
self.audio_box.SetValue(str(audio_track))
def select_caps_folder(self):
openFileDialog = wx.FileDialog(self, "Select caps folder", "", "", "JPG files (*.jpg)|*.jpg", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
openFileDialog.SetMessage("Select an image from the caps folder you want to import")
if openFileDialog.ShowModal() == wx.ID_CANCEL:
return 'none'
new_cap_path = openFileDialog.GetPath()
capsdir = os.path.split(new_cap_path)
capset = capsdir[1].split(".")[0][0:-10] # Used to select set if more than one are present
cap_type = capsdir[1].split('.')[1]
capsdir = capsdir[0] + '/'
print(" Selected " + capsdir + " with capset; " + capset + " filetype; " + cap_type)
return capsdir, capset, cap_type
def __init__(self, parent):
super(WaveformPanel, self).__init__(parent=parent)
self.parent = parent
start_text = wx.StaticText(self, label="Start position (seconds)")
self.start_position = wx.SpinCtrlDouble(self)
stop_text = wx.StaticText(self, label="Stop position (seconds)")
self.stop_position = wx.SpinCtrlDouble(self)
volume_text = wx.StaticText(self, label="Playback volume")
volume_slider = wx.Slider(parent=self, value=25, style=wx.SL_HORIZONTAL | wx.SL_VALUE_LABEL)
ok_button = wx.Button(parent=self, id=wx.ID_OK, label="Trim")
cancel_button = wx.Button(parent=self, id=wx.ID_CANCEL)
top_sizer = wx.BoxSizer(wx.VERTICAL)
button_sizer = wx.BoxSizer(wx.HORIZONTAL)
top_sizer.Add(start_text, 0, wx.ALL ^ wx.BOTTOM, 5)
top_sizer.Add(self.start_position, 0, wx.ALL, 5)
top_sizer.Add(stop_text, 0, wx.ALL ^ wx.BOTTOM, 5)
top_sizer.Add(self.stop_position, 0, wx.ALL, 5)
top_sizer.Add(volume_text, 0, wx.ALL ^ wx.BOTTOM, 5)
top_sizer.Add(volume_slider, 0, wx.ALL | wx.EXPAND, 5)
top_sizer.Add(button_sizer, 0, wx.ALL | wx.EXPAND, 5)
button_sizer.Add(ok_button, 0, wx.ALL, 5)
button_sizer.Add(cancel_button, 0, wx.ALL, 5)
self.Bind(wx.EVT_SPINCTRLDOUBLE, source=self.start_position, handler=self.on_change)
self.Bind(wx.EVT_SPINCTRLDOUBLE, source=self.stop_position, handler=self.on_change)
self.Bind(wx.EVT_SLIDER, source=volume_slider, handler=self.on_volume)
self.SetSizerAndFit(top_sizer)
def __init__(self, parent):
# Translators: The title of a dialog to configure advanced WinTenApps add-on options such as update checking.
super(WinTenAppsConfigDialog, self).__init__(parent, title=_("Windows 10 App Essentials settings"))
mainSizer = wx.BoxSizer(wx.VERTICAL)
w10Helper = gui.guiHelper.BoxSizerHelper(self, orientation=wx.VERTICAL)
# Translators: A checkbox to toggle automatic add-on updates.
self.autoUpdateCheckbox=w10Helper.addItem(wx.CheckBox(self,label=_("Automatically check for add-on &updates")))
self.autoUpdateCheckbox.SetValue(config.conf["wintenApps"]["autoUpdateCheck"])
# Translators: The label for a setting in WinTenApps add-on settings to select automatic update interval in days.
self.updateInterval=w10Helper.addLabeledControl(_("Update &interval in days"), gui.nvdaControls.SelectOnFocusSpinCtrl, min=0, max=30, initial=config.conf["wintenApps"]["updateCheckTimeInterval"])
# Translators: The label for a combo box to select update channel.
labelText = _("&Add-on update channel:")
self.channels=w10Helper.addLabeledControl(labelText, wx.Choice, choices=["development", "stable"])
self.updateChannels = ("dev", "stable")
self.channels.SetSelection(self.updateChannels.index(config.conf["wintenApps"]["updateChannel"]))
if canUpdate:
# Translators: The label of a button to check for add-on updates.
updateCheckButton = w10Helper.addItem(wx.Button(self, label=_("Check for add-on &update")))
updateCheckButton.Bind(wx.EVT_BUTTON, self.onUpdateCheck)
w10Helper.addDialogDismissButtons(self.CreateButtonSizer(wx.OK | wx.CANCEL))
self.Bind(wx.EVT_BUTTON, self.onOk, id=wx.ID_OK)
self.Bind(wx.EVT_BUTTON, self.onCancel, id=wx.ID_CANCEL)
mainSizer.Add(w10Helper.sizer, border=gui.guiHelper.BORDER_FOR_DIALOGS, flag=wx.ALL)
mainSizer.Fit(self)
self.Sizer = mainSizer
self.autoUpdateCheckbox.SetFocus()
self.Center(wx.BOTH | (wx.CENTER_ON_SCREEN if hasattr(wx, "CENTER_ON_SCREEN") else 2))
def OnCloseButton(self, event):
self.EndModal(wx.ID_CANCEL)
def yes_no(info, title="ImagePy Yes-No ?!"):
dlg = wx.MessageDialog(curapp, info, title, wx.YES_NO | wx.CANCEL)
rst = dlg.ShowModal()
dlg.Destroy()
dic = {wx.ID_YES:'yes', wx.ID_NO:'no', wx.ID_CANCEL:'cancel'}
return dic[rst]
def add_confirm(self, modal=True):
self.lst.AddStretchSpacer(1)
sizer = wx.BoxSizer( wx.HORIZONTAL )
self.btn_OK = wx.Button( self, wx.ID_OK, 'OK')
sizer.Add( self.btn_OK, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
self.btn_cancel = wx.Button( self, wx.ID_CANCEL, 'Cancel')
sizer.Add( self.btn_cancel, 0, wx.ALIGN_RIGHT|wx.ALL, 5 )
self.lst.Add(sizer, 0, wx.ALIGN_RIGHT, 5 )
if not modal:
self.btn_OK.Bind( wx.EVT_BUTTON, lambda e:self.commit('ok'))
self.btn_cancel.Bind( wx.EVT_BUTTON, lambda e:self.commit('cancel'))
def __init__(self, *args, **kwds):
# begin wxGlade: ui_choice2Dialog.__init__
kwds["style"] = wx.DIALOG_NO_PARENT
wx.Dialog.__init__(self, *args, **kwds)
self.numListBox = wx.ListBox(self, -1, choices=[], style=wx.LB_MULTIPLE)
self.button_ok = wx.Button(self, wx.ID_OK, "")
self.denListBox = wx.ListBox(self, -1, choices=[], style=wx.LB_MULTIPLE)
self.button_cancel = wx.Button(self, wx.ID_CANCEL, "")
self.__set_properties()
self.__do_layout()
# end wxGlade
def __init__( self, parent, id ):
wx.Dialog.__init__( self, parent, id, title="SocketServer Setup" )
self.HostText = wx.StaticText( self, -1, "Host:" )
self.HostChoice = wx.TextCtrl( self, -1, str( parent.ScoreServer.SocketServer.Host ) )
self.PortText = wx.StaticText( self, -1, "Port:" )
self.PortChoice = wx.TextCtrl( self, -1, str( parent.ScoreServer.SocketServer.Port ) )
self.CancelButton = wx.Button( self, wx.ID_CANCEL, "Cancel" )
self.OKButton = wx.Button( self, wx.ID_OK, "OK" )
TopSizer = wx.BoxSizer( wx.VERTICAL )
HostSizer = wx.BoxSizer( wx.HORIZONTAL )
PortSizer = wx.BoxSizer( wx.HORIZONTAL )
BtnSizer = wx.BoxSizer( wx.HORIZONTAL )
HostSizer.Add( self.HostText, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
HostSizer.Add( self.HostChoice, 2, wx.ALL, 5 )
PortSizer.Add( self.PortText, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
PortSizer.Add( self.PortChoice, 2, wx.ALL, 5 )
BtnSizer.Add( self.CancelButton, 0, wx.ALL, 5 )
BtnSizer.Add( self.OKButton, 0, wx.ALL, 5 )
TopSizer.Add( HostSizer, 0, wx.ALL|wx.CENTER, 5 )
TopSizer.Add( PortSizer, 0, wx.ALL|wx.CENTER, 5 )
TopSizer.Add( BtnSizer, 0, wx.ALL|wx.CENTER, 5 )
self.SetSizer( TopSizer )
TopSizer.Fit( self )
def __init__( self, parent, id ):
wx.Dialog.__init__( self, parent, id, title="TransponderListener Setup" )
self.PortText = wx.StaticText( self, -1, "Port:" )
self.PortChoice = wx.TextCtrl( self, -1, str( parent.ScoreServer.TransponderListener.Port ) )
self.BaudText = wx.StaticText( self, -1, "Host:" )
self.BaudChoice = wx.TextCtrl( self, -1, str( parent.ScoreServer.TransponderListener.Baudrate ) )
self.CancelButton = wx.Button( self, wx.ID_CANCEL, "Cancel" )
self.OKButton = wx.Button( self, wx.ID_OK, "OK" )
TopSizer = wx.BoxSizer( wx.VERTICAL )
BaudSizer = wx.BoxSizer( wx.HORIZONTAL )
PortSizer = wx.BoxSizer( wx.HORIZONTAL )
BtnSizer = wx.BoxSizer( wx.HORIZONTAL )
PortSizer.Add( self.PortText, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
PortSizer.Add( self.PortChoice, 2, wx.ALL, 5 )
BaudSizer.Add( self.BaudText, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 )
BaudSizer.Add( self.BaudChoice, 2, wx.ALL, 5 )
BtnSizer.Add( self.CancelButton, 0, wx.ALL, 5 )
BtnSizer.Add( self.OKButton, 0, wx.ALL, 5 )
TopSizer.Add( PortSizer, 0, wx.ALL|wx.CENTER, 5 )
TopSizer.Add( BaudSizer, 0, wx.ALL|wx.CENTER, 5 )
TopSizer.Add( BtnSizer, 0, wx.ALL|wx.CENTER, 5 )
self.SetSizer( TopSizer )
TopSizer.Fit( self )
def load_event(self, e):
dia = wx.FileDialog(self, "Load Bracket",
"", "", "bp5000 bracket|*.bp5", wx.FD_OPEN)
if dia.ShowModal() == wx.ID_CANCEL:
return
brs = bracketio.read_bracket(dia.GetPath())
if isinstance(brs, str):
w = wx.MessageDialog(self, brs, "Error", wx.ICON_ERROR)
w.ShowModal()
w.Destroy()
return
name = dia.GetFilename().replace(".bp5", "")
pg = ManagementPage(self.nb, name, len(brs), brs)
self.nb.InsertPage(0, pg, name)
def save(self, e):
if not hasattr(self, "brackets"):
errortext = "Make bracket before doing that"
w = wx.MessageDialog(self.parent, errortext,
"Error", wx.ICON_ERROR)
w.ShowModal()
w.Destroy()
return
dia = wx.FileDialog(self, "Save Bracket",
"", self.sname, "bp5000 bracket|*.bp5",
wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
if dia.ShowModal() == wx.ID_CANCEL:
return
bracketio.write_bracket(dia.GetPath(), self.brackets)
def OnCancel(self, events):
"""Do not update data but close dialog."""
self.EndModal(wx.ID_CANCEL)
# end of class TerminalSettingsDialog
def __init__(self, *args, **kwds):
# grab the serial keyword and remove it from the dict
self.serial = kwds['serial']
del kwds['serial']
self.show = SHOW_ALL
if 'show' in kwds:
self.show = kwds.pop('show')
# begin wxGlade: SerialConfigDialog.__init__
kwds["style"] = wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
self.label_2 = wx.StaticText(self, -1, "Port")
self.choice_port = wx.Choice(self, -1, choices=[])
self.label_1 = wx.StaticText(self, -1, "Baudrate")
self.combo_box_baudrate = wx.ComboBox(self, -1, choices=[], style=wx.CB_DROPDOWN)
self.sizer_1_staticbox = wx.StaticBox(self, -1, "Basics")
self.panel_format = wx.Panel(self, -1)
self.label_3 = wx.StaticText(self.panel_format, -1, "Data Bits")
self.choice_databits = wx.Choice(self.panel_format, -1, choices=["choice 1"])
self.label_4 = wx.StaticText(self.panel_format, -1, "Stop Bits")
self.choice_stopbits = wx.Choice(self.panel_format, -1, choices=["choice 1"])
self.label_5 = wx.StaticText(self.panel_format, -1, "Parity")
self.choice_parity = wx.Choice(self.panel_format, -1, choices=["choice 1"])
self.sizer_format_staticbox = wx.StaticBox(self.panel_format, -1, "Data Format")
self.panel_timeout = wx.Panel(self, -1)
self.checkbox_timeout = wx.CheckBox(self.panel_timeout, -1, "Use Timeout")
self.text_ctrl_timeout = wx.TextCtrl(self.panel_timeout, -1, "")
self.label_6 = wx.StaticText(self.panel_timeout, -1, "seconds")
self.sizer_timeout_staticbox = wx.StaticBox(self.panel_timeout, -1, "Timeout")
self.panel_flow = wx.Panel(self, -1)
self.checkbox_rtscts = wx.CheckBox(self.panel_flow, -1, "RTS/CTS")
self.checkbox_xonxoff = wx.CheckBox(self.panel_flow, -1, "Xon/Xoff")
self.sizer_flow_staticbox = wx.StaticBox(self.panel_flow, -1, "Flow Control")
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
# attach the event handlers
self.__attach_events()
def OnCancel(self, events):
self.EndModal(wx.ID_CANCEL)