Python wx.ICON_QUESTION Examples

The following are 30 code examples of wx.ICON_QUESTION(). 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: gui.py    From IkaLog with Apache License 2.0 8 votes vote down vote up
def on_options_load_default(self, event):
        '''Resets the changes to the default, but not save them.'''
        r = wx.MessageDialog(
            None,
            _('IkaLog preferences will be reset to default. Continue?') + '\n' +
            _('The change will be updated when the apply button is pressed.'),
            _('Confirm'),
            wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION
        ).ShowModal()

        if r != wx.ID_YES:
            return

        self.engine.call_plugins('on_config_reset', debug=True)

    # 現在の設定値をYAMLファイルからインポート
    # 
Example #2
Source File: filmow_to_letterboxd.py    From filmow_to_letterboxd with MIT License 6 votes vote down vote up
def OnClose(self, event):
    if self.is_running:
      confirm_exit = wx.MessageDialog(
        self,
        'Tem certeza que quer parar o programa?',
        'Sair',
        wx.YES_NO | wx.ICON_QUESTION
      )

      if confirm_exit.ShowModal() == wx.ID_YES:
        self.Destroy()
        wx.Window.Destroy(self)
      else:
        confirm_exit.Destroy()
    else:
      event.Skip() 
Example #3
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 #4
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 #5
Source File: mainframe.py    From youtube-dl-gui with The Unlicense 6 votes vote down vote up
def _on_close(self, event):
        """Event handler for the wx.EVT_CLOSE event.

        This method is used when the user tries to close the program
        to save the options and make sure that the download & update
        processes are not running.

        """
        if self.opt_manager.options["confirm_exit"]:
            dlg = wx.MessageDialog(self, _("Are you sure you want to exit?"), _("Exit"), wx.YES_NO | wx.ICON_QUESTION)

            result = dlg.ShowModal() == wx.ID_YES
            dlg.Destroy()
        else:
            result = True

        if result:
            self.close() 
Example #6
Source File: app.py    From thotkeeper with BSD 2-Clause "Simplified" License 6 votes vote down vote up
def _RefuseUnsavedModifications(self, refuse_modified_options=False):
        """If there exist unsaved entry modifications, inform the user
        and return True.  Otherwise, return False."""
        if self.entry_modified:
            wx.MessageBox(('Entry has been modified.  You must either '
                           'save or revert it.'),
                          'Modified Entry',
                          wx.OK | wx.ICON_INFORMATION,
                          self.frame)
            return True
        elif refuse_modified_options and self.diary_modified:
            if wx.OK == wx.MessageBox(('Diary has been modified.  Click OK '
                                       'to continue and lose the changes.'),
                                      'Modified Diary',
                                      wx.OK | wx.CANCEL | wx.ICON_QUESTION,
                                      self.frame):
                return False
            return True
        return False 
Example #7
Source File: RTyyyy_main.py    From NXP-MCUBootUtility with Apache License 2.0 6 votes vote down vote up
def _wantToReuseAvailableCert( self, directReuseCert ):
        certAnswer = wx.NO
        if self.isCertificateGenerated(self.secureBootType):
            if not directReuseCert:
                msgText = ((uilang.kMsgLanguageContentDict['certGenInfo_reuseOldCert'][self.languageIndex]))
                certAnswer = wx.MessageBox(msgText, "Certificate Question", wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION)
                if certAnswer == wx.CANCEL:
                    return None
                elif certAnswer == wx.NO:
                    msgText = ((uilang.kMsgLanguageContentDict['certGenInfo_haveNewCert'][self.languageIndex]))
                    certAnswer = wx.MessageBox(msgText, "Certificate Question", wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION)
                    if certAnswer == wx.CANCEL:
                        return None
                    elif certAnswer == wx.YES:
                        certAnswer = wx.NO
                    else:
                        certAnswer = wx.YES
            else:
                certAnswer = wx.YES
        return (certAnswer == wx.YES) 
Example #8
Source File: gui.py    From superpaper with MIT License 6 votes vote down vote up
def onDeleteProfile(self, event):
        """Deletes the currently selected profile after getting confirmation."""
        profname = self.tc_name.GetLineText(0)
        fname = os.path.join(PROFILES_PATH, profname + ".profile")
        file_exists = os.path.isfile(fname)
        if not file_exists:
            msg = "Selected profile is not saved."
            show_message_dialog(msg, "Error")
            return
        # Open confirmation dialog
        dlg = wx.MessageDialog(None,
                               "Do you want to delete profile: {}?".format(profname),
                               'Confirm Delete',
                               wx.YES_NO | wx.ICON_QUESTION)
        result = dlg.ShowModal()
        if result == wx.ID_YES and file_exists:
            os.remove(fname)
            self.update_choiceprofile()
            self.onCreateNewProfile(None)
        else:
            pass 
Example #9
Source File: ConfigEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def OnDeleteButton(self, event):
        filepath = self.GetSelectedFilePath()
        if os.path.isfile(filepath):
            _folder, filename = os.path.split(filepath)

            dialog = wx.MessageDialog(self.ParentWindow,
                                      _("Do you really want to delete the file '%s'?") % filename,
                                      _("Delete File"),
                                      wx.YES_NO | wx.ICON_QUESTION)
            remove = dialog.ShowModal() == wx.ID_YES
            dialog.Destroy()

            if remove:
                os.remove(filepath)
                self.ModuleLibrary.LoadModules()
                wx.CallAfter(self.RefreshView)
        event.Skip() 
Example #10
Source File: FileManagementPanel.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def OnDeleteButton(self, event):
        filepath = self.ManagedDir.GetPath()
        if os.path.isfile(filepath):
            _folder, filename = os.path.split(filepath)

            dialog = wx.MessageDialog(self,
                                      _("Do you really want to delete the file '%s'?") % filename,
                                      _("Delete File"),
                                      wx.YES_NO | wx.ICON_QUESTION)
            remove = dialog.ShowModal() == wx.ID_YES
            dialog.Destroy()

            if remove:
                os.remove(filepath)
                self.ManagedDir.RefreshTree()
        event.Skip() 
Example #11
Source File: ProjectController.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def CheckProjectPathPerm(self, dosave=True):
        if CheckPathPerm(self.ProjectPath):
            return True
        if self.AppFrame is not None:
            dialog = wx.MessageDialog(
                self.AppFrame,
                _('You must have permission to work on the project\nWork on a project copy ?'),
                _('Error'),
                wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
            answer = dialog.ShowModal()
            dialog.Destroy()
            if answer == wx.ID_YES:
                if self.SaveProjectAs():
                    self.AppFrame.RefreshTitle()
                    self.AppFrame.RefreshFileMenu()
                    self.AppFrame.RefreshPageTitles()
                    return True
        return False 
Example #12
Source File: IDEFrame.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
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
    # ------------------------------------------------------------------------------- 
Example #13
Source File: wxglade_hmi.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def _editWXGLADE(self):
        wxg_filename = self._getWXGLADEpath()
        open_wxglade = True
        if not self.GetCTRoot().CheckProjectPathPerm():
            dialog = wx.MessageDialog(self.GetCTRoot().AppFrame,
                                      _("You don't have write permissions.\nOpen wxGlade anyway ?"),
                                      _("Open wxGlade"),
                                      wx.YES_NO | wx.ICON_QUESTION)
            open_wxglade = dialog.ShowModal() == wx.ID_YES
            dialog.Destroy()
        if open_wxglade:
            if not os.path.exists(wxg_filename):
                hmi_name = self.BaseParams.getName()
                open(wxg_filename, "w").write("""<?xml version="1.0"?>
    <application path="" name="" class="" option="0" language="python" top_window="%(name)s" encoding="UTF-8" use_gettext="0" overwrite="0" use_new_namespace="1" for_version="2.8" is_template="0">
        <object class="%(class)s" name="%(name)s" base="EditFrame">
            <style>wxDEFAULT_FRAME_STYLE</style>
            <title>frame_1</title>
            <object class="wxBoxSizer" name="sizer_1" base="EditBoxSizer">
                <orient>wxVERTICAL</orient>
            <object class="sizerslot" />
        </object>
        </object>
    </application>
    """ % {"name": hmi_name, "class": "Class_%s" % hmi_name})
            if wx.Platform == '__WXMSW__':
                wxg_filename = "\"%s\"" % wxg_filename
            self.launch_wxglade([wxg_filename]) 
Example #14
Source File: OptionsDialog.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def ShowLanguageWarning(self):
        dlg = wx.MessageDialog(
            eg.document.frame,
            Text.confirmRestart,
            "",
            wx.YES_NO | wx.ICON_QUESTION
        )
        res = dlg.ShowModal()
        dlg.Destroy()
        if res == wx.ID_YES:
            eg.app.Restart() 
Example #15
Source File: LanguageEditor.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def CheckNeedsSave(self):
        if self.isDirty:
            dlg = wx.MessageDialog(
                self,
                "Save Changes?",
                "Save Changes?",
                wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION
            )
            result = dlg.ShowModal()
            dlg.Destroy()
            if result == wx.ID_CANCEL:
                return True
            if result == wx.ID_YES:
                self.OnCmdSave()
        return False 
Example #16
Source File: WinUsb.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def InstallDriver(cls):
        while True:
            with cls.installThreadLock:
                if cls.installQueue.empty():
                    cls.installThread = None
                    return
            self = cls.installQueue.get()
            if wx.YES != eg.CallWait(
                wx.MessageBox,
                Text.installMsg % self.plugin.name,
                caption=Text.dialogCaption % self.plugin.name,
                style=wx.YES_NO | wx.ICON_QUESTION | wx.STAY_ON_TOP,
                parent=eg.document.frame
            ):
                continue
            if not self.CheckAddOnFiles():
                continue
            self.CreateInf()
            result = -1
            cmdLine = '"%s" /f /lm' % join(INSTALLATION_ROOT, "dpinst.exe")
            try:
                result = ExecAs(
                    "subprocess",
                    eg.WindowsVersion >= 'Vista' or not IsAdmin(),
                    "call",
                    cmdLine.encode('mbcs'),
                )
            except WindowsError, exc:
                #only silence "User abort"
                if exc.winerror != 1223:
                    raise
            if result == 1:
                eg.actionThread.Call(self.plugin.info.Start) 
Example #17
Source File: Main_Dialog.py    From topoflow with MIT License 5 votes vote down vote up
def On_File_Exit(self, event):

        dlg = wx.MessageDialog(self,
                "Do you really want to close this application?",
                "Confirm Exit", wx.OK|wx.CANCEL|wx.ICON_QUESTION)
        result = dlg.ShowModal()
        dlg.Destroy()
        if (result == wx.ID_OK):
            self.Destroy()
  
        ## self.Destroy()

    #   On_File_Exit()
    #---------------------------------------------------------------- 
Example #18
Source File: WinUsb.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def ShowDownloadMessage(self):
        return wx.YES == wx.MessageBox(
            Text.downloadMsg % self.plugin.name,
            caption=Text.dialogCaption % self.plugin.name,
            style=wx.YES_NO | wx.ICON_QUESTION | wx.STAY_ON_TOP,
            parent=eg.document.frame
        ) 
Example #19
Source File: WinUsb.py    From EventGhost with GNU General Public License v2.0 5 votes vote down vote up
def ShowRestartMessage(self):
        res = wx.MessageBox(
            Text.restartMsg,
            caption=eg.APP_NAME,
            style=wx.YES_NO | wx.ICON_QUESTION | wx.STAY_ON_TOP,
            parent=eg.document.frame
        )
        if res == wx.YES:
            eg.app.Restart() 
Example #20
Source File: svgui.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def _StartInkscape(self):
        svgfile = self._getSVGpath()
        open_inkscape = True
        if not self.GetCTRoot().CheckProjectPathPerm():
            dialog = wx.MessageDialog(self.GetCTRoot().AppFrame,
                                      _("You don't have write permissions.\nOpen Inkscape anyway ?"),
                                      _("Open Inkscape"),
                                      wx.YES_NO | wx.ICON_QUESTION)
            open_inkscape = dialog.ShowModal() == wx.ID_YES
            dialog.Destroy()
        if open_inkscape:
            if not os.path.isfile(svgfile):
                svgfile = None
            open_svg(svgfile) 
Example #21
Source File: add_i2c.py    From openplotter with GNU General Public License v2.0 5 votes vote down vote up
def onReset(self, e):
		dlg = wx.MessageDialog(None, _('If your sensors are not detected right, try resetting system or forcing name and address.\n\nDo you want to try auto detection again?'),_('Question'), wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION)
		if dlg.ShowModal() == wx.ID_YES:
			try:
				os.remove(self.home + '/.pypilot/RTIMULib2.ini')
			except: pass
			self.detection()
		dlg.Destroy() 
Example #22
Source File: IDEFrame.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def CheckElementIsUsedBeforeDeletion(self, check_function, title, name):
        if not check_function(name):
            return True

        dialog = wx.MessageDialog(
            self,
            _("\"%s\" is used by one or more POUs. Do you wish to continue?") % name,
            title, wx.YES_NO | wx.ICON_QUESTION)
        answer = dialog.ShowModal()
        dialog.Destroy()
        return answer == wx.ID_YES 
Example #23
Source File: template.py    From wxGlade with MIT License 5 votes vote down vote up
def save_template(data=None):
    "Returns an out file name and template description for saving a template"
    dlg = templates_ui.TemplateInfoDialog(None, -1, "")
    if data is not None:
        dlg.template_name.SetValue( misc.wxstr(os.path.basename(os.path.splitext(data.filename)[0])) )
        dlg.author.SetValue(misc.wxstr(data.author))
        dlg.description.SetValue(misc.wxstr(data.description))
        dlg.instructions.SetValue(misc.wxstr(data.instructions))
    ret = None
    retdata = Template()
    if dlg.ShowModal() == wx.ID_OK:
        ret = dlg.template_name.GetValue().strip()
        retdata.author = dlg.author.GetValue()
        retdata.description = dlg.description.GetValue()
        retdata.instructions = dlg.instructions.GetValue()
        if not ret:
            wx.MessageBox( _("Can't save a template with an empty name"), _("Error"), wx.OK|wx.ICON_ERROR )
    dlg.Destroy()
    name = ret
    if ret:
        template_directory = os.path.join(config.appdata_path, 'templates')
        if not os.path.exists(template_directory):
            try:
                os.makedirs(template_directory)
            except EnvironmentError:
                logging.exception( _('ERROR creating directory "%s"'), template_directory )
                return None, retdata
        ret = os.path.join(template_directory, ret + '.wgt')
    if ret and os.path.exists(ret) and \
       wx.MessageBox( _("A template called '%s' already exists:\ndo you want to overwrite it?") % name,
                      _("Question"), wx.YES|wx.NO|wx.ICON_QUESTION) != wx.YES:
        ret = None
    return ret, retdata 
Example #24
Source File: main.py    From wxGlade with MIT License 5 votes vote down vote up
def _open(self, filename):
        # called by open_app and open_from_history
        if common.check_autosaved(filename):
            res = wx.MessageBox( _('There seems to be auto saved data for this file: do you want to restore it?'),
                                 _('Auto save detected'), style=wx.ICON_QUESTION | wx.YES_NO )
            if res == wx.YES:
                common.restore_from_autosaved(filename)
            else:
                common.remove_autosaved(filename)
        else:
            common.remove_autosaved(filename)

        path = position = None
        if filename == common.root.filename:
            # if we are re-loading the file, store path and position
            if misc.focused_widget:
                path = misc.focused_widget.get_path()
                if misc.focused_widget.widget is not None and not misc.focused_widget.IS_ROOT:
                    toplevel = misc.get_toplevel_parent(misc.focused_widget.widget)
                    if toplevel: position = toplevel.GetPosition()

        self._open_app(filename)
        self.cur_dir = os.path.dirname(filename)
        if not path: return
        editor = common.root.find_widget_from_path(path)
        if not editor: return
        misc.set_focused_widget(editor)
        if editor is common.root: return
        editor.toplevel_parent.create()

        common.app_tree.ExpandAllChildren(editor.item)

        if not position or not editor.widget: return
        misc.get_toplevel_parent(editor.widget).SetPosition(position) 
Example #25
Source File: main.py    From wxGlade with MIT License 5 votes vote down vote up
def ask_save(self):
        """checks whether the current app has changed and needs to be saved:
        if so, prompts the user;
        returns False if the operation has been cancelled"""
        if not common.root.saved:
            ok = wx.MessageBox(_("Save changes to the current app?"),
                               _("Confirm"), wx.YES_NO|wx.CANCEL|wx.CENTRE|wx.ICON_QUESTION)
            if ok == wx.YES:
                self.save_app()
            return ok != wx.CANCEL
        return True 
Example #26
Source File: main.py    From wxGlade with MIT License 5 votes vote down vote up
def check_autosaved(self):
        if not common.check_autosaved(None): return
        res = wx.MessageBox(
            _('There seems to be auto saved data from last wxGlade session: do you want to restore it?'),
            _('Auto save detected'), style=wx.ICON_QUESTION | wx.YES_NO)
        if res == wx.YES:
            filename = common.get_name_for_autosave()
            if self._open_app(filename, add_to_history=False):
                self.cur_dir = os.path.dirname(filename)
                common.root.saved = False
                common.root.filename = None
                self.user_message(_('Auto save loaded'))
        common.remove_autosaved() 
Example #27
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 #28
Source File: configurator.py    From steam-vr-wheel with MIT License 5 votes vote down vote up
def read_config(self):
        try:
            self.config = PadConfig()
        except ConfigException as e:
            msg = "Config error: {}. Load defaults?".format(e)
            dlg = wx.MessageDialog(self.pnl, msg, "Config Error", wx.YES_NO | wx.ICON_QUESTION)
            result = dlg.ShowModal() == wx.ID_YES
            dlg.Destroy()
            if result:
                self.config = PadConfig(load_defaults=True)
            else:
                sys.exit(1)
        for key, item in self._config_map.items():
            item.SetValue(getattr(self.config, key)) 
Example #29
Source File: app.py    From thotkeeper with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def _DeleteEntry(self, year, month, day, id, skip_verify=False):
        if self._RefuseUnsavedModifications(True):
            return False
        entry = self.entries.get_entry(year, month, day, id)

        def _ConfirmDelete():
            return wx.MessageBox(
                ("Are you sure you want to delete this entry?\n\n"
                 "   Date: %04d-%02d-%02d\n"
                 "   Author: %s\n"
                 "   Subject:  %s\n"
                 "   Tags: %s"
                 % (year, month, day, entry.get_author(),
                    entry.get_subject(),
                    self._TagsToText(entry.get_tags()))),
                'Confirm Deletion',
                wx.OK | wx.CANCEL | wx.ICON_QUESTION,
                self.frame)
        if skip_verify or wx.OK == _ConfirmDelete():
            self.entries.remove_entry(year, month, day, id)
            self._SaveData(self.conf.data_file, self.entries)
            dispyear, dispmonth, dispday, dispid = self._GetEntryFormKeys()
            if [dispyear, dispmonth, dispday, dispid] == \
               [year, month, day, id]:
                self._SetEntryModified(False)
                self._SetEntryFormDate(dispyear, dispmonth, dispday) 
Example #30
Source File: guiminer.py    From poclbm with GNU General Public License v3.0 5 votes vote down vote up
def on_close(self, event):
        """Minimize to tray if they click "close" but exit otherwise.

        On closing, stop any miners that are currently working.
        """
        if event.CanVeto():
            self.Hide()
            event.Veto()
        else:
            if any(p.is_modified for p in self.profile_panels):
                dialog = wx.MessageDialog(self, _('Do you want to save changes?'), _('Save'),
                    wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
                retval = dialog.ShowModal()
                dialog.Destroy()
                if retval == wx.ID_YES:
                    self.save_config()

            if self.console_panel is not None:
                self.console_panel.on_close()
            if self.summary_panel is not None:
                self.summary_panel.on_close()
            for p in self.profile_panels:
                p.on_close()
            if self.tbicon is not None:
                self.tbicon.RemoveIcon()
                self.tbicon.timer.Stop()
                self.tbicon.Destroy()
            event.Skip()