python类OK的实例源码

gui.py 文件源码 项目:stopgo 作者: notklaatu 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def OnQuit(self,event,dbfile):
        if _plat.startswith('linux'):
            dlg = wx.MessageDialog(self, 'Really quit?','', wx.OK | wx.CANCEL | wx.ICON_ERROR)
            val = dlg.ShowModal()
            dlg.Show()

            if val == wx.ID_CANCEL:
                dlg.Destroy()
            elif val == wx.ID_OK:
                OKQuit = self.DBQuit(dbfile)
                if OKQuit == 42:
                    self.Close()

        elif _plat.startswith('darwin'):
            pass
        elif _plat.startswith('win'):
            OKQuit = self.DBQuit(dbfile)
            if OKQuit == 42:
                self.Close()
                sys.exit()#windows


        self.Refresh()
SettingsDialog.py 文件源码 项目:irida-miseq-uploader 作者: phac-nml 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, parent=None, first_run=False):
        wx.Dialog.__init__(self, parent, title="Settings", style=wx.DEFAULT_DIALOG_STYLE)
        self._first_run = first_run
        self._sizer = wx.BoxSizer(wx.VERTICAL)
        self._defaults = {}

        self._sizer.Add(URLEntryPanel(self, default_url=read_config_option("baseurl")), flag=wx.EXPAND | wx.ALL, border=5)

        authorization_sizer = wx.BoxSizer(wx.HORIZONTAL)
        authorization_sizer.Add(ClientDetailsPanel(self, default_client_id=read_config_option("client_id"), default_client_secret=read_config_option("client_secret")), flag=wx.EXPAND | wx.RIGHT, border=2, proportion=1)
        authorization_sizer.Add(UserDetailsPanel(self, default_user=read_config_option("username"), default_pass=read_config_option("password")), flag=wx.EXPAND | wx.LEFT, border=2, proportion=1)
        self._sizer.Add(authorization_sizer, flag=wx.EXPAND | wx.ALL, border=5)

        self._sizer.Add(PostProcessingTaskPanel(self, default_post_process=read_config_option("completion_cmd")), flag=wx.EXPAND | wx.ALL, border=5)
        self._sizer.Add(DefaultDirectoryPanel(self, default_directory=read_config_option("default_dir"), monitor_directory=read_config_option("monitor_default_dir", expected_type=bool)), flag=wx.EXPAND | wx.ALL, border=5)

        self._sizer.Add(self.CreateSeparatedButtonSizer(flags=wx.OK), flag=wx.EXPAND | wx.ALL, border=5)

        self.SetSizerAndFit(self._sizer)
        self.Layout()

        pub.subscribe(self._field_changed, SettingsDialog.field_changed_topic)
        self.Bind(wx.EVT_CLOSE, self._on_close)
        self.Bind(wx.EVT_BUTTON, self._on_close, id=wx.ID_OK)
        threading.Thread(target=connect_to_irida).start()
designer.py 文件源码 项目:tindieorderprintout 作者: limpkin 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def do_input(Class, parent, title, fields, data):
        dlg = Class(parent, -1, title, size=(350, 200),
                         style=wx.DEFAULT_DIALOG_STYLE, # & ~wx.CLOSE_BOX,
                        fields=fields, data=data
                         )
        dlg.CenterOnScreen()
        while 1:
            val = dlg.ShowModal()
            if val == wx.ID_OK:
                values = {}
                for field in fields:
                    try:
                        values[field] = eval(dlg.textctrls[field].GetValue())
                    except Exception, e:
                        msg = wx.MessageDialog(parent, unicode(e),
                               "Error in field %s" % field,
                               wx.OK | wx.ICON_INFORMATION
                               )
                        msg.ShowModal()
                        msg.Destroy()
                        break
                else:
                    return dict([(field, values[field]) for field in fields])
            else:
                return None
mobile_insight_gui.py 文件源码 项目:mobileinsight-core 作者: mobile-insight 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __init__(self, parent, message, caption, choices=[]):
        wx.Dialog.__init__(self, parent, -1)
        self.SetTitle(caption)
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.message = wx.StaticText(self, -1, message)
        self.clb = wx.CheckListBox(self, -1, choices=choices)
        self.chbox = wx.CheckBox(self, -1, 'Select all')
        self.btns = self.CreateSeparatedButtonSizer(wx.OK | wx.CANCEL)
        self.Bind(wx.EVT_CHECKBOX, self.EvtChBox, self.chbox)

        sizer.Add(self.message, 0, wx.ALL | wx.EXPAND, 5)
        sizer.Add(self.clb, 1, wx.ALL | wx.EXPAND, 5)
        sizer.Add(self.chbox, 0, wx.ALL | wx.EXPAND, 5)
        sizer.Add(self.btns, 0, wx.ALL | wx.EXPAND, 5)
        self.SetSizer(sizer)
        # self.Fit()
mentaltasks.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def afterTest(self, earlyStop):
        if not earlyStop:
            self.saveCap()
            ca = np.mean(np.diag(self.confusion))/self.nTestTrial
            confusion = np.round(100*self.confusion/self.nTestTrial)

            resultText = (('Test Selection CA: %f\n' % ca) +
                          ('Confusion Matrix:\n' + str(confusion) + '\n') +
                          ('Choices: ' + str(self.choices)))

            wx.MessageBox(message=resultText,
                          caption='Testing Complete',
                          style=wx.OK | wx.ICON_INFORMATION)

            self.saveResultText(resultText)
        else:
            self.pieMenu.zeroBars(refresh=False)
            self.pieMenu.clearAllHighlights()
logging.py 文件源码 项目:cebl 作者: idfah 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def DoLog(self, level, msg, time):
        if level == wx.LOG_Warning:
            caption = 'Warning'
        elif level == wx.LOG_Error:
            caption = 'Error'
        else:
            caption = 'Message'

        fullMessage = caption + ': ' + msg + '\n'
        if level == wx.LOG_Error:
            sys.stderr.write(fullMessage)
            sys.stderr.flush()

        for tctrl in self.textCtrls:
            tctrl.AppendText(fullMessage)

        if level <= wx.LOG_Warning:
            dialog = wx.MessageDialog(None, message=msg, caption=caption,
                style=wx.ICON_ERROR | wx.OK)
            dialog.ShowModal()
            dialog.Destroy()
app.py 文件源码 项目:pyvmwareclient 作者: wbugbofh 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def onsoftreboot(self, event):
        fila = self.listadoVM
        for i in range(len(fila)):
            if logger != None: logger.info(fila[i])
        # El 9 elemento es el UUID
        if logger != None: logger.info (fila[8])
        #Pedimos confirmacion del reset de la mv con ventana dialogo
        dlg_reset = wx.MessageDialog(self,
                                     "Estas a punto de reiniciar \n " + fila[1] + " ",
                                     "Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION)
        result = dlg_reset.ShowModal()
        dlg_reset.Destroy()

        if result == wx.ID_OK:
            vm = conexion.searchIndex.FindByUuid(None,fila[8], True)
            if  vm  is not None:

                if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState))
                TASK = vm.RebootGuest()
                #Este da error tasks.wait_for_tasks(conexion, [TASK])
                if logger != None: logger.info("Soft reboot its done.")
app.py 文件源码 项目:pyvmwareclient 作者: wbugbofh 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def onsoftPowerOff(self, event):
        fila = self.listadoVM
        for i in range(len(fila)):
            if logger != None: logger.info(fila[i])
        # El 9 elemento es el UUID
        if logger != None: logger.info (fila[8])
        #Pedimos confirmacion del reset de la mv con ventana dialogo
        dlg_reset = wx.MessageDialog(self,
                                     "Estas a punto de Soft Apagar \n " + fila[1] + " ",
                                     "Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION)
        result = dlg_reset.ShowModal()
        dlg_reset.Destroy()

        if result == wx.ID_OK:
            vm = conexion.searchIndex.FindByUuid(None,fila[8], True)
            if  vm  is not None:

                if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState))
                TASK = vm.ShutdownGuest()
                #Este da error tasks.wait_for_tasks(conexion, [TASK])
                if logger != None: logger.info("Soft poweroff its done.")

    # Reiniciamos el ordenador seleccionado en el menu contextual
app.py 文件源码 项目:pyvmwareclient 作者: wbugbofh 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def onreboot(self, event):
        fila = self.listadoVM
        for i in range(len(fila)):
            if logger != None: logger.info(fila[i])
        # El 9 elemento es el UUID
        if logger != None: logger.info (fila[8])
        #Pedimos confirmacion del reset de la mv con ventana dialogo
        dlg_reset = wx.MessageDialog(self,
                                     "Estas a punto de reiniciar \n " + fila[1] + " ",
                                     "Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION)
        result = dlg_reset.ShowModal()
        dlg_reset.Destroy()

        if result == wx.ID_OK:
            vm = conexion.searchIndex.FindByUuid(None,fila[8], True)
            if  vm  is not None:

                if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState))
                TASK = vm.ResetVM_Task()
                tasks.wait_for_tasks(conexion, [TASK])
                if logger != None: logger.info("reboot its done.")
app.py 文件源码 项目:pyvmwareclient 作者: wbugbofh 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def onpower_on(self, event):
        fila = self.listadoVM
        for i in range(len(fila)):
            if logger != None: logger.info(fila[i])
        # El 9 elemento es el UUID
        if logger != None: logger.info (fila[8])
        #Pedimos confirmacion del poweron de la mv con ventana dialogo
        dlg_reset = wx.MessageDialog(self,
                                     "Estas a punto de iniciar \n " + fila[1] + "\nAhora esta:  " + fila[3],
                                     "Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION)
        result = dlg_reset.ShowModal()
        dlg_reset.Destroy()

        if result == wx.ID_OK:
            vm = conexion.searchIndex.FindByUuid(None,fila[8], True)
            if  vm  is not None and not vm.runtime.powerState == 'poweredOn':
                if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState))
                TASK = vm.PowerOn()
                tasks.wait_for_tasks(conexion, [TASK])
                if logger != None: logger.info("Power ON  its done.")
app.py 文件源码 项目:pyvmwareclient 作者: wbugbofh 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def onpowerOff(self, event):
        fila = self.listadoVM
        for i in range(len(fila)):
            if logger != None: logger.info(fila[i])
        # El 9 elemento es el UUID
        if logger != None: logger.info (fila[8])
        #Pedimos confirmacion del reset de la mv con ventana dialogo
        dlg_reset = wx.MessageDialog(self,
                                     "Estas a punto de Apagar \n " + fila[1] + " ",
                                     "Confirm Exit", wx.OK | wx.CANCEL | wx.ICON_QUESTION)
        result = dlg_reset.ShowModal()
        dlg_reset.Destroy()

        if result == wx.ID_OK:
            vm = conexion.searchIndex.FindByUuid(None,fila[8], True)
            if  vm  is not None and not vm.runtime.powerState == 'poweredOff':
                if logger != None: logger.info ("The current powerState is: {0}".format(vm.runtime.powerState))
                TASK = vm.PowerOff()
                tasks.wait_for_tasks(conexion, [TASK])
                if logger != None: logger.info("Power OFF its done.")
config_camera.py 文件源码 项目:Pigrow 作者: Pragmatismo 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def list_fs_ctrls_click(self, e):
        print("this is supposed to fswebcam -d v4l2:/dev/video0 --list-controls on the pi")
        target_ip = self.tb_ip.GetValue()
        target_user = self.tb_user.GetValue()
        target_pass = self.tb_pass.GetValue()
        try:
            ssh.connect(target_ip, username=target_user, password=target_pass, timeout=3)
            print "Connected to " + target_ip
            found_login = True
            cam_choice = self.cam_select_cb.GetValue()
            cam_cmd = "fswebcam -d v4l2:" + cam_choice + " --list-controls"
            print("---Doing: " + cam_cmd)
            stdin, stdout, stderr = ssh.exec_command(cam_cmd)
            cam_output = stderr.read().strip()
            print "Camera output; " + cam_output
            ssh.close()
        except Exception as e:
            print("Some form of problem; " + str(e))
            ssh.close()
        if not cam_output == None:
            msg_text = 'Camera located and interorgated; copy-paste a controll name from the following into the settings text box \n \n'
            msg_text += str(cam_output)
            wx.MessageBox(msg_text, 'Info', wx.OK | wx.ICON_INFORMATION)
pigrow_remote.py 文件源码 项目:Pigrow 作者: Pragmatismo 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def cat_script(self, e):
        #opens an ssh pipe and runs a cat command to get the text of the script
        target_ip = pi_link_pnl.target_ip
        target_user = pi_link_pnl.target_user
        target_pass = pi_link_pnl.target_pass
        script_path = self.cron_path_combo.GetValue()
        script_name = self.cron_script_cb.GetValue()
        script_to_ask = script_path + script_name
        try:
        #    ssh.connect(target_ip, username=target_user, password=target_pass, timeout=3)
            print "Connected to " + target_ip
            print("running; cat " + str(script_to_ask))
            stdin, stdout, stderr = ssh.exec_command("cat " + str(script_to_ask))
            script_text = stdout.read().strip()
            error_text = stderr.read().strip()
            if not error_text == '':
                msg_text =  'Error reading script \n\n'
                msg_text += str(error_text)
            else:
                msg_text = script_to_ask + '\n\n'
                msg_text += str(script_text)
            wx.MessageBox(msg_text, 'Info', wx.OK | wx.ICON_INFORMATION)
        except Exception as e:
            print("oh bother, this seems wrong... " + str(e))
plot.py 文件源码 项目:bonsu 作者: bonsudev 项目源码 文件源码 阅读 44 收藏 0 点赞 0 评论 0
def PrintPreview(self):
        """Print-preview current plot."""
        printout = PlotPrintout(self)
        printout2 = PlotPrintout(self)
        self.preview = wx.PrintPreview(printout, printout2, self.print_data)
        if not self.preview.IsOk():
            wx.MessageDialog(self, "Print Preview failed.\n"
                             "Check that default printer is configured\n",
                             "Print error", wx.OK | wx.CENTRE).ShowModal()
        self.preview.SetZoom(40)
        # search up tree to find frame instance
        frameInst = self
        while not isinstance(frameInst, wx.Frame):
            frameInst = frameInst.GetParent()
        frame = wx.PreviewFrame(self.preview, frameInst, "Preview")
        frame.Initialize()
        frame.SetPosition(self.GetPosition())
        frame.SetSize((600, 550))
        frame.Centre(wx.BOTH)
        frame.Show(True)
bonsu.py 文件源码 项目:bonsu 作者: bonsudev 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def OnHelp(self,e):
        dlg = wx.MessageDialog(self, "Bonsu will attempt to open the"+os.linesep+"documentation with your default"+os.linesep+"browser. Continue?","Confirm Open", wx.OK|wx.CANCEL|wx.ICON_QUESTION)
        result = dlg.ShowModal()
        dlg.Destroy()
        if result == wx.ID_OK:
            path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'docs',  'bonsu.html')
            if sys.platform.startswith('win'):
                os.startfile(path)
            elif sys.platform.startswith('darwin'):
                from subprocess import Popen
                Popen(['open', path])
            else:
                try:
                    from subprocess import Popen
                    Popen(['xdg-open', path])
                except:
                    pass
supplicantdev.py 文件源码 项目:Supplicant 作者: mayuko2012 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def OnConnect(self,event):
        Username = self.username.GetValue()
        Password = self.pwd.GetValue()
        mac = get.get_mac_address()
        self.MAC=mac
        ip = get.Get_local_ip()
        self.IP=ip
        upnet_net = packet.generate_upnet(mac, ip, Username, Password)
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        hosts = '210.45.194.10'
        status,message= connect.upnet(sock, upnet_net, hosts,self.getsession)
        if status == 0:
            msgbox = wx.MessageDialog(None, "",message,wx.OK)
            msgbox.ShowModal()
            frame=MainFrame()
            frame.Show()
        else:
            self.connect.Disable()
            self.disconnect.Enable()
            self.username.SetEditable(False)
            self.pwd.SetEditable(False)
            wx.MessageBox(u'??????',message)
            self.SetStatusText(u"????")
            self.OnStartThread()
supplicantdev.py 文件源码 项目:Supplicant 作者: mayuko2012 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def run(self):
         self.timeToQuit.wait(10)
         while True:
            if self.timeToQuit.isSet():
                self.sock.close()
                break
            else:
                breathe = packet.generate_breathe(self.mac, self.ip, self.session, self.index)
                status = connect.breathe(self.sock, breathe, self.hosts)
                if status == 0:
                    self.sock.close()
                    wx.MessageBox(u"?????????????",u"??!!",wx.OK | wx.ICON_INFORMATION,self)
                    sys.exit()
                    break
                else:
                    self.index += 3
                    self.timeToQuit.wait(self.messageDelay)
UI.py 文件源码 项目:AppAutoViewer 作者: RealLau 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def tellToDoSwipeOrInput(self, evt):
        operationString = self.OpeartionBox.GetStringSelection()    
        inputC = self.inputContent.GetValue()
        sX = self.swipeStartX.GetValue()
        sY = self.swipeStartY.GetValue()
        eX = self.swipeEndX.GetValue()
        eY = self.swipeEndY.GetValue()        

        if operationString=="??":
            if inputC=="":
                dlg = wx.MessageDialog(self, u"???????", u"????????", wx.OK | wx.ICON_ERROR)
                if dlg.ShowModal() == wx.ID_OK:
                    dlg.Destroy()
            else:
                keyb = self.keyboardType.GetValue()
                wx.CallAfter(pub.sendMessage, "DoSwipeOrInput", msg =inputC+"\n"+keyb)
        else:
            if sX=="" or sY=="" or eX=="" or eY=="":
                dlg = wx.MessageDialog(self, u"?????????", u"??????????????????", wx.OK | wx.ICON_ERROR)
                if dlg.ShowModal() == wx.ID_OK:
                    dlg.Destroy()
            else:
                wx.CallAfter(pub.sendMessage, "DoSwipeOrInput", msg ="??\n%d\n%d\n%d\n%d" % (sX,sY,eX,eY))
request2doc_gui.py 文件源码 项目:request2doc 作者: kongxinchi 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def on_transform_button_click(self, event):
        slice_startswith = self.slice_text.GetValue()
        template_path = self.get_template_path()
        response_body = self.GetParent().get_response_content()

        try:
            handler = Request2Doc()
            handler.set_slice_startswith(slice_startswith)
            handler.set_response_body(response_body)

            if not handler.get_response_data():
                return wx.MessageDialog(None, u'Response body is not legal format', u"Information", wx.OK | wx.ICON_INFORMATION).ShowModal()

            self.GetParent().set_document_content(handler.render_string(template_path))

        except Exception, e:
            return wx.MessageDialog(None, traceback.format_exc(), u"Exception", wx.OK | wx.ICON_ERROR).ShowModal()
about.py 文件源码 项目:pyjam 作者: 10se1ucgo 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def update_check(parent):
    """Check for updates using the GitHub API

    Args:
        parent (wx.Window): The parent window (for the message dialog)

    Returns:
        None
    """
    r = requests.get('https://api.github.com/repos/10se1ucgo/pyjam/releases/latest')

    if not r.ok:
        return

    new = r.json()['tag_name']

    try:
        if StrictVersion(__version__) < StrictVersion(new.lstrip('v')):
            info = wx.MessageDialog(parent, message="pyjam {v} is now available!\nGo to download page?".format(v=new),
                                    caption="pyjam Update", style=wx.OK | wx.CANCEL | wx.ICON_INFORMATION)
            if info.ShowModal() == wx.ID_OK:
                webbrowser.open_new_tab(r.json()['html_url'])
            info.Destroy()
    except ValueError:
        pass
downloader.py 文件源码 项目:pyjam 作者: 10se1ucgo 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def on_ok(self, event):
        songs = yt_extract(self.audio_links.GetValue().split(','))
        if not songs:
            error = wx.MessageDialog(parent=self,
                                     message="Invalid/Unsupported URL!",
                                     caption="Error!", style=wx.OK | wx.ICON_WARNING)
            error.ShowModal()
            error.Destroy()
            return

        self.num_songs = len(songs)

        self.progress_dialog = wx.ProgressDialog(title="Download", message="Downloading songs...",
                                                 maximum=self.num_songs * 100, parent=self, style=PD_STYLE)

        self.downloader = DownloaderThread(self, songs, self.out_dir.GetPath())
        self.downloader.start()
ffmpeg.py 文件源码 项目:pyjam 作者: 10se1ucgo 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def convert_complete(self, errors):
        if self.progress_dialog:
            self.converter.join()
            if errors:
                done_string = "Songs converted with {errors} error(s)".format(errors=len(errors))
            else:
                done_string = "All songs were converted succesfully!"
            done_message = wx.MessageDialog(parent=self, message=done_string, caption="pyjam")
            done_message.ToggleWindowStyle(wx.STAY_ON_TOP)
            done_message.ShowModal()
            done_message.Destroy()

            if errors:
                errors = '\n'.join(errors)
                error_dialog = wx.MessageDialog(parent=self, message="The following files caused errors\n" + errors,
                                                caption="Conversion Error!", style=wx.OK | wx.ICON_ERROR)
                error_dialog.ShowModal()
                error_dialog.Destroy()
                logger.critical("Error converting these files\n{errors}".format(errors=errors))

            logger.info(done_string)
            wx.CallAfter(self.progress_dialog.Destroy)
WPKG-GP-Client_phoenix.py 文件源码 项目:wpkg-gp-client 作者: sonicnkt 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def OnStartButton(self, e):
        if wpkg_running():
            dlg_msg = _(u"WPKG is currently running,\n"
                        u"please wait a few seconds and try again.")
            dlg = wx.MessageDialog(self, dlg_msg, app_name, wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return
        dlg_title = _(u"2. Warning")
        dlg_msg = _(u"Close all open programs!\n\nThe System could restart without further confirmation!\n\n" \
                    u"Continue?")
        dlg = wx.MessageDialog(self, dlg_msg, dlg_title, wx.YES_NO|wx.YES_DEFAULT|wx.ICON_EXCLAMATION)
        if dlg.ShowModal() == wx.ID_YES:
            dlg.Destroy()
            # Disable/enable buttons and disable Close Window option!
            self.startButton.Disable()
            self.abortButton.Enable()
            self.EnableCloseButton(enable=False)
            # Set Start Time
            self.wpkg_start_time = datetime.datetime.now()
            # Reset Log
            self.log = None
            startWorker(self.LongTaskDone, self.LongTask)
WPKG-GP-Client.py 文件源码 项目:wpkg-gp-client 作者: sonicnkt 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def OnStartButton(self, e):
        if wpkg_running():
            dlg_msg = _(u"WPKG is currently running,\n"
                        u"please wait a few seconds and try again.")
            dlg = wx.MessageDialog(self, dlg_msg, app_name, wx.OK | wx.ICON_EXCLAMATION)
            dlg.ShowModal()
            dlg.Destroy()
            return
        dlg_title = _(u"2. Warning")
        dlg_msg = _(u"Close all open programs!\n\nThe System could restart without further confirmation!\n\n" \
                    u"Continue?")
        dlg = wx.MessageDialog(self, dlg_msg, dlg_title, wx.YES_NO|wx.YES_DEFAULT|wx.ICON_EXCLAMATION)
        if dlg.ShowModal() == wx.ID_YES:
            dlg.Destroy()
            # Disable/enable buttons and disable Close Window option!
            self.startButton.Disable()
            self.abortButton.Enable()
            self.EnableCloseButton(enable=False)
            # Set Start Time
            self.wpkg_start_time = datetime.datetime.now()
            # Reset Log
            self.log = None
            startWorker(self.LongTaskDone, self.LongTask)
frame_main.py 文件源码 项目:Turrican2Editor 作者: GitExl 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def open(self, event):
        dialog = wx.DirDialog(self, 'Select a Turrican II CDTV directory', '', wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)
        if dialog.ShowModal() != wx.ID_OK:
            return

        directory = dialog.GetPath()
        test_files = ['L1-1', 'L2-1', 'L3-1', 'L4-1', 'L5-1', 'LOADER', 'MAIN']
        for filename in test_files:
            if not os.path.exists(os.path.join(directory, filename)):
                wx.MessageBox('Not a valid Turrican II CDTV directory.', 'Invalid directory', wx.OK | wx.ICON_EXCLAMATION)
                return

        self._game_dir = directory
        self._graphics = Graphics(self._game_dir)
        self.load_worlds()

        self.Entities.set_graphics(self._graphics)
        self.Entities.set_font(self._font)

        self.LevelSelect.SetSelection(0)
        self.select_level(0, 0)
        self.update_menu_state()
        self.update_title()
PLCOpenEditor.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def _init_coll_HelpMenu_Items(self, parent):
        AppendMenu(parent, help='', id=wx.ID_HELP,
                   kind=wx.ITEM_NORMAL, text=_(u'PLCOpenEditor') + '\tF1')
        # AppendMenu(parent, help='', id=wx.ID_HELP_CONTENTS,
        #      kind=wx.ITEM_NORMAL, text=u'PLCOpen\tF2')
        # AppendMenu(parent, help='', id=wx.ID_HELP_CONTEXT,
        #      kind=wx.ITEM_NORMAL, text=u'IEC 61131-3\tF3')

        def handler(event):
            return wx.MessageBox(
                version.GetCommunityHelpMsg(),
                _(u'Community support'),
                wx.OK | wx.ICON_INFORMATION)

        id = wx.NewId()
        parent.Append(help='', id=id, kind=wx.ITEM_NORMAL, text=_(u'Community support'))
        self.Bind(wx.EVT_MENU, handler, id=id)

        AppendMenu(parent, help='', id=wx.ID_ABOUT,
                   kind=wx.ITEM_NORMAL, text=_(u'About'))
        self.Bind(wx.EVT_MENU, self.OnPLCOpenEditorMenu, id=wx.ID_HELP)
        # self.Bind(wx.EVT_MENU, self.OnPLCOpenMenu, id=wx.ID_HELP_CONTENTS)
        self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT)
PLCOpenEditor.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def OnGenerateProgramMenu(self, event):
        dialog = wx.FileDialog(self, _("Choose a file"), os.getcwd(), self.Controler.GetProgramFilePath(),  _("ST files (*.st)|*.st|All files|*.*"), wx.SAVE | wx.CHANGE_DIR)
        if dialog.ShowModal() == wx.ID_OK:
            filepath = dialog.GetPath()
            message_text = ""
            header, icon = _("Done"), wx.ICON_INFORMATION
            if os.path.isdir(os.path.dirname(filepath)):
                program, errors, warnings = self.Controler.GenerateProgram(filepath)
                message_text += "".join([_("warning: %s\n") % warning for warning in warnings])
                if len(errors) > 0:
                    message_text += "".join([_("error: %s\n") % error for error in errors])
                    message_text += _("Can't generate program to file %s!") % filepath
                    header, icon = _("Error"), wx.ICON_ERROR
                else:
                    message_text += _("Program was successfully generated!")
            else:
                message_text += _("\"%s\" is not a valid folder!") % os.path.dirname(filepath)
                header, icon = _("Error"), wx.ICON_ERROR
            message = wx.MessageDialog(self, message_text, header, wx.OK | icon)
            message.ShowModal()
            message.Destroy()
        dialog.Destroy()
ArrayTypeDialog.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def GetDimensions(self):
        message = None
        dimensions_list = []
        dimension_strings = self.Dimensions.GetStrings()
        if len(dimension_strings) == 0:
            message = _("Empty dimension isn't allowed.")

        for dimensions in dimension_strings:
            result = DIMENSION_MODEL.match(dimensions)
            if result is None:
                message = _("\"%s\" value isn't a valid array dimension!") % dimensions
                break
            bounds = result.groups()
            if int(bounds[0]) >= int(bounds[1]):
                message = _("\"%s\" value isn't a valid array dimension!\nRight value must be greater than left value.") % dimensions
                break
            dimensions_list.append(bounds)

        if message is not None:
            dlg = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()
            dlg.Destroy()
            return None
        return dimensions_list
PouNameDialog.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def OnOK(self, event):
        message = None
        step_name = self.GetSizer().GetItem(1).GetWindow().GetValue()
        if step_name == "":
            message = _("You must type a name!")
        elif not TestIdentifier(step_name):
            message = _("\"%s\" is not a valid identifier!") % step_name
        elif step_name.upper() in IEC_KEYWORDS:
            message = _("\"%s\" is a keyword. It can't be used!") % step_name
        elif step_name.upper() in self.PouNames:
            message = _("A POU named \"%s\" already exists!") % step_name
        if message is not None:
            dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
            dialog.ShowModal()
            dialog.Destroy()
        else:
            self.EndModal(wx.ID_OK)
        event.Skip()
ProjectDialog.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __init__(self, parent, enable_required=True):
        wx.Dialog.__init__(self, parent, title=_('Project properties'),
                           style=wx.DEFAULT_DIALOG_STYLE)

        main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=10)
        main_sizer.AddGrowableCol(0)
        main_sizer.AddGrowableRow(0)

        self.ProjectProperties = ProjectPropertiesPanel(
            self,
            enable_required=enable_required)

        main_sizer.AddWindow(self.ProjectProperties, flag=wx.GROW)

        self.ButtonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE)
        self.Bind(wx.EVT_BUTTON, self.OnOK,
                  self.ButtonSizer.GetAffirmativeButton())
        main_sizer.AddSizer(self.ButtonSizer, border=20,
                            flag=wx.ALIGN_RIGHT | wx.BOTTOM | wx.LEFT | wx.RIGHT)

        self.SetSizer(main_sizer)
        self.ProjectProperties.Fit()
        self.Fit()


问题


面经


文章

微信
公众号

扫码关注公众号