Python wx 模块,MessageBox() 实例源码

我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用wx.MessageBox()

项目:cebl    作者:idfah    | 项目源码 | 文件源码
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()
项目:Pigrow    作者:Pragmatismo    | 项目源码 | 文件源码
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    作者:Pragmatismo    | 项目源码 | 文件源码
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))
项目:Supplicant    作者:mayuko2012    | 项目源码 | 文件源码
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()
项目:Supplicant    作者:mayuko2012    | 项目源码 | 文件源码
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)
项目:Turrican2Editor    作者:GitExl    | 项目源码 | 文件源码
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()
项目:Turrican2Editor    作者:GitExl    | 项目源码 | 文件源码
def close(self, event):
        if not self._world:
            event.Skip()
            return

        modified = False
        for level in self._world.levels:
            modified = modified | level.modified

        if modified:
            result = wx.MessageBox('Do you want to save your changes?', 'Unsaved changes', wx.YES_NO | wx.CANCEL | wx.ICON_EXCLAMATION)
            if result == wx.YES:
                self._world.save()
            elif result == wx.CANCEL:
                return

        event.Skip()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
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)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def open_pdf(pdffile, pagenum=None):
    if wx.Platform == '__WXMSW__':
        try:
            readerpath = get_acroversion()
        except Exception:
            wx.MessageBox("Acrobat Reader is not found or installed !")
            return None

        readerexepath = os.path.join(readerpath, "AcroRd32.exe")
        if(os.path.isfile(readerexepath)):
            open_win_pdf(readerexepath, pdffile, pagenum)
        else:
            return None
    else:
        readerexepath = os.path.join("/usr/bin", "xpdf")
        if(os.path.isfile(readerexepath)):
            open_lin_pdf(readerexepath, pdffile, pagenum)
        else:
            wx.MessageBox("xpdf is not found or installed !")
            return None
项目:multiplierz    作者:BlaisProteomics    | 项目源码 | 文件源码
def Validate(self, win):
        tc = self.GetWindow()
        val = tc.GetValue()
        nm = tc.GetName()

        try:
            v = self.func(val)
            if self.flag and v <= 0.0:
                wx.MessageBox("%s must be positive" % nm, "Error")
            elif v < 0.0:
                wx.MessageBox("%s must be non-negative" % nm, "Error")
            else:
                tc.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW))
                tc.Refresh()
                return True
        except ValueError:
            wx.MessageBox("%s is not a valid number" % nm, "Error")

        tc.SetBackgroundColour("YELLOW")
        tc.Clear()
        tc.SetFocus()
        tc.Refresh()
        return False
项目:multiplierz    作者:BlaisProteomics    | 项目源码 | 文件源码
def alerts(message='multiplierz', title='multiplierz', method='popup'):
    """Alert system for displaying popup or writing message to a file

    Available methods equal 'popup' or 'file'.
    If a file type method is chosen, the title represents the file name and location.

    Example:
    >> alerts('popup', 'Test', 'Hello. The test worked. Please click OK.')

    """

    message = str(message)
    title = str(title)
    if method == 'popup':
        try:
            wx.MessageBox(message, title)
        except wx._core.PyNoAppError:
            app = mzApp()
            app.launch()
            wx.MessageBox(message, title)
    elif method == 'file':
        fh = open(title,'w')
        fh.write(message)
        fh.close()
项目:wxpythoncookbookcode    作者:driscollis    | 项目源码 | 文件源码
def onShorten(self, event):
        """
        Shortens a URL using the service specified.
        Then sets the text control to the new URL.
        """
        text = self.inputURLTxt.GetValue()
        textLength = len(text)

        if re.match("^https?://[^ ]+", text) and textLength > 20:
            pass
        else:
            wx.MessageBox("URL is already tiny!", "Error")
            return

        URL = self.URLCbo.GetValue()
        if URL == "is.gd":
            self.shortenWithIsGd(text)
        elif URL == "bit.ly":
            self.shortenWithBitly(text)
        elif URL == "tinyurl":
            self.shortenWithTinyURL(text)
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def on_new_rocktable(event):
    OM = ObjectManager(event.GetEventObject())
    rocktable_dlg = RockTableEditor.NewRockTableDialog(wx.App.Get().GetTopWindow())
    try:
        if rocktable_dlg.ShowModal() == wx.ID_OK:
#            wx.MessageBox('It was created a partition.')
            name = rocktable_dlg.get_value()
            print 'name', name, type(str(name)), str(name).strip(''), str(name).strip()
            if name == '': name = 'Table'
            rock = OM.new('rocktable', name = name)
#            partition_dlg.Destroy()        
            OM.add(rock)
    except Exception as e:
        print 'ERROR:', e
    finally:
        rocktable_dlg.Destroy()
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def on_edit_rocktable(event):
    OM = ObjectManager(event.GetEventObject())
    if not OM.list('rocktable'):
        try:
            wx.MessageBox('Please create a new Rock Table first!')
        except Exception as e:
            print 'ERROR:', e
        finally:
            return

    dlg = RockTableEditor.Dialog(wx.App.Get().GetTopWindow())
    dlg.ShowModal()
    dlg.Destroy()

    _UIM = UIManager()
    tree_ctrl = _UIM.list('tree_controller')[0]
    tree_ctrl.refresh()
项目:GRIPy    作者:giruenf    | 项目源码 | 文件源码
def on_new_partition(event):
    OM = ObjectManager(event.GetEventObject())
    partition_dlg = PartitionEditor.NewPartitionDialog(wx.App.Get().GetTopWindow())
    try:
        if partition_dlg.ShowModal() == wx.ID_OK:
#            wx.MessageBox('It was created a partition.')
            name = partition_dlg.get_value()
            print 'name', name, type(str(name)), str(name).strip(''), str(name).strip()
            if name == '': name = 'NEW'
            rock = OM.new('partition', name = name)
#            partition_dlg.Destroy()        
            OM.add(rock)
    except Exception as e:
        print 'ERROR:', e
    finally:
        partition_dlg.Destroy()
项目:kicad-action-plugins    作者:easyw    | 项目源码 | 文件源码
def Run( self ):
        fileName = GetBoard().GetFileName()
        if len(fileName)==0:
            wx.LogMessage("a board needs to be saved/loaded!")
        else:
            dirpath = os.path.abspath(os.path.expanduser(fileName))
            path, fname = os.path.split(dirpath)
            ext = os.path.splitext(os.path.basename(fileName))[1]
            name = os.path.splitext(os.path.basename(fileName))[0]

            LogMsg="reading from "+ dirpath
            out_filename=path+os.sep+name+".dxf"
            LogMsg+="writing to "+out_filename
            content=[]
            txtFile = open(fileName,"r")
            content = txtFile.readlines()
            content.append(" ")
            txtFile.close()

            #wx.MessageDialog(None, 'This is a message box. ONLY TEST!', 'Test', wx.OK | wx.ICON_INFORMATION).ShowModal()
            #wx.MessageDialog(None, 'This is a message box. ONLY TEST!', content, wx.OK | wx.ICON_INFORMATION).ShowModal()
            #found_selected=False
            #board = pcbnew.GetBoard()

            dlg=wx.MessageBox( 'Only SAVED board file will be exported to DXF file', 'Confirm',  wx.OK | wx.CANCEL | wx.ICON_INFORMATION )
            if dlg == wx.OK:
                if os.path.isfile(out_filename):
                    dlg=wx.MessageBox( 'Overwrite DXF file?', 'Confirm', wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION )
                    if dlg == wx.YES:
                        export_dxf(content, out_filename)
                else:
                    export_dxf(content, out_filename)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def Error(self, dialog):
        wx.MessageBox(dialog , 'Info', 
            wx.OK | wx.ICON_INFORMATION)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def onSendFailed(self, reason, line):
        """Called if a send failed"""
        wx.MessageBox(str(reason), 'Could not send %s' % line, wx.OK|wx.ICON_ERROR, self)

    # Event handlers for net framework
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def onServerFailed(self, reason):
        """Called if the server can't listen"""
        self.btnListen.SetValue(False)
        wx.MessageBox(reason, 'Server Failed', wx.OK|wx.ICON_ERROR, self)
        self.GetStatusBar().SetStatusText('Server failed: %s' % reason)
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def onClientFailed(self, reason):
        self.btnConnect.SetValue(False)
        wx.MessageBox(str(reason), 'Client Connection Failed', wx.OK|wx.ICON_ERROR, self)
        self.GetStatusBar().SetStatusText('Client Connection Failed: %s' % reason)
项目:pyqha    作者:mauropalumbo75    | 项目源码 | 文件源码
def OnOpenEtotV(self, event):
        wildcard =  "dat file (*.dat)|*.dat|" \
                    "All files (*)|*"
        dialog = wx.FileDialog(None, "Choose a file with total energies", os.getcwd(),"", wildcard)
        if dialog.ShowModal() == wx.ID_OK:
            try:
                fname = dialog.GetPath()
                self.V, self.E = read_EtotV(fname)   
                self.IsEtotVRead = True
                self.SetStatusText("E_tot(V) file "+fname+" read")
            except:
                wx.MessageBox("Something wrong while opening the E_tot file... not loaded.",
                "", wx.OK | wx.ICON_EXCLAMATION, self)  

        dialog.Destroy()
项目:pyqha    作者:mauropalumbo75    | 项目源码 | 文件源码
def OnFitisoEtot(self, event):
        try:

            self.a, self.cov, self.chi = fit_Murn(self.V,self.E)
            print_eos_data(self.V,self.E,self.a,self.chi,"Etot")

            fig1 = plot_EV(self.V,self.E,self.a)                    # plot the E(V) data and the fitting line
            fig1.savefig("figure_1.png")

        except:
            wx.MessageBox("Something wrong while fitting total energies...",
                "", wx.OK | wx.ICON_EXCLAMATION, self)
项目:pyqha    作者:mauropalumbo75    | 项目源码 | 文件源码
def OnFitanisoEtot(self, event):
        try:
            wx.MessageBox("Not implemented yet...",
                "", wx.OK | wx.ICON_EXCLAMATION, self)  

        except:
            wx.MessageBox("Something wrong while fitting total energies...",
                "", wx.OK | wx.ICON_EXCLAMATION, self)
项目:pyqha    作者:mauropalumbo75    | 项目源码 | 文件源码
def OnHelp(self, event):
        wx.MessageBox("A program to perform quasi-harmonic calculations based on the pyqha module",
        "Help Contents", wx.OK | wx.ICON_INFORMATION, self)
项目:pyqha    作者:mauropalumbo75    | 项目源码 | 文件源码
def OnAbout(self, event):
        wx.MessageBox("pyqhaGUI: a program to perform quasi-harmonic calculations",
        "About pyQHA", wx.OK | wx.ICON_INFORMATION, self)
项目:FestEngine    作者:Himura2la    | 项目源码 | 文件源码
def on_ok(self, e):
        self.session_file_path = self.session_picker.GetPath()
        if not self.session_file_path:
            wx.MessageBox(_("Please specify the Current Fest file."), "No Fest File", wx.OK | wx.ICON_ERROR, self)
            return

        self.config[Config.PROJECTOR_SCREEN] = self.screens_combobox.GetSelection()
        self.config[Config.FILENAME_RE] = self.filename_re.GetValue()
        self.config[Config.BG_TRACKS_DIR] = self.bg_tracks.GetPath()
        self.config[Config.BG_ZAD_PATH] = self.bg_zad.GetPath()
        self.config[Config.FILES_DIRS] = [picker.GetPath() for picker in self.dir_pickers]

        self.EndModal(e.Id)
项目:fritzchecksum    作者:mementum    | 项目源码 | 文件源码
def OnButtonSave(self, msg):
        if not self.model.status:
            wx.MessageBox('No export file has been successfully loaded yet!')
            return

        ret = wx.MessageBox('Overwrite the original file?', 'Attention!',
                            wx.YES_NO | wx.ICON_QUESTION)

        if ret == wx.YES:
            self.model.save(self.fileread.path)
项目:fritzchecksum    作者:mementum    | 项目源码 | 文件源码
def OnButtonSaveAs(self, msg):
        if not self.model.status:
            wx.MessageBox('No export file has been successfully loaded yet!')
            return

        dialog = wx.FileDialog(
            self, 'Save As ...', style=wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)

        result = dialog.ShowModal()
        if result != wx.ID_OK:
            return

        # Show filedialog and get value
        self.model.save(dialog.GetPath())
项目:fritzchecksum    作者:mementum    | 项目源码 | 文件源码
def On_ModelLoaded(self, msg):
        ret, error = msg

        if not ret:
            wx.MessageBox(str(error), 'An error happened')
            return

        self.crcold.value = self.model.crcold
        self.crcnew.value = self.model.crcnew
项目:fritzchecksum    作者:mementum    | 项目源码 | 文件源码
def On_ModelSaved(self, msg):
        ret, error = msg

        if not ret:
            wx.MessageBox(str(error), 'An error happened!')
            return

        wx.MessageBox('File saved!', 'File Saved!')
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def trainTDENet(self, segs):
        trainData = [seg.data for seg in segs]

        convs = ((25,7),) # first session
        maxIter = 400

        nHidden = None
        poolSize = 1
        poolMethod = 'average'

        self.stand = ml.ClassSegStandardizer(trainData)
        trainDataStd = self.stand.apply(trainData)

        dialog = wx.ProgressDialog('Training Classifier',
                                   'Featurizing', maximum=maxIter+2,
                                   style=wx.PD_ELAPSED_TIME | wx.PD_SMOOTH)

        def progressCB(optable, iteration, *args, **kwargs):
            dialog.Update(iteration, 'Iteration: %d/%d' % (iteration, maxIter))

        self.classifier = ml.CNA(trainDataStd, convs=convs, nHidden=nHidden, maxIter=maxIter,
                                 optimFunc=ml.optim.scg, accuracy=0.0, precision=0.0,
                                 poolSize=poolSize, poolMethod=poolMethod,
                                 verbose=False, callback=progressCB)

        trainCA = self.classifier.ca(trainDataStd)
        trainConfusion = np.round(100*self.classifier.confusion(trainDataStd))

        dialog.Destroy()

        resultText = (('Final Training CA: %f\n' % trainCA) +
                      ('Confusion Matrix:\n' + str(trainConfusion) + '\n') +
                      ('Choices: ' + str(self.choices)))

        wx.MessageBox(message=resultText,
                      caption='Training Completed!',
                      style=wx.OK | wx.ICON_INFORMATION)

        self.saveResultText(resultText)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def trainConvNet(self, segs):
        trainData = [seg.data for seg in segs]

        #convs = ((16,9), (8,9))
        #maxIter = 400 # 49
        convs = ((8,3), (8,3), (8,3))
        maxIter = 1000

        nHidden = None
        poolSize = 1
        poolMethod = 'average'

        self.stand = ml.ClassSegStandardizer(trainData)
        trainDataStd = self.stand.apply(trainData)

        dialog = wx.ProgressDialog('Training Classifier',
                                   'Featurizing', maximum=maxIter+2,
                                   style=wx.PD_ELAPSED_TIME | wx.PD_SMOOTH)

        def progressCB(optable, iteration, *args, **kwargs):
            dialog.Update(iteration, 'Iteration: %d/%d' % (iteration, maxIter))

        self.classifier = ml.CNA(trainDataStd, convs=convs, nHidden=nHidden, maxIter=maxIter,
                                 optimFunc=ml.optim.scg, accuracy=0.0, precision=0.0,
                                 poolSize=poolSize, poolMethod=poolMethod,
                                 verbose=False, callback=progressCB)

        trainCA = self.classifier.ca(trainDataStd)
        trainConfusion = np.round(100*self.classifier.confusion(trainDataStd))

        dialog.Destroy()

        resultText = (('Final Training CA: %f\n' % trainCA) +
                      ('Confusion Matrix:\n' + str(trainConfusion) + '\n') +
                      ('Choices: ' + str(self.choices)))

        wx.MessageBox(message=resultText,
                      caption='Training Completed!',
                      style=wx.OK | wx.ICON_INFORMATION)

        self.saveResultText(resultText)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def trainKNN(self, classData, dialog, metric):
        ks = np.arange(1,10)

        trainAUC = np.zeros(ks.shape)
        validAUC = np.zeros(ks.shape)

        partitionGenerator = ml.part.classRandomSubSample(classData,
                self.trainFrac, self.nFold)

        for fold, trainData, validData in partitionGenerator:
            dialog.Update(fold, 'Validation Fold: %d' % fold)

            for i, k in enumerate(ks):
                classifier = ml.KNN(trainData, k=k, distMetric=metric)

                trainAUC[i] += classifier.auc(trainData)
                validAUC[i] += classifier.auc(validData)

        dialog.Update(self.nFold, 'Training Final Classifier')

        trainAUC /= self.nFold
        validAUC /= self.nFold

        print 'train AUC: ', trainAUC
        print 'valid AUC: ', validAUC

        bestK = ks[np.argmax(validAUC)]
        print 'best K: ', bestK

        self.classifier = ml.KNN(classData, k=bestK, distMetric=metric)

        finalAUC = self.classifier.auc(classData)

        dialog.Destroy()

        wx.MessageBox(message=('Best K: %d\n' % bestK) + \
            ('Mean Validation AUC: %f\n' % np.max(validAUC)) +
            ('Final Training AUC: %f' % finalAUC),
            caption='Training Completed!', style=wx.OK | wx.ICON_INFORMATION)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def trainKNN(self, classData, dialog, metric):
        ks = np.arange(1,10)

        trainAUC = np.zeros(ks.shape)
        validAUC = np.zeros(ks.shape)

        partitionGenerator = ml.part.classRandomSubSample(classData,
                self.trainFrac, self.nFold)

        for fold, trainData, validData in partitionGenerator:
            dialog.Update(fold, 'Validation Fold: %d' % fold)

            for i, k in enumerate(ks):
                classifier = ml.KNN(trainData, k=k, distMetric=metric)

                trainAUC[i] += classifier.auc(trainData)
                validAUC[i] += classifier.auc(validData)

        dialog.Update(self.nFold, 'Training Final Classifier')

        trainAUC /= self.nFold
        validAUC /= self.nFold

        print 'train AUC: ', trainAUC
        print 'valid AUC: ', validAUC

        bestK = ks[np.argmax(validAUC)]
        print 'best K: ', bestK

        self.classifier = ml.KNN(classData, k=bestK, distMetric=metric)

        finalAUC = self.classifier.auc(classData)

        dialog.Destroy()

        wx.MessageBox(message=('Best K: %d\n' % bestK) + \
            ('Mean Validation AUC: %f\n' % np.max(validAUC)) +
            ('Final Training AUC: %f' % finalAUC),
            caption='Training Completed!', style=wx.OK | wx.ICON_INFORMATION)
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def afterTest(self, earlyStop):
        if not earlyStop:
            self.saveCap()
            ca = np.mean(np.diag(self.confusion))/self.nTestTrial
            wx.MessageBox(('Test CA: %f\n' % ca) +
                           'Confusion Matrix:\n' + str(self.confusion/self.nTestTrial),
                           'Testing Complete', wx.OK | wx.ICON_INFORMATION)
项目:PancakeViewer    作者:forensicmatt    | 项目源码 | 文件源码
def OnDropFiles(self, x, y, filenames):
        wx.MessageBox(
            u"Items Added:\n{}".format("\n".join(filenames)), #message
            u'Evidence Dropped', #title
            wx.OK | wx.ICON_INFORMATION
        )
        for filename in filenames:
            self.window.EnumerateSource(
                filename
            )

        pass
项目:kicad_scripts    作者:NilujePerchut    | 项目源码 | 文件源码
def onProcessAction(self, event):
        """Executes the requested action"""
        if self.rbx_action.GetSelection() == 0:
            count = SetTeardrops(self.sp_hpercent.GetValue(),
                                 self.sp_vpercent.GetValue(),
                                 self.sp_nbseg.GetValue(),
                                 self.board)
            wx.MessageBox("{0} Teardrops inserted".format(count))
        else:
            count = RmTeardrops(pcb=self.board)
            wx.MessageBox("{0} Teardrops removed".format(count))
        self.Destroy()
项目:Pigrow    作者:Pragmatismo    | 项目源码 | 文件源码
def ok_click(self, e):
        # check for changes to cron
        if self.cron_lamp_on.GetLabel() == "not found" or self.cron_lamp_off.GetLabel() == "not found":
            mbox = wx.MessageDialog(None, "Add new job to cron?", "Are you sure?", wx.YES_NO|wx.ICON_QUESTION)
            sure = mbox.ShowModal()
            if sure == wx.ID_YES:
                if self.cron_lamp_on.GetLabel() == "not found":
                    cron_task = "/home/pi/Pigrow/scripts/switches/" + "lamp_on.py"
                    MainApp.cron_info_pannel.add_to_onetime_list("new", "True", self.new_on_string_text.GetLabel(), cron_task)
                if self.cron_lamp_off.GetLabel() == "not found":
                    cron_task = "/home/pi/Pigrow/scripts/switches/" + "lamp_off.py"
                    MainApp.cron_info_pannel.add_to_onetime_list("new", "True", self.new_off_string_text.GetLabel(), cron_task)
                    MainApp.cron_info_pannel.update_cron_click("e")
        elif not self.new_on_string_text.GetLabel() == self.cron_lamp_on.GetLabel() or not self.new_off_string_text.GetLabel() == self.cron_lamp_off.GetLabel():
            print(":" + self.new_on_string_text.GetLabel() + ":")
            print(":" + self.cron_lamp_on.GetLabel() + ":")
            mbox = wx.MessageDialog(None, "Update cron timing?", "Are you sure?", wx.YES_NO|wx.ICON_QUESTION)
            sure = mbox.ShowModal()
            result_on = 'done'  # these are for cases when only one is changed
            result_off = 'done' # if it attempts to update cron and fails it'll change to an error message
            if sure == wx.ID_YES:
                if not self.new_on_string_text.GetLabel() == self.cron_lamp_on.GetLabel():
                    result_on = self.change_cron_trigger("lamp_on.py", self.new_on_string_text.GetLabel())
                if not self.new_off_string_text.GetLabel() == self.cron_lamp_off.GetLabel():
                    result_off = self.change_cron_trigger("lamp_off.py", self.new_off_string_text.GetLabel())
                if result_on != "done" or result_off != "done":
                    wx.MessageBox('Cron update error, edit lamp switches in the cron pannel', 'Info', wx.OK | wx.ICON_INFORMATION)
                else:
                    MainApp.cron_info_pannel.update_cron_click("e")

        # check for changes to settings file

        time_lamp_on = str(self.on_hour_spin.GetValue()) + ":" + str(self.on_min_spin.GetValue())
        time_lamp_off = str(self.off_hour_spin.GetValue()) + ":" + str(self.off_min_spin.GetValue())
        if not MainApp.config_ctrl_pannel.config_dict["time_lamp_on"] == time_lamp_on or not MainApp.config_ctrl_pannel.config_dict["time_lamp_off"] == time_lamp_off:
            MainApp.config_ctrl_pannel.config_dict["time_lamp_on"] = time_lamp_on
            MainApp.config_ctrl_pannel.config_dict["time_lamp_off"] = time_lamp_off
            MainApp.config_ctrl_pannel.update_setting_click("e")
            MainApp.config_ctrl_pannel.update_config_click("e")
        self.Destroy()
项目:Pigrow    作者:Pragmatismo    | 项目源码 | 文件源码
def set_new_gpio_link(self, e):
        #get data from combo boxes.
        unused_gpio = self.list_unused_gpio(self.list_used_gpio())
        config_ctrl_pnl.device_new = self.devices_combo.GetValue()
        config_ctrl_pnl.gpio_new = self.gpio_tc.GetValue()
        config_ctrl_pnl.wiring_new = self.wiring_combo.GetValue()
        #check to see if info is valid and closes if it is
        should_close = True
        # check if device is set
        if config_ctrl_pnl.device_new == "":
            wx.MessageBox('Select a device to link from the list', 'Error', wx.OK | wx.ICON_INFORMATION)
            should_close = False
        #check if gpio number is valid
        if not config_ctrl_pnl.gpio_new == config_ctrl_pnl.gpio_toedit or config_ctrl_pnl.gpio_toedit == "":
            if not config_ctrl_pnl.gpio_new in unused_gpio and should_close == True:
                wx.MessageBox('Select a valid and unused gpio pin', 'Error', wx.OK | wx.ICON_INFORMATION)
                config_ctrl_pnl.gpio_new = self.gpio_tc.SetValue("")
                should_close = False
        # check if wiring direction is set to a valid setting
        if not config_ctrl_pnl.wiring_new == "low" and should_close == True:
            if not config_ctrl_pnl.wiring_new == "high":
                wx.MessageBox("No wiring direction set, \nIf you don't know guess and change it if the device turns on when it should be off", 'Error', wx.OK | wx.ICON_INFORMATION)
                should_close = False
        # if box should be closed then close it
        if should_close == True:
            #checks to see if changes have been made and updates ui if so
            if not config_ctrl_pnl.device_new == config_ctrl_pnl.device_toedit:
                config_ctrl_pnl.currently_new = 'unlinked'
            else:
                if not config_ctrl_pnl.gpio_new == config_ctrl_pnl.gpio_toedit:
                    config_ctrl_pnl.currently_new = 'unlinked'
                else:
                    if not config_ctrl_pnl.wiring_new == config_ctrl_pnl.wiring_toedit:
                        config_ctrl_pnl.currently_new = 'unlinked'
                    else:
                        config_ctrl_pnl.currently_new = config_ctrl_pnl.currently_toedit
            self.Destroy()
项目:Pigrow    作者:Pragmatismo    | 项目源码 | 文件源码
def show_help(self, e):
        script_path = self.cron_path_combo.GetValue()
        script_name = self.cron_script_cb.GetValue()
        helpfile = self.get_help_text(str(script_path + script_name))
        msg_text =  script_name + ' \n \n'
        msg_text += str(helpfile)
        wx.MessageBox(msg_text, 'Info', wx.OK | wx.ICON_INFORMATION)
项目:Supplicant    作者:mayuko2012    | 项目源码 | 文件源码
def OnDisconnect(self, event):
        msgbox = wx.MessageDialog(None, "",u'???????',wx.YES_NO | wx.ICON_QUESTION)
        ret = msgbox.ShowModal()
        if (ret == wx.ID_YES):
            self.StopThreads()
            wx.MessageBox( u"??????",u'\n??????????')
            sys.exit()
项目:Supplicant    作者:mayuko2012    | 项目源码 | 文件源码
def OnAbout(self, event):
        wx.MessageBox(u"????????\n??????????hack?????????",u"??", wx.OK | wx.ICON_INFORMATION, self)
项目:magic-card-database    作者:drknotter    | 项目源码 | 文件源码
def OnEditorShown(self, evt):
        if evt.GetRow() == 6 and evt.GetCol() == 3 and \
           wx.MessageBox("Are you sure you wish to edit this cell?",
                        "Checking", wx.YES_NO) == wx.NO:
            evt.Veto()
            return

        print "OnEditorShown: (%d,%d) %s\n" % (evt.GetRow(), evt.GetCol(), evt.GetPosition())
        evt.Skip()
项目:magic-card-database    作者:drknotter    | 项目源码 | 文件源码
def OnEditorHidden(self, evt):
        if evt.GetRow() == 6 and evt.GetCol() == 3 and \
           wx.MessageBox("Are you sure you wish to  finish editing this cell?",
                        "Checking", wx.YES_NO) == wx.NO:
            evt.Veto()
            return

        print "OnEditorHidden: (%d,%d) %s\n" % (evt.GetRow(), evt.GetCol(), evt.GetPosition())
        evt.Skip()
项目:python_2048    作者:OATOMO    | 项目源码 | 文件源码
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()
项目:Turrican2Editor    作者:GitExl    | 项目源码 | 文件源码
def update_status(self):
        bytes_left = self._level.get_entity_bytes_left()
        if bytes_left < 0:
            self.Status.SetStatusText('No entity bytes left!', 0)
            wx.MessageBox('There is no more room for entities. Delete entities or move entites to create empty blockmap blocks to free up more room. This level cannot be saved until enough room is made available.', 'No more room for entities', wx.ICON_EXCLAMATION | wx.OK)
        else:
            self.Status.SetStatusText('{} entity bytes left'.format(bytes_left), 0)
项目:Turrican2Editor    作者:GitExl    | 项目源码 | 文件源码
def save(self):
        stream = StreamWrite.from_file(self._filename, Endianness.BIG)
        levels_not_saved = 0

        for level_index, level in enumerate(self._levels):
            if level.modified:

                if not level.can_save():
                    levels_not_saved += 1
                    continue

                # Write entities first.
                level.write_entities(stream)

                # Save level data.
                if level_index == 0:
                    level.save(stream)
                else:
                    filename = 'L{}-{}'.format(self._world_index + 1, level_index + 1)
                    game_dir = os.path.dirname(self._filename)
                    filename = os.path.join(game_dir, filename)

                    level_stream = StreamWrite.from_file(filename, Endianness.BIG)

                    if self._world_index == 2 and level_index == 1:
                        offset = 19620
                    else:
                        offset = 0
                    level.save(level_stream, offset)
                    level_stream.write_to_file(filename)

                # Save level header.
                stream.seek(self._level_offsets[level_index])
                level.save_header(stream)
                level.modified = False

        stream.write_to_file(self._filename)

        if levels_not_saved:
            wx.MessageBox('{} level(s) could not be saved.'.format(levels_not_saved), 'Levels not saved', wx.ICON_INFORMATION | wx.OK)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def OnPLCOpenEditorMenu(self, event):
        wx.MessageBox(_("No documentation available.\nComing soon."))
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def OnLinkClick(self, event):
            url = event.linkinfo[0]
            try:
                if wx.Platform == '__WXMSW__':
                    import webbrowser
                    webbrowser.open(url)
                elif subprocess.call("firefox %s" % url, shell=True) != 0:
                    wx.MessageBox("""Firefox browser not found.\nPlease point your browser at :\n%s""" % url)
            except ImportError:
                wx.MessageBox('Please point your browser at: %s' % url)