Python wx.SingleChoiceDialog() Examples

The following are 15 code examples of wx.SingleChoiceDialog(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: networkeditortemplate.py    From CANFestivino with GNU Lesser General Public License v2.1 6 votes vote down vote up
def OnRemoveSlaveMenu(self, event):
        slavenames = self.NodeList.GetSlaveNames()
        slaveids = self.NodeList.GetSlaveIDs()
        dialog = wx.SingleChoiceDialog(self.Frame, _("Choose a slave to remove"), _("Remove slave"), slavenames)
        if dialog.ShowModal() == wx.ID_OK:
            choice = dialog.GetSelection()
            result = self.NodeList.RemoveSlaveNode(slaveids[choice])
            if not result:
                slaveids.pop(choice)
                current = self.NetworkNodes.GetSelection()
                self.NetworkNodes.DeletePage(choice + 1)
                if self.NetworkNodes.GetPageCount() > 0:
                    new_selection = min(current, self.NetworkNodes.GetPageCount() - 1)
                    self.NetworkNodes.SetSelection(new_selection)
                    if new_selection > 0:
                        self.NodeList.SetCurrentSelected(slaveids[new_selection - 1])
                self.RefreshBufferState()
            else:
                self.ShowErrorMessage(result)
        dialog.Destroy() 
Example #2
Source File: Zone.py    From admin4 with Apache License 2.0 6 votes vote down vote up
def OnExecute(parentWin, page):
    rdtype=None
    rtypes=[]
    for type in prioTypes:
      rtypes.append("%s - %s" % (type, DnsSupportedTypes[type]))
    for type in sorted(DnsSupportedTypes.keys()):
      if type not in prioTypes and type not in individualTypes:
        rtypes.append("%s - %s" % (type, DnsSupportedTypes[type]))
      
    dlg=wx.SingleChoiceDialog(parentWin, xlt("record type"), "Select record type", rtypes)
    if dlg.ShowModal() == wx.ID_OK:
      rdtype=rdatatype.from_text(dlg.GetStringSelection().split(' ')[0])
      dlg=page.EditDialog(rdtype)(parentWin, page.lastNode, "", rdtype)
      dlg.page=page
      if dlg.GoModal():
        page.Display(None, False) 
Example #3
Source File: LanguageEditor.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def OnCmdOpen(self, dummyEvent):
        if self.CheckNeedsSave():
            return
        dialog = wx.SingleChoiceDialog(
            self,
            'Choose a language to edit',
            'Choose a language',
            self.langNames,
            wx.CHOICEDLG_STYLE
        )
        try:
            x = self.langKeys.index(Config.language)
        except ValueError:
            x = 0
        dialog.SetSelection(x)
        if dialog.ShowModal() == wx.ID_OK:
            self.LoadLanguage(self.langKeys[dialog.GetSelection()])
        dialog.Destroy() 
Example #4
Source File: DeviceManager.py    From meerk40t with MIT License 6 votes vote down vote up
def on_button_new(self, event):  # wxGlade: DeviceManager.<event_handler>
        names = [name for name in self.device.registered['device']]
        dlg = wx.SingleChoiceDialog(None, _('What type of device is being added?'), _('Device Type'), names)
        dlg.SetSelection(0)
        if dlg.ShowModal() == wx.ID_OK:
            device_type = dlg.GetSelection()
            device_type = names[device_type]
        else:
            dlg.Destroy()
            return
        dlg.Destroy()
        device_uid = 0
        while device_uid <= 100:
            device_uid += 1
            device_match = self.device.read_persistent(str, 'device_name', default='', uid=device_uid)
            if device_match == '':
                break
        self.device.write_persistent('device_name', device_type, uid=device_uid)
        self.device.write_persistent('autoboot', True, uid=device_uid)
        devices = [d for d in self.device.list_devices.split(';') if d != '']
        devices.append(str(device_uid))
        self.device.list_devices = ';'.join(devices)
        self.device.write_persistent('list_devices', self.device.list_devices)
        self.refresh_device_list() 
Example #5
Source File: Viewer.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def AddNewJump(self, bbox, wire=None):
        choices = []
        for block in self.Blocks.itervalues():
            if isinstance(block, SFC_Step):
                choices.append(block.GetName())
        dialog = wx.SingleChoiceDialog(self.ParentWindow,
                                       _("Add a new jump"),
                                       _("Please choose a target"),
                                       choices,
                                       wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL)
        if dialog.ShowModal() == wx.ID_OK:
            id = self.GetNewId()
            jump = SFC_Jump(self, dialog.GetStringSelection(), id)
            self.Controler.AddEditedElementJump(self.TagName, id)
            self.AddNewElement(jump, bbox, wire)
        dialog.Destroy() 
Example #6
Source File: objdictedit.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def Display_Exception_Dialog(e_type,e_value,e_tb):
    trcbck_lst = []
    for i,line in enumerate(traceback.extract_tb(e_tb)):
        trcbck = " " + str(i+1) + _(". ")
        if line[0].find(os.getcwd()) == -1:
            trcbck += _("file : ") + str(line[0]) + _(",   ")
        else:
            trcbck += _("file : ") + str(line[0][len(os.getcwd()):]) + _(",   ")
        trcbck += _("line : ") + str(line[1]) + _(",   ") + _("function : ") + str(line[2])
        trcbck_lst.append(trcbck)
        
    # Allow clicking....
    cap = wx.Window_GetCapture()
    if cap:
        cap.ReleaseMouse()

    dlg = wx.SingleChoiceDialog(None, 
        _("""
An error happens.

Click on OK for saving an error report.

Please be kind enough to send this file to:
edouard.tisserant@gmail.com


Error:
""") +
        str(e_type) + _(" : ") + str(e_value), 
        _("Error"),
        trcbck_lst)
    try:
        res = (dlg.ShowModal() == wx.ID_OK)
    finally:
        dlg.Destroy()

    return res 
Example #7
Source File: networkedit.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def Display_Exception_Dialog(e_type,e_value,e_tb):
    trcbck_lst = []
    for i,line in enumerate(traceback.extract_tb(e_tb)):
        trcbck = " " + str(i+1) + _(". ")
        if line[0].find(os.getcwd()) == -1:
            trcbck += _("file : ") + str(line[0]) + _(",   ")
        else:
            trcbck += _("file : ") + str(line[0][len(os.getcwd()):]) + _(",   ")
        trcbck += _("line : ") + str(line[1]) + _(",   ") + _("function : ") + str(line[2])
        trcbck_lst.append(trcbck)
        
    # Allow clicking....
    cap = wx.Window_GetCapture()
    if cap:
        cap.ReleaseMouse()

    dlg = wx.SingleChoiceDialog(None, 
        _("""
An error happens.

Click on OK for saving an error report.

Please be kind enough to send this file to:
edouard.tisserant@gmail.com


Error:
""") +
        str(e_type) + _(" : ") + str(e_value), 
        _("Error"),
        trcbck_lst)
    try:
        res = (dlg.ShowModal() == wx.ID_OK)
    finally:
        dlg.Destroy()

    return res 
Example #8
Source File: edit_sizers.py    From wxGlade with MIT License 5 votes vote down vote up
def _ask_count(self, insert=True):
        # helper for next method (insertion/adding of multiple slots)
        choices = [str(n) for n in range(1,11)]
        if insert:
            dlg = wx.SingleChoiceDialog(None, "Select number of slots to be inserted", "Insert Slots", choices)
        else:
            dlg = wx.SingleChoiceDialog(None, "Select number of slots to be added", "Add Slots", choices)
        ret = 0  if dlg.ShowModal()==wx.ID_CANCEL  else   int(dlg.GetStringSelection())
        dlg.Destroy()
        return ret 
Example #9
Source File: flow.py    From iqiyi-parser with MIT License 5 votes vote down vote up
def handler_audio(sel_res):
            audio_info = sel_res.getAllAudioInfo()
            if audio_info:
                dlg = wx.SingleChoiceDialog(gui.frame_parse, u'Pick the AUDIO you prefer', u'Audio Choice', audio_info)
                if dlg.ShowModal() == wx.ID_OK:
                    index = audio_info.index(dlg.GetStringSelection())
                    sel_res.setSelAudio(index)
                    dlg.Destroy()
                else:
                    dlg.Destroy()
                    return False

            return True 
Example #10
Source File: Viewer.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def EditJumpContent(self, jump):
        choices = []
        for block in self.Blocks.itervalues():
            if isinstance(block, SFC_Step):
                choices.append(block.GetName())
        dialog = wx.SingleChoiceDialog(self.ParentWindow,
                                       _("Edit jump target"),
                                       _("Please choose a target"),
                                       choices,
                                       wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL)
        try:
            indx = choices.index(jump.GetTarget())
            dialog.SetSelection(indx)
        except ValueError:
            pass

        if dialog.ShowModal() == wx.ID_OK:
            value = dialog.GetStringSelection()
            rect = jump.GetRedrawRect(1, 1)
            jump.SetTarget(value)
            rect = rect.Union(jump.GetRedrawRect())
            self.RefreshJumpModel(jump)
            self.RefreshBuffer()
            self.RefreshScrollBars()
            self.RefreshVisibleElements()
            jump.Refresh(rect)
        dialog.Destroy() 
Example #11
Source File: SFCViewer.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def AddJump(self):
        if isinstance(self.SelectedElement, SFC_Step) and not self.SelectedElement.Output:
            choices = []
            for block in self.Blocks:
                if isinstance(block, SFC_Step):
                    choices.append(block.GetName())
            dialog = wx.SingleChoiceDialog(self.ParentWindow,
                                           _("Add a new jump"),
                                           _("Please choose a target"),
                                           choices,
                                           wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL)
            if dialog.ShowModal() == wx.ID_OK:
                value = dialog.GetStringSelection()
                self.SelectedElement.AddOutput()
                self.RefreshStepModel(self.SelectedElement)
                step_connectors = self.SelectedElement.GetConnectors()
                transition = self.CreateTransition(step_connectors["output"])
                transition_connectors = transition.GetConnectors()
                id = self.GetNewId()
                jump = SFC_Jump(self, value, id)
                pos = transition_connectors["output"].GetPosition(False)
                jump.SetPosition(pos.x, pos.y + SFC_WIRE_MIN_SIZE)
                self.AddBlock(jump)
                self.Controler.AddEditedElementJump(self.TagName, id)
                jump_connector = jump.GetConnector()
                wire = self.ConnectConnectors(jump_connector, transition_connectors["output"])
                transition.RefreshOutputPosition()
                wire.SetPoints([wx.Point(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wx.Point(pos.x, pos.y)])
                self.RefreshJumpModel(jump)
                self.RefreshBuffer()
                self.RefreshScrollBars()
                self.Refresh(False)
            dialog.Destroy() 
Example #12
Source File: ExceptionHandler.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def Display_Exception_Dialog(e_type, e_value, e_tb, bug_report_path, exit):
    trcbck_lst = []
    for i, line in enumerate(traceback.extract_tb(e_tb)):
        trcbck = " " + str(i+1) + ". "
        if line[0].find(os.getcwd()) == -1:
            trcbck += "file : " + str(line[0]) + ",   "
        else:
            trcbck += "file : " + str(line[0][len(os.getcwd()):]) + ",   "
        trcbck += "line : " + str(line[1]) + ",   " + "function : " + str(line[2])
        trcbck_lst.append(trcbck)

    # Allow clicking....
    cap = wx.Window_GetCapture()
    if cap:
        cap.ReleaseMouse()

    dlg = wx.SingleChoiceDialog(
        None,
        _("""
An unhandled exception (bug) occured. Bug report saved at :
(%s)

Please be kind enough to send this file to:
beremiz-devel@lists.sourceforge.net

You should now restart program.

Traceback:
""") % bug_report_path +
        repr(e_type) + " : " + repr(e_value),
        _("Error"),
        trcbck_lst)
    try:
        res = (dlg.ShowModal() == wx.ID_OK)
    finally:
        dlg.Destroy()

    if exit:
        sys.exit()  # wx.Exit()

    return res 
Example #13
Source File: spellcheckdlg.py    From trelby with GNU General Public License v2.0 4 votes vote down vote up
def OnSuggest(self, event):
        if not self.sc.word:
            return

        isAllCaps = self.sc.word == util.upper(self.sc.word)
        isCapitalized = self.sc.word[:1] == util.upper(self.sc.word[:1])

        word = util.lower(self.sc.word)

        wl = len(word)
        wstart = word[:2]
        d = 500
        fifo = util.FIFO(5)
        wx.BeginBusyCursor()

        for w in spellcheck.prefixDict[util.getWordPrefix(word)]:
            if w.startswith(wstart):
                d = self.tryWord(word, wl, w, d, fifo)

        for w in self.gScDict.words.iterkeys():
            if w.startswith(wstart):
                d = self.tryWord(word, wl, w, d, fifo)

        for w in self.ctrl.sp.scDict.words.iterkeys():
            if w.startswith(wstart):
                d = self.tryWord(word, wl, w, d, fifo)

        items = fifo.get()

        wx.EndBusyCursor()

        if len(items) == 0:
            wx.MessageBox("No similar words found.", "Results",
                          wx.OK, self)

            return

        dlg = wx.SingleChoiceDialog(
            self, "Most similar words:", "Suggestions", items)

        if dlg.ShowModal() == wx.ID_OK:
            sel = dlg.GetSelection()

            newWord = items[sel]

            if isAllCaps:
                newWord = util.upper(newWord)
            elif isCapitalized:
                newWord = util.capitalize(newWord)

            self.replaceEntry.SetValue(newWord)

        dlg.Destroy()

    # if w2 is closer to w1 in Levenshtein distance than d, add it to
    # fifo. return min(d, new_distance). 
Example #14
Source File: elecsus_gui.py    From ElecSus with Apache License 2.0 4 votes vote down vote up
def OnFileOpen(self,event):
		""" 
		Open a csv data file and plot the data. Detuning is assumed to be in GHz. 
		Vertical units are assumed to be the same as in the theory curves 
		"""
		self.dirname= ''
		dlg_choice = wx.SingleChoiceDialog(self,"Choose type of data to be imported","Data import",choices=OutputTypes)
		
		# wait for OK to be clicked
		if dlg_choice.ShowModal() == wx.ID_OK:
			choice = dlg_choice.GetSelection()
			#print 'Choice:', choice
			self.expt_type = OutputTypes[choice]
			# use the choice index to select which axes the data appears on	- may be different 
			# if axes order is rearranged later?
			self.choice_index = OutputTypes_index[choice]
			#print self.choice_index
			
			dlg_choice.Destroy()
		
			dlg_open = wx.FileDialog(self,"Choose 2-column csv file (Detuning, Transmission)",
									self.dirname,"","*.csv",wx.FD_OPEN)
			
			# if OK button clicked, open and read file
			if dlg_open.ShowModal() == wx.ID_OK:
				#set experimental display on, and update menus
				self.display_expt_curves[self.choice_index] = True
				#self.showEplotsSubMenu.GetMenuItems()[self.choice_index].Check(True)
			
				self.filename = dlg_open.GetFilename()
				self.dirname = dlg_open.GetDirectory()
				#call read
				self.x_expt_arrays[self.choice_index],self.y_expt_arrays[self.choice_index] = np.loadtxt(os.path.join(self.dirname,self.filename),delimiter=',',usecols=[0,1]).T
				
				#overwrite fit_array data - i.e. last data to be loaded
				self.x_fit_array = self.x_expt_arrays[self.choice_index]
				self.y_fit_array = self.y_expt_arrays[self.choice_index]
				
				# implicit that the fit type is the same as last data imported
				self.fit_datatype = self.expt_type
				
				## create main plot				
				self.OnCreateAxes(self.figs[0],self.canvases[0],clear_current=True)
				
				
			dlg_open.Destroy() 
Example #15
Source File: LocationCellEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 4 votes vote down vote up
def OnBrowseButtonClick(self, event):
        # pop up the location browser dialog
        dialog = BrowseLocationsDialog(self, self.VarType, self.Controller)
        if dialog.ShowModal() == wx.ID_OK:
            infos = dialog.GetValues()
        else:
            infos = None
        dialog.Destroy()

        if infos is not None:
            location = infos["location"]
            # set the location
            if not infos["location"].startswith("%"):
                dialog = wx.SingleChoiceDialog(
                    self,
                    _("Select a variable class:"),
                    _("Variable class"),
                    [_("Input"), _("Output"), _("Memory")],
                    wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL)
                if dialog.ShowModal() == wx.ID_OK:
                    selected = dialog.GetSelection()
                else:
                    selected = None
                dialog.Destroy()
                if selected is None:
                    self.Location.SetFocus()
                    return
                if selected == 0:
                    location = "%I" + location
                elif selected == 1:
                    location = "%Q" + location
                else:
                    location = "%M" + location

            self.Location.SetValue(location)
            self.VariableName = infos["var_name"]
            self.VarType = infos["IEC_type"]

            # when user selected something, end editing immediately
            # so that changes over multiple colums appear
            wx.CallAfter(self.Parent.Parent.CloseEditControl)

        self.Location.SetFocus()