Python wx.ID_NO Examples

The following are 15 code examples of wx.ID_NO(). 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: objdictedit.py    From CANFestivino with GNU Lesser General Public License v2.1 6 votes vote down vote up
def OnCloseMenu(self, event):
        answer = wx.ID_YES
        result = self.Manager.CloseCurrent()
        if not result:
            dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"),  _("Close File"), wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
            answer = dialog.ShowModal()
            dialog.Destroy()
            if answer == wx.ID_YES:
                self.OnSaveMenu(event)
                if self.Manager.CurrentIsSaved():
                    self.Manager.CloseCurrent()
            elif answer == wx.ID_NO:
                self.Manager.CloseCurrent(True)
        if self.FileOpened.GetPageCount() > self.Manager.GetBufferNumber():
            current = self.FileOpened.GetSelection()
            self.FileOpened.DeletePage(current)
            if self.FileOpened.GetPageCount() > 0:
                self.FileOpened.SetSelection(min(current, self.FileOpened.GetPageCount() - 1))
            self.RefreshBufferState()
            self.RefreshMainMenu()
        

#-------------------------------------------------------------------------------
#                         Import and Export Functions
#------------------------------------------------------------------------------- 
Example #2
Source File: networkedit.py    From CANFestivino with GNU Lesser General Public License v2.1 6 votes vote down vote up
def OnCloseProjectMenu(self, event):
        if self.NodeList:
            if self.NodeList.HasChanged():
                dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"), _("Close Project"), wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
                answer = dialog.ShowModal()
                dialog.Destroy()
                if answer == wx.ID_YES:
                    result = self.NodeList.SaveProject()
                    if result:
                        message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR)
                        message.ShowModal()
                        message.Destroy()
                elif answer == wx.ID_NO:
                    self.NodeList.ForceChanged(False)
            if not self.NodeList.HasChanged():
                self.Manager = None
                self.NodeList = None
                self.RefreshNetworkNodes()
                self.RefreshTitle()
                self.RefreshMainMenu()
        
        
#-------------------------------------------------------------------------------
#                             Refresh Functions
#------------------------------------------------------------------------------- 
Example #3
Source File: xrced.py    From admin4 with Apache License 2.0 6 votes vote down vote up
def AskSave(self):
        if not (self.modified or panel.IsModified()): return True
        flags = wx.ICON_EXCLAMATION | wx.YES_NO | wx.CANCEL | wx.CENTRE
        dlg = wx.MessageDialog( self, 'File is modified. Save before exit?',
                               'Save before too late?', flags )
        say = dlg.ShowModal()
        dlg.Destroy()
        wx.Yield()
        if say == wx.ID_YES:
            self.OnSaveOrSaveAs(wx.CommandEvent(wx.ID_SAVE))
            # If save was successful, modified flag is unset
            if not self.modified: return True
        elif say == wx.ID_NO:
            self.SetModified(False)
            panel.SetModified(False)
            return True
        return False 
Example #4
Source File: Document.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def CheckFileNeedsSave(self):
        """
        Checks if the file was changed and if necessary asks the user if he
        wants to save it. If the user affirms, calls Save/SaveAs also.

        returns: wx.ID_OK     if no save was needed
                 wx.ID_YES    if file was saved
                 wx.ID_NO     if file was not saved
                 wx.ID_CANCEL if user canceled possible save
        """
        if not self.isDirty:
            return wx.ID_OK
        dialog = SaveChangesDialog(self.frame)
        result = dialog.ShowModal()
        dialog.Destroy()
        if result == wx.ID_CANCEL:
            return wx.ID_CANCEL
        elif result == wx.ID_YES:
            return self.Save()
        else:
            return wx.ID_NO 
Example #5
Source File: Document.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def Open(self, filePath=None):
        self.ShowFrame()
        if filePath is not None:
            res = wx.MessageBox(
                "Do you really want to load the tree file:\n%s" % filePath,
                eg.APP_NAME,
                wx.YES_NO | wx.CENTRE | wx.ICON_QUESTION,
                parent = self.frame,
            )
            if res == wx.ID_NO:
                return wx.ID_CANCEL
        if self.CheckFileNeedsSave() == wx.ID_CANCEL:
            return wx.ID_CANCEL
        if filePath is None:
            filePath = self.AskFile(wx.OPEN)
        if filePath is None:
            return wx.ID_CANCEL
        self.StartSession(filePath) 
Example #6
Source File: guiminer.py    From poclbm with GNU General Public License v3.0 5 votes vote down vote up
def on_page_closing(self, event):
        """Handle a tab closing event.

        If they are closing a special panel, we have to shut it down.
        If the tab has a miner running in it, we have to stop the miner
        before letting the tab be removed.
        """
        p = self.nb.GetPage(event.GetSelection())

        if p == self.console_panel:
            self.console_panel.on_close()
            self.console_panel = None
            event.Skip()
            return
        if p == self.summary_panel:
            self.summary_panel.on_close()
            self.summary_panel = None
            event.Skip()
            return

        if p.is_mining:
            result = self.message(
                _("Closing this miner will stop it. Continue?"),
                _("Close miner"),
                wx.YES_NO | wx.NO_DEFAULT | wx.ICON_INFORMATION)
            if result == wx.ID_NO:
                event.Veto()
                return
        p.on_close()
        event.Skip() # OK to close the tab now 
Example #7
Source File: guiminer.py    From poclbm with GNU General Public License v3.0 5 votes vote down vote up
def create_solo_password(self, event):
        """Prompt the user for login credentials to the bitcoin client.

        These are required to connect to the client over JSON-RPC and are
        stored in 'bitcoin.conf'.
        """
        if sys.platform == 'win32':
            filename = os.path.join(os.getenv("APPDATA"), "Bitcoin", "bitcoin.conf")
        else: # Assume Linux for now TODO test
            filename = os.path.join(os.getenv('HOME'), ".bitcoin")
        if os.path.exists(filename):
            result = self.message(
                _("%s already exists. Overwrite?") % filename,
                _("bitcoin.conf already exists."),
                wx.YES_NO | wx.NO_DEFAULT | wx.ICON_INFORMATION)
            if result == wx.ID_NO:
                return

        dialog = SoloPasswordRequest(self, _('Enter password'))
        result = dialog.ShowModal()
        dialog.Destroy()
        if result == wx.ID_CANCEL:
            return

        with open(filename, "w") as f:
            f.write('\nrpcuser=%s\nrpcpassword=%s\nrpcallowip=*' % dialog.get_value())
            f.close()

        self.message(_("Wrote bitcoin config ok."), _("Success"), wx.OK) 
Example #8
Source File: objdictedit.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def OnCloseFrame(self, event):
        self.Closing = True
        if not self.ModeSolo:
            if getattr(self, "_onclose", None) != None:
                self._onclose()
            event.Skip()
        elif self.Manager.OneFileHasChanged():
            dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"),  _("Close Application"), wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION)
            answer = dialog.ShowModal()
            dialog.Destroy()
            if answer == wx.ID_YES:
                for i in xrange(self.Manager.GetBufferNumber()):
                    if self.Manager.CurrentIsSaved():
                        self.Manager.CloseCurrent()
                    else:
                        self.Save()
                        self.Manager.CloseCurrent(True)
                event.Skip()
            elif answer == wx.ID_NO:
                event.Skip()
            else:
                event.Veto()
        else:
            event.Skip()

#-------------------------------------------------------------------------------
#                             Refresh Functions
#------------------------------------------------------------------------------- 
Example #9
Source File: App.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def OnQueryEndSessionVista(self, event):
        if self.shouldVeto:
            event.Veto()
            return
        if not self.firstQuery:
            return
        if eg.document.isDirty:
            self.firstQuery = False
            self.shouldVeto = True
            event.Veto(True)
            ShutdownBlockReasonCreate(self.hwnd, "Unsaved data")
            res = eg.document.CheckFileNeedsSave()
            if res == wx.ID_YES:
                # file was saved, reset everything
                event.Veto(False)
                self.Reset()
                return
            if res == wx.ID_NO:
                # file was not saved
                # if called before shutdownUI, we get a OnEndSession
                self.shouldVeto = False
                ShutdownBlockReasonDestroy(self.hwnd)
                wx.CallAfter(self.OnEndSession, None)
                return
            if res == wx.ID_CANCEL:
                self.shouldVeto = True
                wx.CallAfter(self.Reset)
                return 
Example #10
Source File: MessageDialog.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def OnNoButton(self, event):
        self.EndModal(wx.ID_NO)
        event.Skip() 
Example #11
Source File: Document.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, parent=None):
        text = eg.text.MainFrame.SaveChanges
        wx.Dialog.__init__(self, parent, title=eg.APP_NAME)
        bmp = wx.ArtProvider.GetBitmap(
            wx.ART_WARNING, wx.ART_CMN_DIALOG, (32, 32)
        )
        staticBitmap = wx.StaticBitmap(self, -1, bmp)

        messageCtrl = wx.StaticText(
            self, -1, eg.text.MainFrame.SaveChanges.mesg
        )
        messageCtrl.Wrap(400)
        saveButton = wx.Button(self, wx.ID_YES, text.saveButton)
        saveButton.Bind(wx.EVT_BUTTON, self.OnButton)
        saveButton.SetDefault()
        saveButton.SetFocus()
        dontSaveButton = wx.Button(self, wx.ID_NO, text.dontSaveButton)
        dontSaveButton.Bind(wx.EVT_BUTTON, self.OnButton)
        cancelButton = wx.Button(self, wx.ID_CANCEL, eg.text.General.cancel)
        cancelButton.Bind(wx.EVT_BUTTON, self.OnButton)
        self.SetDefaultItem(saveButton)

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(staticBitmap, 0, wx.ALL, 12)
        sizer.Add(messageCtrl, 0, wx.ALIGN_CENTER | wx.LEFT | wx.TOP | wx.RIGHT, 6)
        buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
        buttonSizer.Add(saveButton, 0, wx.LEFT | wx.RIGHT, 3)
        buttonSizer.Add(dontSaveButton, 0, wx.LEFT | wx.RIGHT, 3)
        buttonSizer.Add(cancelButton, 0, wx.LEFT | wx.RIGHT, 3)
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(sizer)
        mainSizer.Add(buttonSizer, 0, wx.ALIGN_RIGHT | wx.ALL, 12)
        self.SetSizerAndFit(mainSizer)
        if parent:
            self.CenterOnParent()
        else:
            self.Center() 
Example #12
Source File: IDMergeDialog.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent, title, question, optiontext, button_texts):
        wx.Dialog.__init__(self, parent, title=title)

        main_sizer = wx.BoxSizer(wx.VERTICAL)

        message = wx.StaticText(self, label=question)
        main_sizer.AddWindow(message, border=20,
                             flag=wx.ALIGN_CENTER_HORIZONTAL | wx.TOP | wx.LEFT | wx.RIGHT)

        self.check = wx.CheckBox(self, label=optiontext)
        main_sizer.AddWindow(self.check, border=20,
                             flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_CENTER_HORIZONTAL)

        buttons_sizer = wx.BoxSizer(wx.HORIZONTAL)
        for label, wxID in zip(button_texts, [wx.ID_YES, wx.ID_NO, wx.ID_CANCEL]):
            Button = wx.Button(self, label=label)

            def OnButtonFactory(_wxID):
                return lambda event: self.EndModal(_wxID)

            self.Bind(wx.EVT_BUTTON, OnButtonFactory(wxID), Button)
            buttons_sizer.AddWindow(Button)

        main_sizer.AddSizer(buttons_sizer, border=20,
                            flag=wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALIGN_RIGHT)

        self.SetSizer(main_sizer)
        self.Fit()

        self.Bind(wx.EVT_CHAR_HOOK, self.OnEscapeKey) 
Example #13
Source File: relay_board_gui.py    From R421A08-rs485-8ch-relay-board with MIT License 5 votes vote down vote up
def OnNoClick(self, event):
        self.EndModal(wx.ID_NO)


# --------------------------------------------------------------------------------------------------
# Taskbar icon
# -------------------------------------------------------------------------------------------------- 
Example #14
Source File: guiminer.py    From poclbm with GNU General Public License v3.0 4 votes vote down vote up
def load_config(self, event=None):
        """Load JSON profile info from the config file."""
        self.parse_config()

        config_data = self.config_data
        executable = config_data.get('bitcoin_executable', None)
        if executable is not None:
            self.bitcoin_executable = executable
            
        blockchain_directory = config_data.get('blockchain_directory', None)
        if blockchain_directory is not None:
            self.blockchain_directory = blockchain_directory

        # Shut down any existing miners before they get clobbered
        if(any(p.is_mining for p in self.profile_panels)):
            result = self.message(
                _("Loading profiles will stop any currently running miners. Continue?"),
                _("Load profile"), wx.YES_NO | wx.NO_DEFAULT | wx.ICON_INFORMATION)
            if result == wx.ID_NO:
                return
        for p in reversed(self.profile_panels):
            p.on_close()
            self.nb.DeletePage(self.nb.GetPageIndex(p))

        # If present, summary should be the leftmost tab on startup.
        if config_data.get('show_summary', False):
            self.show_summary()

        profile_data = config_data.get('profiles', [])
        for d in profile_data:
            self.add_profile(d)

        if not any(profile_data):
            self.add_profile() # Create a default one using defaults.ini

        if config_data.get('show_console', False):
            self.show_console()
            
        window_position = config_data.get('window_position')
        if window_position:
            self.SetRect(window_position)

        for p in self.profile_panels:
            if p.autostart:
                p.start_mining() 
Example #15
Source File: elecsus_gui.py    From ElecSus with Apache License 2.0 4 votes vote down vote up
def OnFitButton(self,event):
		""" Call elecsus to fit data. Some sanity checking takes place first. """

		## check for things that will prevent fitting from working, e.g. no data loaded - halt fitting if found
		if len(self.y_fit_array) == 0:
			#warn about no data present
			dlg = wx.MessageDialog(self, "No experimental data has been loaded, cannot proceed with fitting...", "No no no", wx.OK|wx.ICON_EXCLAMATION)
			dlg.ShowModal()
			return
		
		self.fit_bools = [checkbox.IsChecked() for checkbox in self.FitOptions.main_paramlist_bools]
		self.fit_bools += [checkbox.IsChecked() for checkbox in self.FitOptions.magnet_paramlist_bools]
		self.fit_bools += [self.FitOptions.fit_polarisation_checkbox.IsChecked()]
		if self.fit_bools.count(True) == 0:
			dlg = wx.MessageDialog(self, "No fit parameters are floating, cannot proceed with fitting...", "No no no", wx.OK|wx.ICON_EXCLAMATION)
			dlg.ShowModal()
			return
		
		## check for non-optimal conditions and warn user
		if self.warnings:
			## if number of booleans > 3 and ML fitting selected, warn about fitting methods
			if self.fit_bools.count(True) > 3 and self.fit_algorithm=='Marquardt-Levenberg':
				dlg = wx.MessageDialog(self, "The number of fitted parameters is large and the Marquardt-Levenberg algorithm is selected. There is a high probability that the fit will return a local minimum, rather than the global minimum. \n\nTo find the global minimum more reliably, consider changing to either Random-Restart or Simulated Annealing algorithms.\n\n Continue with fitting anyway?", "Warning", wx.YES|wx.NO|wx.ICON_WARNING)
				
				if dlg.ShowModal() == wx.ID_NO:
					return
				
			## if large number of data points
			if len(self.x_fit_array) > 5000:
				dlg = wx.MessageDialog(self, "The number of data points is quite high and fitting may be very slow, especially with Random-Restart or Simulated Annealing methods. \n\nConsider reducing the number of data points by binning data (Menu Fit --> Data Processing... --> Bin Data).\n\n Continue with fitting anyway?", "Warning", wx.YES|wx.NO|wx.ICON_WARNING)

				if dlg.ShowModal() == wx.ID_NO:
					return
		
		# Bounds on fit parameters must be enabled for differential evolution
		if self.fit_algorithm=='Differential Evolution':
			# status of checkboxes for floated params must equal checkboxes ticked for bounds
			ticked_bools = [i for i, box in enumerate(self.FitOptions.main_paramlist_bools+self.FitOptions.magnet_paramlist_bools) if box.IsChecked()]
			print(ticked_bools)
			ticked_bounds = [i for i, box in enumerate(self.FitOptions.main_paramlist_usebounds+self.FitOptions.magnet_paramlist_usebounds) if box.IsChecked()]
			print(ticked_bounds)
			
			if ticked_bools != ticked_bounds:
				dlg = wx.MessageDialog(self,"Bounds on fit parameters must be specified to use Differential Evolution algorithm","Bounds not specified",style=wx.OK|wx.CENTRE|wx.ICON_ERROR)
				dlg.ShowModal()
				return
						
		# If all conditions satisfied, start the fitting process
		self.Call_ElecSus('Fit')