python类YES_NO的实例源码

w10config.py 文件源码 项目:wintenApps 作者: josephsl 项目源码 文件源码 阅读 40 收藏 0 点赞 0 评论 0
def getUpdateResponse(message, caption, updateURL):
    if gui.messageBox(message, caption, wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.CENTER | wx.ICON_QUESTION) == wx.YES:
        W10UpdateDownloader([updateURL]).start()
w10config.py 文件源码 项目:wintenApps 作者: josephsl 项目源码 文件源码 阅读 38 收藏 0 点赞 0 评论 0
def onOk(self, evt):
        # #39: Prompt if switching from stable to development channel.
        currentUpdateChannel = config.conf["wintenApps"]["updateChannel"]
        newUpdateChannel = ("dev", "stable")[self.channels.GetSelection()]
        if currentUpdateChannel == "stable" and newUpdateChannel == "dev":
            if gui.messageBox(
                # Translators: The confirmation prompt displayed when changing to development channel (with risks involved).
                _("You are about to switch to development updates channel. Although updates from this channel brings exciting features, it also comes with updates that might be unstable at times and should be used for testing and sending feedback to the add-on developer. If you prefer to use stable releases, please answer no and switch to stable update channel. Are you sure you wish to switch to the development update channel?"),
                # Translators: The title of the channel switch confirmation dialog.
                _("Switching to unstable channel"),
                wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION, self
            ) == wx.NO:
                return
        global updateChecker
        if updateChecker and updateChecker.IsRunning(): updateChecker.Stop()
        config.conf["wintenApps"]["autoUpdateCheck"] = self.autoUpdateCheckbox.Value
        config.conf["wintenApps"]["updateCheckTimeInterval"] = self.updateInterval.Value
        if not self.updateInterval.Value:
            config.conf["wintenApps"]["updateCheckTime"] = 0
            updateChecker = None
        else:
            updateChecker = wx.PyTimer(autoUpdateCheck)
            currentTime = time.time()
            whenToCheck = currentTime+(self.updateInterval.Value * addonUpdateCheckInterval)
            updateChecker.Start(whenToCheck-currentTime, True)
        config.conf["wintenApps"]["updateChannel"] = ("dev", "stable")[self.channels.GetSelection()]
        self.Destroy()
TortoiseSVNPlugin.py 文件源码 项目:robotframework-ride-tortoisesvn 作者: ukostas 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def create_callable(self, name, action):
        def callable(event):
            # check if this is for whole project or file/directory
            if 'item' in name.lower():  # for one single item - file/directory
                if not self.datafile:
                    return
                full_cmd = action.format(path=self.datafile.source)
            else:  # for whole project - root file/directory
                full_cmd = action.format(path=self.model.suite.source)
            # RideLogMessage(name + " clicked: " + fullCmd).publish()
            if full_cmd.lower().startswith('http'):
                wx.LaunchDefaultBrowser(full_cmd)
            else:
                try:
                    subprocess.Popen(full_cmd)
                except OSError as error:
                    s = "This is the error we got trying to execute {executor_name} executable file:\n" \
                        "\"{error}\"\n\n" \
                        "Probably this file in not in your PATH. Try to reinstall {executor_name}.\n" \
                        "Do you want to open download page?".format(error=error.strerror, executor_name=self.MENU_NAME)
                    dlg = wx.MessageDialog(parent=self.frame, caption="Hmm, something went wrong...", message=s,
                                           style=wx.YES_NO | wx.CENTER | wx.ICON_INFORMATION)
                    if dlg.ShowModal() == wx.ID_YES:
                        wx.LaunchDefaultBrowser(self.SVN_INSTALLATION_URL)
                    dlg.Destroy()

        return callable
wx_2048_02.py 文件源码 项目:python_2048 作者: OATOMO 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def doMove(self,move,score):
        if move:
            self.putTile()
            self.drawChange(score)
            if self.isGameOver():
                if wx.MessageBox(u"????????????",u"??",
                        wx.YES_NO|wx.ICON_INFORMATION)==wx.YES:
                    bstScore = self.bstScore
                    self.initGame()
                    self.bstScore = bstScore
                    self.drawAll()
IDEFrame.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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
ProjectController.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def CheckNewProjectPath(self, old_project_path, new_project_path):
        if old_project_path == new_project_path:
            message = (_("Save path is the same as path of a project! \n"))
            dialog = wx.MessageDialog(self.AppFrame, message, _("Error"), wx.OK | wx.ICON_ERROR)
            dialog.ShowModal()
            return False
        else:
            plc_file = os.path.join(new_project_path, "plc.xml")
            if os.path.isfile(plc_file):
                message = (_("Selected directory already contains another project. Overwrite? \n"))
                dialog = wx.MessageDialog(self.AppFrame, message, _("Error"), wx.YES_NO | wx.ICON_ERROR)
                answer = dialog.ShowModal()
                return answer == wx.ID_YES
        return True
svgui.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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)
IPy.py 文件源码 项目:imagepy 作者: Image-Py 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
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]
lib.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def OnRemoveClick(self, event): # wxGlade: MyFrame.<event_handler>

        self.remove_row_index
        msg="This student along with all data will be deleted\nAre you sure you want to  Delete this row?"
        if wx.MessageBox(msg, "Want to Delete?", wx.YES_NO) == wx.YES:



            removed_item=self.CURRENT_LIST[0][self.remove_row_index+1]
            #print "removing",removed_item

            self.DB.RemoveScore(removed_item[4])     #Passing score id

            #Checking if the student has any other record in any other  div
            query='SELECT * FROM T1 WHERE STUDENT_ID=?'
            self.DB.cur.execute(query,(removed_item[1],))
            if self.DB.cur.fetchone()==None:
                self.DB.RemoveStudent(removed_item[1])  #passing student_id
            else:
                print 'other records exixts'


            if self.SUBJECT=="Basic Science":


                removed_item2=self.CURRENT_LIST[1][self.remove_row_index]
                removed_item3=self.CURRENT_LIST[2][self.remove_row_index]
                self.CURRENT_LIST[1].remove(removed_item2)
                self.CURRENT_LIST[2].remove(removed_item3)


            self.grid_1.DeleteRows(self.remove_row_index,1)
                    #except:

                    #print "Error in removing row"


        event.Skip()
sampoorna_gui_old.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def on_finished(self, event):  # wxGlade: sampoorna_win.<event_handler>
        if self.button_finished.Label=="Abort":
            msg="Do you want to abort this operation?"
            dlg = wx.MessageDialog(self, msg,"Warning", wx.YES_NO | wx.ICON_QUESTION)
            result = dlg.ShowModal()# == wx.ID_YES
            if result==wx.ID_YES:


                self.thread.stop()
                self.Close()

            dlg.Destroy()
        else:
            self.Close()
        event.Skip()# end of class sampoorna_win
import_win.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def ok_clicked(self,event):

        msg='The spreadsheet must have data in 3 columns in the order of Roll No, Admission No, Name.'
        msg+=' It assumes first row carries headings and student data begins only from the second row.Do you want to proceed ?'
        dlg = wx.MessageDialog(self, msg,"Excel Format", wx.YES_NO | wx.ICON_QUESTION)
        result = dlg.ShowModal()# == wx.ID_YES
        if result==wx.ID_YES:


            self.I=import_excel_operations(self,self.YEAR,self.CLASS,self.DIV)
            self.I.do()
            dlg.Destroy()
        else:
            self.Close()
add_div.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def on_hlink(self, event):  # wxGlade: student_profie.<event_handler>

        new_acd_win=add_academic_year(self)
        new_acd_win.ShowModal()
        new_year=new_acd_win.NEW_YEAR
        if not new_year:
            new_acd_win.Destroy()

            return 0
        new_acd_win.Destroy()
        years=self.DB.Get_Years()
        if years.count(int(new_year)):
            msg= "Acdemic year "+str(new_year)+"-"+str(int(new_year)+1)+"already exists"
            dlg = wx.MessageDialog(self,msg, 'Error Adding',wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return

        years.sort()

        msg="Do you want to add new academic year "+new_year+"-"+str(int(new_year)+1)

        dlg = wx.MessageDialog(self, msg,"Add Year?", wx.YES_NO | wx.ICON_QUESTION)
        result = dlg.ShowModal()# == wx.ID_YES
        if result==wx.ID_NO:
            dlg.Destroy()


            return 0

        dlg.Destroy()
        self.DB.Add_Div(new_year,'8','A')
        self.DB.Add_Div(new_year,'9','A')
        self.DB.Add_Div(new_year,'10','A')

        self.load_year()



        event.Skip()
student_profile.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def db_delete(self):

        msg="The student "+self.text_ctrl_name.Value+", along with all data, will be deleted\nAre you sure you want to  continue?"
        dlg = wx.MessageDialog(self, msg,"Warning", wx.YES_NO | wx.ICON_QUESTION)
        result = dlg.ShowModal()# == wx.ID_YES
        if result==wx.ID_NO:
            return 0
        dlg.Destroy()

        try:
                self.DB.Remove_Student_Full(self.combo_box_adno.GetStringSelection())
                msg="Successfully Removed Student"
                icon=wx.ICON_INFORMATION
        except:
            msg="Failed to Remove the Student"
            icon=wx.ICON_ERROR

        dlg = wx.MessageDialog(self, msg, '',wx.OK | icon)                  
        dlg.ShowModal()
        dlg.Destroy()



        self.load_admission_no()
        self.clear_student_details()
        self.button_delete.Disable()
imViewer_Simple.py 文件源码 项目:bids 作者: robertoostenveld 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def MsgDlg(window, string, caption='OFAImage', style=wx.YES_NO | wx.CANCEL):
    """Common MessageDialog."""
    dlg = wx.MessageDialog(window, string, caption, style)
    result = dlg.ShowModal()
    dlg.Destroy()
    return result
mzGUI_standalone.py 文件源码 项目:multiplierz 作者: BlaisProteomics 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def update(self, count):
        self.progressBar.Update(count)

        if self.progressBar.Update(count)[0] == 0:
            cancelMsg = wx.MessageDialog(None, "Are you sure you want to cancel?",'Continue?',wx.YES_NO | wx.ICON_QUESTION)
            cancelMsgAnswer = cancelMsg.ShowModal()
            if cancelMsgAnswer == wx.ID_YES:
                return False
            else:
                self.progressBar.Resume()

        return True
gripy_app.py 文件源码 项目:GRIPy 作者: giruenf 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def PreExit(self):
        msg = 'GriPy Application is preparing to terminate....'
        log.info(msg)
        print '\n', msg
        OM = ObjectManager(self)
        if OM.get_changed_flag():
            dial = wx.MessageDialog(self.GetTopWindow(), 
                                    'Do you want to save your project?', 
                                    'GriPy', 
                                    wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION
            )
            if dial.ShowModal() == wx.ID_YES:
                self.on_save()   
        #
        self.reset_ObjectManager()
        #
        app_UI_filename = self._gripy_app_state.get('app_UI_file')
        Interface.save_UI_application_data(app_UI_filename)

        user_UI_filename = self._gripy_app_state.get('user_UI_file')
        Interface.save_UI_user_data(user_UI_filename)

        # This time I choose not use the line below because there was a little
        # freeze on exiting (1-2 seconds). Then I opted delegate it do compiler.
        #UIM = UIManager()      
        #UIM.close()
        UIM = UIManager()  
        UIM.PreExit()

        # As indicated by https://forums.wxwidgets.org/viewtopic.php?t=32138        
        aui_manager = wx.aui.AuiManager.GetManager(self.GetTopWindow())
        aui_manager.UnInit()
record.py 文件源码 项目:TensorKart 作者: kevinhughes27 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def start_recording(self):
        # check that a dir has been specified
        if self.txt_outputDir.IsEmpty():

            msg = wx.MessageDialog(self, 'Specify the Output Directory', 'Error', wx.OK | wx.ICON_ERROR)
            msg.ShowModal() == wx.ID_YES
            msg.Destroy()

            self.recording = False

        else: # a directory was specified
            self.outputDir = self.txt_outputDir.GetValue()
            self.t = 0

            # check if path exists - ie may be saving over data
            if os.path.exists(self.outputDir):

                msg = wx.MessageDialog(self, 'Output Directory Exists - Overwrite Data?', 'Yes or No', wx.YES_NO | wx.ICON_QUESTION)
                result = msg.ShowModal() == wx.ID_YES
                msg.Destroy()

                # overwrite the data
                if result == True:

                    # delete the dir
                    shutil.rmtree(self.outputDir)

                    # re-make dir
                    os.mkdir(self.outputDir)

                # do not overwrite the data
                else: # result == False
                    self.recording = False
                    self.txt_outputDir.SetFocus()

            # no directory so make one
            else:
                os.mkdir(self.outputDir)
pigrow_remote.py 文件源码 项目:Pigrow 作者: Pragmatismo 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def update_cron_click(self, e):
        #make a text file of all the cron jobs
        cron_text = ''
        startup_num = cron_list_pnl.startup_cron.GetItemCount()
        for num in range(0, startup_num):
            cron_line = ''
            if cron_list_pnl.startup_cron.GetItemText(num, 1) == 'False':
                cron_line += '#'
            cron_line += '@reboot ' + cron_list_pnl.startup_cron.GetItemText(num, 3) # cron_task
            cron_line += ' ' + cron_list_pnl.startup_cron.GetItemText(num, 4) # cron_extra_args
            cron_line += ' ' + cron_list_pnl.startup_cron.GetItemText(num, 5) # cron_comment
            cron_text += cron_line + '\n'
        repeat_num = cron_list_pnl.repeat_cron.GetItemCount()
        for num in range(0, repeat_num):
            cron_line = ''
            if cron_list_pnl.repeat_cron.GetItemText(num, 1) == 'False':
                cron_line += '#'
            cron_line += cron_list_pnl.repeat_cron.GetItemText(num, 2).strip(' ')
            cron_line += ' ' + cron_list_pnl.repeat_cron.GetItemText(num, 3) # cron_task
            cron_line += ' ' + cron_list_pnl.repeat_cron.GetItemText(num, 4) # cron_extra_args
            cron_line += ' ' + cron_list_pnl.repeat_cron.GetItemText(num, 5) # cron_comment
            cron_text += cron_line + '\n'
        onetime_num = cron_list_pnl.timed_cron.GetItemCount()
        for num in range(0, onetime_num):
            cron_line = ''
            if cron_list_pnl.timed_cron.GetItemText(num, 1) == 'False':
                cron_line += '#'
            cron_line += cron_list_pnl.timed_cron.GetItemText(num, 2).strip(' ')
            cron_line += ' ' + cron_list_pnl.timed_cron.GetItemText(num, 3) # cron_task
            cron_line += ' ' + cron_list_pnl.timed_cron.GetItemText(num, 4) # cron_extra_args
            cron_line += ' ' + cron_list_pnl.timed_cron.GetItemText(num, 5) # cron_comment
            cron_text += cron_line + '\n'
        # ask the user if they're sure
        msg_text = "Update cron to; \n\n" + cron_text
        mbox = wx.MessageDialog(None, msg_text, "Are you sure?", wx.YES_NO|wx.ICON_QUESTION)
        sure = mbox.ShowModal()
        if sure == wx.ID_YES:
            print "Updating remote cron"
            # save cron text onto pigrow as text file then import into cron
            sftp = ssh.open_sftp()
            try:
                tempfolder = '/home/pi/Pigrow/temp'
                sftp.mkdir(tempfolder)
            except IOError:
                pass
            f = sftp.open(tempfolder + '/remotecron.txt', 'w')
            f.write(cron_text)
            f.close()
            try:
                stdin, stdout, stderr = ssh.exec_command("crontab " + tempfolder + '/remotecron.txt')
                responce = stdout.read()
                error = stderr.read()
                print responce, error
            except Exception as e:
                print("this ain't right, it just ain't right! " + str(e))
        else:
            print("Updating cron cancelled")
        mbox.Destroy()
        #refresh cron list
        self.read_cron_click("event")
WPKG-GP-Client_phoenix.py 文件源码 项目:wpkg-gp-client 作者: sonicnkt 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def on_upgrade(self, event):
        try:
            if self.wpkg_dialog.IsShown():
                # If dialog is opened already, raise window to top
                self.wpkg_dialog.Raise()
                return
        except AttributeError:
            # Dialog is not opened yet
            # Check if Reboot is Pending
            try:
                reboot_pending = ReadRebootPendingTime()
            except WindowsError:
                dlg_msg = _(u'Registry Error\n\nNo access to necessary registry key.')
                dlg = wx.MessageDialog(None, dlg_msg, app_name, wx.OK | wx.ICON_ERROR)
                dlg.ShowModal()
                dlg.Destroy()
                return
            if reboot_pending and reboot_pending > self.bootup_time:
                dlg_msg = _(u"Reboot required!\n\n"
                           u"A reboot is required before the system\n"
                           u"can be updated again.\n"
                           u"Reboot now?")
                dlg = wx.MessageDialog(None, dlg_msg, app_name, wx.YES_NO | wx.YES_DEFAULT | wx.ICON_EXCLAMATION)
                if dlg.ShowModal() == wx.ID_YES:
                    # Initiate Reboot
                    shutdown(1, time=5, msg=_(u"System will reboot now!"))
                    return
                else:
                    return
            elif reboot_pending:
                SetRebootPendingTime(reset=True)
            if update_method and update_interval:
                self.timer.Stop()
            self.wpkg_dialog = RunWPKGDialog(parent=self, title=_(u'System Update'))
            self.wpkg_dialog.ShowModal()
            if self.wpkg_dialog.shutdown_scheduled == True:
                # Shutdown Scheduled add Cancel Option to Popup Menu
                self.shutdown_scheduled = True
            if self.wpkg_dialog.reboot_scheduled == True:
                # Reboot Scheduled add Cancel Option to Popup Menu
                self.shutdown_scheduled = True
                self.reboot_scheduled = True
            self.wpkg_dialog.Destroy()
            if update_method and update_interval:
                self.timer.Start()
WPKG-GP-Client_phoenix.py 文件源码 项目:wpkg-gp-client 作者: sonicnkt 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def LongTask(self):
        return_msg = None
        return_code = None
        reboot = False
        # Checking if System is connected through VPN
        if check_vpn and vpn_connected(arch=arch):
            dlg_msg = _(u"WPKG-GP Client detected a active VPN Connection using Cisco Anyconnect.\n"
                        u"This could result in slow upgrade progress and updates for the AnyConnect\n"
                        u"Software will be blocked.\n"
                        u"Continue?")
            dlg = wx.MessageDialog(self, dlg_msg, app_name, wx.YES_NO | wx.YES_DEFAULT | wx.ICON_INFORMATION)
            if dlg.ShowModal() == wx.ID_NO:
                # Canceled by user because of active VPN Connection
                return_msg = 'WPKG process start canceled by user.' # Make translate able?
                return 400, return_msg, None
        # LONG TASK is the PipeConnection to the WPKG-GP Windows Service
        self.running = True
        msg = 'ExecuteNoReboot'
        try:
            pipeHandle = CreateFile("\\\\.\\pipe\\WPKG", GENERIC_READ|GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, None)
        except pywintypes.error, (n, f, e):
            # print "Error when generating pipe handle: %s" % e
            # Can't connect to pipe error, probably service not running
            return_msg = u"Error: WPKG-GP Service not running"
            return 208, return_msg, None

        SetNamedPipeHandleState(pipeHandle, PIPE_READMODE_MESSAGE, None, None)
        WriteFile(pipeHandle, msg)
        while 1:
            try:
                (hr, readmsg) = ReadFile(pipeHandle, 512)
                out = readmsg[4:].decode('utf-8')  #Strip 3 digit status code, decode characters
                status_code = int(readmsg[:3])
                if status_code < 102:
                    # default status code for pipe updates
                    percentage = getPercentage(out)
                    wx.CallAfter(self.update_box.SetValue, out)
                    wx.CallAfter(self.gauge.SetValue, percentage)
                elif status_code > 300:
                    # reboot necessary
                    reboot = True
                elif status_code > 200:
                    # possible error
                    return_code = status_code
                    return_msg = out
            except win32api.error as exc:
                if exc.winerror == winerror.ERROR_PIPE_BUSY:
                    win32api.Sleep(5000)
                    print 'Pipe Busy Error'
                    continue
                break

        return return_code, return_msg, reboot


问题


面经


文章

微信
公众号

扫码关注公众号