python类OK的实例源码

SFCStepNameDialog.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 18 收藏 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
        elif step_name.upper() in self.Variables:
            message = _("A variable with \"%s\" as name already exists in this pou!") % step_name
        elif step_name.upper() in self.StepNames:
            message = _("\"%s\" step 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()
FolderTree.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def OnTreeEndLabelEdit(self, event):
        new_name = event.GetLabel()
        if new_name != "":
            old_filepath = self.GetPath(event.GetItem())
            new_filepath = os.path.join(os.path.split(old_filepath)[0], new_name)
            if new_filepath != old_filepath:
                if not os.path.exists(new_filepath):
                    os.rename(old_filepath, new_filepath)
                    event.Skip()
                else:
                    message = wx.MessageDialog(self,
                                               _("File '%s' already exists!") % new_name,
                                               _("Error"), wx.OK | wx.ICON_ERROR)
                    message.ShowModal()
                    message.Destroy()
                    event.Veto()
        else:
            event.Skip()
DebugVariableTextViewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def ShowMessage(self, message):
        """
        Show error message in Error Dialog
        @param message: Error message to display
        """
        dialog = wx.MessageDialog(self.ParentWindow,
                                  message,
                                  _("Error"),
                                  wx.OK | wx.ICON_ERROR)
        dialog.ShowModal()
        dialog.Destroy()


# -------------------------------------------------------------------------------
#                      Debug Variable Text Viewer Class
# -------------------------------------------------------------------------------
SFCViewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def AddInitialStep(self, pos):
        dialog = SFCStepNameDialog(self.ParentWindow, _("Please enter step name"), _("Add a new initial step"), "", wx.OK | wx.CANCEL)
        dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
        dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, debug=self.Debug))
        dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)])
        if dialog.ShowModal() == wx.ID_OK:
            id = self.GetNewId()
            name = dialog.GetValue()
            step = SFC_Step(self, name, True, id)
            min_width, min_height = step.GetMinSize()
            step.SetPosition(pos.x, pos.y)
            width, height = step.GetSize()
            step.SetSize(max(min_width, width), max(min_height, height))
            self.AddBlock(step)
            self.Controler.AddEditedElementStep(self.TagName, id)
            self.RefreshStepModel(step)
            self.RefreshBuffer()
            self.RefreshScrollBars()
            self.Refresh(False)
        dialog.Destroy()
SFCViewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def EditStepContent(self, step):
        if self.GetDrawingMode() == FREEDRAWING_MODE:
            Viewer.EditStepContent(self, step)
        else:
            dialog = SFCStepNameDialog(self.ParentWindow, _("Edit step name"), _("Please enter step name"), step.GetName(), wx.OK | wx.CANCEL)
            dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug))
            dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, debug=self.Debug))
            dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()])
            if dialog.ShowModal() == wx.ID_OK:
                value = dialog.GetValue()
                step.SetName(value)
                min_size = step.GetMinSize()
                size = step.GetSize()
                step.UpdateSize(max(min_size[0], size[0]), max(min_size[1], size[1]))
                step.RefreshModel()
                self.RefreshBuffer()
                self.RefreshScrollBars()
                self.Refresh(False)
            dialog.Destroy()

    # -------------------------------------------------------------------------------
    #                          Delete element functions
    # -------------------------------------------------------------------------------
Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def AddNewJump(self, bbox, wire=None):
        choices = []
        for block in self.Blocks.itervalues():
            if isinstance(block, SFC_Step):
                choices.append(block.GetName())
        dialog = wx.SingleChoiceDialog(self.ParentWindow,
                                       _("Add a new jump"),
                                       _("Please choose a target"),
                                       choices,
                                       wx.DEFAULT_DIALOG_STYLE | wx.OK | wx.CANCEL)
        if dialog.ShowModal() == wx.ID_OK:
            id = self.GetNewId()
            jump = SFC_Jump(self, dialog.GetStringSelection(), id)
            self.Controler.AddEditedElementJump(self.TagName, id)
            self.AddNewElement(jump, bbox, wire)
        dialog.Destroy()
Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def EditCommentContent(self, comment):
        dialog = wx.TextEntryDialog(self.ParentWindow,
                                    _("Edit comment"),
                                    _("Please enter comment text"),
                                    comment.GetContent(),
                                    wx.OK | wx.CANCEL | wx.TE_MULTILINE)
        width, height = comment.GetSize()
        dialogSize = wx.Size(max(width + 30, 400), max(height + 60, 200))
        dialog.SetClientSize(dialogSize)
        if dialog.ShowModal() == wx.ID_OK:
            value = dialog.GetValue()
            rect = comment.GetRedrawRect(1, 1)
            comment.SetContent(value)
            comment.SetSize(*self.GetScaledSize(*comment.GetSize()))
            rect = rect.Union(comment.GetRedrawRect())
            self.RefreshCommentModel(comment)
            self.RefreshBuffer()
            self.RefreshScrollBars()
            self.RefreshVisibleElements()
            comment.Refresh(rect)
        dialog.Destroy()

    # -------------------------------------------------------------------------------
    #                          Model update functions
    # -------------------------------------------------------------------------------
Viewer.py 文件源码 项目:beremiz 作者: nucleron 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def Paste(self, bbx=None):
        if not self.Debug:
            element = self.ParentWindow.GetCopyBuffer()
            if bbx is None:
                mouse_pos = self.Editor.ScreenToClient(wx.GetMousePosition())
                middle = wx.Rect(0, 0, *self.Editor.GetClientSize()).InsideXY(mouse_pos.x, mouse_pos.y)
                if middle:
                    x, y = self.CalcUnscrolledPosition(mouse_pos.x, mouse_pos.y)
                else:
                    x, y = self.CalcUnscrolledPosition(0, 0)
                new_pos = [int(x / self.ViewScale[0]), int(y / self.ViewScale[1])]
            else:
                middle = True
                new_pos = [bbx.x, bbx.y]
            result = self.Controler.PasteEditedElementInstances(self.TagName, element, new_pos, middle, self.Debug)
            if not isinstance(result, (StringType, UnicodeType)):
                self.RefreshBuffer()
                self.RefreshView(selection=result)
                self.RefreshVariablePanel()
                self.ParentWindow.RefreshPouInstanceVariablesPanel()
            else:
                message = wx.MessageDialog(self.Editor, result, "Error", wx.OK | wx.ICON_ERROR)
                message.ShowModal()
                message.Destroy()
email_win.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def on_button_email_passwd(self,event):# Button save email and password
        email=self.text_ctrl_email.Value
        passwd=self.text_ctrl_email_passwd.Value

        if not self.V.validate_email(email)[0]:
            msg="Invalid Email"
            dlg = wx.MessageDialog(self, msg, 'Error',wx.OK | wx.ICON_ERROR)                  
            dlg.ShowModal()
            dlg.Destroy()
            return 0
        self.DB.Set_SMS_Sender_Mail(email)
        self.DB.Set_SMS_Sender_Mail_Password(passwd)
        msg="Successfully Saved"
        dlg = wx.MessageDialog(self, msg, 'Success',wx.OK | wx.ICON_INFORMATION)                  
        dlg.ShowModal()
        dlg.Destroy()
email_win.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def validate_email(self):

        self.CHECK_LIST_ITEMS=[]

        sending_numbers=self.text_ctrl_selected_email.Value
        sending_numbers=sending_numbers.split(";")

        for email in sending_numbers:
            print email
            if not email:
                continue


            if self.V.validate_email(email)[0]:
                self.CHECK_LIST_ITEMS.append(email)

            else:
                #msg=email+" is invalid email id. Either edit or delete it to continue!"
                #dlg = wx.MessageDialog(self, msg, 'Error',wx.OK | wx.ICON_ERROR)                  
                #dlg.ShowModal()
                #dlg.Destroy()

                return 0

        return True
user_operations.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def Login_Check(self,user,password):

        print "login check"

        passw=self.EN.Encrypt_Password(self.Secret_Key+password)
        query="SELECT PASSWORD FROM USER WHERE USER='%s' AND PASSWORD='%s'" %(user,passw)  
        #self.DB.cur.execute(query,(user,self.Secret_Key+password,))
        self.DB.cur.execute(query)
        #self.DB.con.commit()

        row=self.DB.cur.fetchone()


        if row:


            return True
        else:
            dlg = wx.MessageDialog(self.parent, 'Incorrect Password', '',wx.OK | wx.ICON_INFORMATION)                  
            dlg.ShowModal()
            dlg.Destroy()

            return False
user_operations.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def validate_pass(self):

        if not self.UO.Login_Check(self.combo_box_1.Value,self.text_ctrl_1.Value):
            return False

        if len(self.text_ctrl_2.Value)<5:
            dlg = wx.MessageDialog(self, 'Password must be of at least five characters', '',wx.OK | wx.ICON_ERROR)                  
            dlg.ShowModal()
            dlg.Destroy()
            return False
        if self.text_ctrl_2.Value!=self.text_ctrl_3.Value:
            dlg = wx.MessageDialog(self, 'Passwords do not match', '',wx.OK | wx.ICON_ERROR)                  
            dlg.ShowModal()
            dlg.Destroy()
            return False

        return True
sms_win.py 文件源码 项目:smartschool 作者: asifkodur 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def __init__(self, *args, **kwds):
        # begin wxGlade: MyDialog.__init__
        #args[
        kwds["style"] = wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP
        wx.Dialog.__init__(self, *args, **kwds)
        self.text_ctrl_passwd = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_PASSWORD)
        self.button_cancel = wx.Button(self, wx.ID_ANY, _("Cancel"))
        self.button_ok = wx.Button(self, wx.ID_ANY, _("OK"))

        self.__set_properties()
        self.__do_layout()

        self.password_text=''
        self.Bind(wx.EVT_TEXT, self.on_passwod, self.text_ctrl_passwd)
        self.Bind(wx.EVT_BUTTON, self.on_button_cancel, self.button_cancel)
        self.Bind(wx.EVT_BUTTON, self.on_button_ok, self.button_ok)
        self.cancelled=False
        # end wxGlade
main.py 文件源码 项目:pyupdater-wx-demo 作者: wettenhj 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def OnInit(self):
        """
        Run automatically when the wxPython application starts.
        """
        self.frame = wx.Frame(None, title="PyUpdater wxPython Demo")
        self.frame.Bind(wx.EVT_CLOSE, self.OnCloseFrame)
        self.frame.SetSize(wx.Size(400, 100))
        self.statusBar = wx.StatusBar(self.frame)
        self.statusBar.SetStatusText(self.status)
        self.frame.SetStatusBar(self.statusBar)
        self.panel = wx.Panel(self.frame)
        self.sizer = wx.BoxSizer()
        self.sizer.Add(
            wx.StaticText(self.frame, label="Version %s" % __version__))
        self.panel.SetSizerAndFit(self.sizer)

        self.frame.Show()

        if hasattr(sys, "frozen") and \
                not os.environ.get('PYUPDATER_FILESERVER_DIR'):
            dlg = wx.MessageDialog(
                self.frame,
                "The PYUPDATER_FILESERVER_DIR environment variable "
                "is not set!", "PyUpdaterWxDemo File Server Error",
                wx.OK | wx.ICON_ERROR)
            dlg.ShowModal()

        return True
action_menu_pcb2dxf.py 文件源码 项目:kicad-action-plugins 作者: easyw 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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)
recipe-578681.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def Error(self, dialog):
        wx.MessageBox(dialog , 'Info', 
            wx.OK | wx.ICON_INFORMATION)
recipe-286201.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
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
recipe-286201.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
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)
recipe-286201.py 文件源码 项目:code 作者: ActiveState 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
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)
EyePicker.py 文件源码 项目:nimo 作者: wolfram2012 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def onAbout(self,event):
        dlg = wx.MessageDialog(self,message="For more information visit:\n\nhttp://pyvision.sourceforge.net",style = wx.OK )
        result = dlg.ShowModal()


问题


面经


文章

微信
公众号

扫码关注公众号