Python wx 模块,ID_OK 实例源码

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

项目:mobileinsight-core    作者:mobile-insight    | 项目源码 | 文件源码
def Open(self, e):
        openFileDialog = wx.FileDialog(
            self,
            "Open Log file",
            "",
            "",
            "log files (*.mi2log) |*.mi2log| All files |*.*",
            wx.FD_OPEN | wx.FD_FILE_MUST_EXIST | wx.FD_MULTIPLE)
        if (openFileDialog.ShowModal() == wx.ID_OK):
            # print 'Selected %s' %openFileDialog.GetPath()
            print 'Selected %s' % openFileDialog.Paths
            try:
                self.grid.ClearGrid()

                # thread.start_new_thread(openFile,(openFileDialog.GetPath(),))
                # t = Thread(target = self.openFile, args=(openFileDialog.GetPath(),self.selectedTypes))
                t = Thread(
                    target=self.openFile,
                    args=(
                        openFileDialog.Paths,
                        self.selectedTypes))
                self.progressDialog = ProgressDialog(self)
                t.start()
                self.progressDialog.ShowModal()

                if len(openFileDialog.Paths) == 1:
                    self.SetTitle(openFileDialog.GetPath())
                else:
                    self.SetTitle(
                        "Multiple files in " +
                        openFileDialog.Directory)

            except e:
                print "Error while opening file.", e
            # if (random() > 0.5):
            #    self.SetupGrid(self.data1)
            # else:
            #    self.SetupGrid(self.data2)
项目:pyvmwareclient    作者:wbugbofh    | 项目源码 | 文件源码
def __init__(self, *args, **kwds):
        # begin wxGlade: Dialogo_acceso_vcenter.__init__
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX
        wx.Dialog.__init__(self, *args, **kwds)
        self.label_7 = wx.StaticText(self, wx.ID_ANY, "Vcenter / esxi:")
        self.nombre_vcenter = wx.TextCtrl(self, wx.ID_ANY, "")
        self.label_9 = wx.StaticText(self, wx.ID_ANY, "Login:")
        self.login_vcenter = wx.TextCtrl(self, wx.ID_ANY, "")
        self.label_10 = wx.StaticText(self, wx.ID_ANY, "Password:")
        self.passwor_vcenter = wx.TextCtrl(self, wx.ID_ANY, "", style=wx.TE_PASSWORD)
        self.label_8 = wx.StaticText(self, wx.ID_ANY, "Puerto:")
        self.puert_vcenter = wx.TextCtrl(self, wx.ID_ANY, "")
        self.button_Exit = wx.Button(self, wx.ID_CANCEL, "Exit")
        self.button_Connect = wx.Button(self, wx.ID_OK, "Conectar")

        self.__set_properties()
        self.__do_layout()
        # end wxGlade
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def buildDialog(filePath, resourceName, mayCancel, **defaults):
    """Return a configured wx.Dialog.
    Assumes that the OK and Cancel buttons are named ID_OK & ID_CANCEL.
    """
    res = loadXrc(filePath)
    insureWxApp()
    dlg = res.LoadDialog(None, resourceName)
    assert isinstance(dlg, wx.Dialog)
    dlg.Fit()
    fetchWidget = dlg.FindWindowByName
    bOk     = dlg.FindWindowByName('ID_OK')
    bCancel = dlg.FindWindowByName('ID_CANCEL')
    bOk.SetId(wx.ID_OK)
    bCancel.SetId(wx.ID_CANCEL)
    if not mayCancel:
        bCancel.Disable()
        bCancel.Hide()
    for name, value in defaults.items():
        dlg.FindWindowByName(name).SetValue(value)
    if not mayCancel:
        dlg.Bind(wx.EVT_CHAR_HOOK, escapeSuppressor)
    return dlg
项目:SameKeyProxy    作者:xzhou    | 项目源码 | 文件源码
def OnSetMeta(self, ev=None):
      """
      set user meta on selected groups + items
      """
      tree = self.treeCtrlItems
      itemsL, groupsL = self._getSelections()
      namesL  = itemsL + groupsL
      if namesL:     
         namesS = ',\n '.join(namesL)
         msg = 'User meta data string for:\n %s' % namesS
         dlg = wx.TextEntryDialog(self, msg, 'Enter meta data')
         dlg.CentreOnParent()
         if dlg.ShowModal() == wx.ID_OK:
            meta=dlg.GetValue()
            for name in namesL:
               self.nsc_set_meta(name,meta)
项目:stopgo    作者:notklaatu    | 项目源码 | 文件源码
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()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def OnPopupNew(self, event):
        p = PhonebookEditEntry(self, '', '', 1, self.nameLength)
        if p.ShowModal() == wx.ID_OK:
            name, number = p.getValues()
            pos = self.findFreePosition()
            if pos:
                try:
                    self.SIM.gotoFile(LND_FILE_PATH)
                    if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE):
                        raise "Access conditions not met."
                    if self.writePhonebookEntry(pos, name, number) == wx.ID_YES:
                        self.itemDataMap[pos] = (name, number)
                        self.UpdateView()
                except:
                    pySIMmessage(self, "Unable to save: %s (%s)" % (name, number), "SIM card error")
            else:
                pySIMmessage(self, "Cannot save: %s (%s)\n\nNo free positions left on SIM card." % (name, number), "SIM card error")
        p.Destroy()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def OnPopupCopy(self, event):
        name = self.getColumnText(self.currentItem, 0)
        number = self.getColumnText(self.currentItem, 1)
        p = PhonebookEditEntry(self, name, number, 1, self.nameLength)
        if p.ShowModal() == wx.ID_OK:
            name, number = p.getValues()
            pos = self.findFreePosition()
            if pos:
                try:
                    self.SIM.gotoFile(LND_FILE_PATH)
                    if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE):
                        raise "Access conditions not met."
                    if self.writePhonebookEntry(pos, name, number) == wx.ID_YES:
                        self.itemDataMap[pos] = (name, number)
                        self.UpdateView()
                except:
                    pySIMmessage(self, "Unable to save: %s (%s)" % (name, number), "SIM card error")
            else:
                pySIMmessage(self, "Cannot save: %s (%s)\n\nNo free positions left on SIM card." % (name, number), "SIM card error")
        p.Destroy()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def OnPopupEdit(self, event):
        name = self.getColumnText(self.currentItem, 0)
        number = self.getColumnText(self.currentItem, 1)
        p = PhonebookEditEntry(self, name, number, 1, self.nameLength)
        if p.ShowModal() == wx.ID_OK:
            name, number = p.getValues()
            pos = self.listCtrl.GetItemData(self.currentItem)
            try:
                self.SIM.gotoFile(LND_FILE_PATH)
                if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE):
                    raise "Access conditions not met."
                if self.writePhonebookEntry(pos, name, number) == wx.ID_YES:
                    self.itemDataMap[pos] = (name, number)
                    self.UpdateView()
            except:
                pySIMmessage(self, "Unable to save: %s (%s)" % (name, number), "SIM card error")
        p.Destroy()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def OnPopupNew(self, event):
        p = PhonebookEditEntry(self, '', '', 1, self.nameLength)
        if p.ShowModal() == wx.ID_OK:
            name, number = p.getValues()
            pos = self.findFreePosition()
            if pos:
                try:
                    self.SIM.gotoFile(self.filepath)
                    if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE):
                        raise "Access conditions not met."
                    if self.writePhonebookEntry(pos, name, number) == wx.ID_YES:
                        self.itemDataMap[pos] = (name, number)
                        self.UpdateView()
                except:
                    pySIMmessage(self, "Unable to save: %s (%s)" % (name, number), "SIM card error")
            else:
                pySIMmessage(self, "Cannot save: %s (%s)\n\nNo free positions left on SIM card." % (name, number), "SIM card error")
        p.Destroy()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def OnPopupCopy(self, event):
        name = self.getColumnText(self.currentItem, 0)
        number = self.getColumnText(self.currentItem, 1)
        p = PhonebookEditEntry(self, name, number, 1, self.nameLength)
        if p.ShowModal() == wx.ID_OK:
            name, number = p.getValues()
            pos = self.findFreePosition()
            if pos:
                try:
                    self.SIM.gotoFile(self.filepath)
                    if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE):
                        raise "Access conditions not met."
                    if self.writePhonebookEntry(pos, name, number) == wx.ID_YES:
                        self.itemDataMap[pos] = (name, number)
                        self.UpdateView()
                except:
                    pySIMmessage(self, "Unable to save: %s (%s)" % (name, number), "SIM card error")
            else:
                pySIMmessage(self, "Cannot save: %s (%s)\n\nNo free positions left on SIM card." % (name, number), "SIM card error")
        p.Destroy()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def doExport(self, event):
        dlg = wx.FileDialog(self, "Save to file:", ".", "", "Text (*.txt)|*.txt", wx.SAVE|wx.OVERWRITE_PROMPT)
        if dlg.ShowModal() == wx.ID_OK:
            i = dlg.GetFilterIndex()
            if i == 0: # Text format
                try:
                    f = open(dlg.GetPath(), "w")
                    f.write("# Date, From, SerivceCenter, Message\n")
                    for i in self.itemDataMap.keys():
                        entry = self.itemDataMap[i]
                        f.write('%s,%s,%s,%s\n' % (entry[1], entry[2], entry[4].smsc, entry[3]))
                    f.close()
                    pySIMmessage(self, "SMS export to file was successful\n\nFilename: %s" % dlg.GetPath(), "Export OK")
                except:
                    pySIMmessage(self, "Unable to save your SMS messages to file: %s" % dlg.GetPath(), "Export error")
                    #print_exc()

        dlg.Destroy()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def OnPopupNew(self, event):
        p = SMSEditEntry(self, SMSmessage())
        if p.ShowModal() == wx.ID_OK:
            sms = p.getSMS()
            pos = self.findFreePosition()
            if pos:
                try:
                    self.SIM.gotoFile(SMS_FILE_PATH)
                    if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE):
                        raise "Access conditions not met."
                    self.writeSMSEntry(pos, sms)
                    self.itemDataMap[pos] = (sms.status, sms.timestamp, sms.number, sms.message, sms)
                    self.UpdateView()
                except:
                    pySIMmessage(self, "Unable to save SMS message.", "SIM card error")
            else:
                pySIMmessage(self, "Cannot save: %s (%s)\n\nNo free positions left on SIM card." % (name, number), "SIM card error")
        p.Destroy()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def OnPopupCopy(self, event):
        pos = self.listCtrl.GetItemData(self.currentItem)
        sms = self.itemDataMap[pos][COL_SMS]
        p = SMSEditEntry(self, sms.clone())
        if p.ShowModal() == wx.ID_OK:
            sms = p.getSMS()
            pos = self.findFreePosition()
            if pos:
                try:
                    self.SIM.gotoFile(SMS_FILE_PATH)
                    if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE):
                        raise "Access conditions not met."
                    self.writeSMSEntry(pos, sms)
                    self.itemDataMap[pos] = (sms.status, sms.timestamp, sms.number, sms.message, sms)
                    self.UpdateView()
                except:
                    pySIMmessage(self, "Unable to save SMS message.", "SIM card error")
            else:
                pySIMmessage(self, "Cannot save: %s (%s)\n\nNo free positions left on SIM card." % (name, number), "SIM card error")
        p.Destroy()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def OnPopupEdit(self, event):
        pos = self.listCtrl.GetItemData(self.currentItem)
        sms = self.itemDataMap[pos][COL_SMS]
        p = SMSEditEntry(self, sms)
        if p.ShowModal() == wx.ID_OK:
            sms = p.getSMS()
            try:
                self.SIM.gotoFile(SMS_FILE_PATH)
                if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE):
                    raise "Access conditions not met."
                self.writeSMSEntry(pos, sms)
                self.itemDataMap[pos] = (sms.status, sms.timestamp, sms.number, sms.message, sms)
                self.UpdateView()
            except:
                pySIMmessage(self, "Unable to save SMS message.", "SIM card error")
        p.Destroy()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def onOK(self, event):
        if self.Validate() and self.TransferDataFromWindow():
            if self.textCtrlNewPin1.GetValue() != self.textCtrlNewPin2.GetValue():
                pySIMmessage(self, "New PINs do not match!", "SIM card error")
                return

            if not self.SIM.chv1_enabled:
                # Enable CHV 'A028000108'
                apdu = "A028000108%s" % ASCIIToPIN(self.textCtrlNewPin1.GetValue())
            else:
                # Change CHV
                apdu = "A024000110%s%s" % (ASCIIToPIN(self.textCtrlOldPin.GetValue()), ASCIIToPIN(self.textCtrlNewPin1.GetValue()))

            try:
                self.SIM.sendAPDUmatchSW(apdu, SW_OK)
                self.SIM.chv1_enabled = 1
                self.chv1 = self.textCtrlNewPin1.GetValue()
            except:
                print "apdu: %r" % (apdu, )
                print_exc()
                pySIMmessage(self, "Invalid PIN!", "SIM card error")
                return

            pySIMmessage(self, "PIN was set successfully!", "Change PIN")
            self.EndModal(wx.ID_OK)
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
def __init__(self, parent, id, title, message, download_url, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE, name='dialog'):
        wx.Dialog.__init__(self, parent, id, title, pos, size, style, name)

        label = wx.StaticText(self, label=message)
        button = wx.Button(self, id=wx.ID_OK, label="Close")
        button.SetDefault()

        line = wx.StaticLine(self, wx.ID_ANY, size=(20, -1), style=wx.LI_HORIZONTAL)
        download_ctrl = hl.HyperLinkCtrl(self, wx.ID_ANY, download_url, URL=download_url)

        sizer = wx.BoxSizer(wx.VERTICAL)
        button_sizer = wx.StdDialogButtonSizer()
        button_sizer.AddButton(button)
        button_sizer.Realize()

        sizer.Add(label, 0, wx.ALIGN_CENTER|wx.ALL, 5)
        sizer.Add(download_ctrl, 0, wx.ALL, 10)
        sizer.Add(line, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.RIGHT|wx.TOP, 5)
        sizer.Add(button_sizer, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)

        self.SetSizer(sizer)
        sizer.Fit(self)
项目:irida-miseq-uploader    作者:phac-nml    | 项目源码 | 文件源码
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()
项目:tindieorderprintout    作者:limpkin    | 项目源码 | 文件源码
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
项目:cebl    作者:idfah    | 项目源码 | 文件源码
def captureImage(self, event=None):
        ## Parts borrowed from backends_wx.py from matplotlib
        # Fetch the required filename and file type.
        filetypes, exts, filter_index = self.canvas._get_imagesave_wildcards()
        default_file = self.canvas.get_default_filename()
        dlg = wx.FileDialog(self, "Save to file", "", default_file,
                            filetypes,
                            wx.SAVE|wx.OVERWRITE_PROMPT)
        dlg.SetFilterIndex(filter_index)
        if dlg.ShowModal() == wx.ID_OK:
            dirname  = dlg.GetDirectory()
            filename = dlg.GetFilename()
            format = exts[dlg.GetFilterIndex()]
            basename, ext = os.path.splitext(filename)
            if ext.startswith('.'):
                ext = ext[1:]
            if ext in ('svg', 'pdf', 'ps', 'eps', 'png') and format!=ext:
                #looks like they forgot to set the image type drop
                #down, going with the extension.
                format = ext
            self.canvas.print_figure(
                os.path.join(dirname, filename), format=format)
项目:pyvmwareclient    作者:wbugbofh    | 项目源码 | 文件源码
def on_set_note(self, event):
        fila = self.listadoVM
        for i in range(len(fila)):
                if logger != None: logger.info(fila[i])
        # At tree elemente are the name and the nine at the UUID

        vm = conexion.searchIndex.FindByUuid(None,fila[8], True)

        self.my_dialogo_ssh = dialogos.Dialogo_user_pass(None, -1, 'New Note in: {0}' .format(vm.name))
        punteromaquina = vim.vm.ConfigSpec()

        # the actual file 8 is the Note

        self.my_dialogo_ssh.usuario.SetValue('{0}' .format(fila[7]) )


        result = self.my_dialogo_ssh.ShowModal() # pintamos la ventan con la informcion
        if result == wx.ID_OK:
                punteromaquina.annotation = str( self.my_dialogo_ssh.usuario.GetValue())
                task = vm.ReconfigVM_Task(punteromaquina)
                tasks.wait_for_tasks(conexion, [task])
        self.my_dialogo_ssh.Destroy()
项目:pyvmwareclient    作者:wbugbofh    | 项目源码 | 文件源码
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.")
项目:pyvmwareclient    作者:wbugbofh    | 项目源码 | 文件源码
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
项目:pyvmwareclient    作者:wbugbofh    | 项目源码 | 文件源码
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.")
项目:pyvmwareclient    作者:wbugbofh    | 项目源码 | 文件源码
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.")
项目:pyvmwareclient    作者:wbugbofh    | 项目源码 | 文件源码
def conectar_con_vcenter():

       dlgDialogo = DialogAcceso()

       while not dlgDialogo.si:
           result = dlgDialogo.my_dialog_acceso_vcenter.ShowModal()
           if result == wx.ID_OK:
               dlgDialogo.OnConnect()
               if dlgDialogo.si:
                   if logger != None: logger.info('conectado')
                   atexit.register(Disconnect, dlgDialogo.si)
                   content = dlgDialogo.si.RetrieveContent()
                   dlgDialogo.my_dialog_acceso_vcenter.Destroy()
                   return content
               else:
                    sys.exit(0)
           else:
               dlgDialogo.OnDisConnect()


# ----------------------------------------------------------------------
# Sacar listado carpetas
项目:pyvmwareclient    作者:wbugbofh    | 项目源码 | 文件源码
def __init__(self, *args, **kwds):
        # begin wxGlade: Dialog_snapshot.__init__
        kwds["style"] = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
        wx.Dialog.__init__(self, *args, **kwds)
        self.label_1 = wx.StaticText(self, wx.ID_ANY, "Nombre:")
        self.nombre_snap = wx.TextCtrl(self, wx.ID_ANY, "")
        self.label_2 = wx.StaticText(self, wx.ID_ANY, u"Descripci\u00f3n:")
        self.descripcion_snap = wx.TextCtrl(self, wx.ID_ANY, "")
        self.checkbox_memory = wx.CheckBox(self, wx.ID_ANY, "memory")
        self.checkbox_quiesce = wx.CheckBox(self, wx.ID_ANY, "quiesce")
        self.snap_ok = wx.Button(self, wx.ID_OK, "OK")
        self.snap_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")

        self.__set_properties()
        self.__do_layout()
        # end wxGlade
项目:PancakeViewer    作者:forensicmatt    | 项目源码 | 文件源码
def button_browse_path_click(self, event):
        print "Event handler 'button_browse_path_click' not implemented!"
        dlg = wx.DirDialog(
            self,
            "Choose a directory:",
            style=wx.DD_DEFAULT_STYLE
        )

        if dlg.ShowModal() == wx.ID_OK:
            self.text_ctrl_outpath.Clear()
            self.text_ctrl_outpath.SetValue(dlg.GetPath())
            print('You selected: %s\n' % dlg.GetPath())

        dlg.Destroy()

        event.Skip()
# end of class ExtractionDialog
项目:PancakeViewer    作者:forensicmatt    | 项目源码 | 文件源码
def __init__(self, *args, **kwds):
        # begin wxGlade: LogicalVolumeDialog.__init__
        wx.Dialog.__init__(self, *args, **kwds)
        self.panel_1 = wx.Panel(self, wx.ID_ANY)
        self.panel_4 = wx.Panel(self, wx.ID_ANY)
        self.label_1 = wx.StaticText(self, wx.ID_ANY, _("Select Logical Volume: "), style=wx.ALIGN_CENTER_HORIZONTAL)
        self.panel_7 = wx.Panel(self, wx.ID_ANY)
        self.combo_logical_volumes = wx.ComboBox(self, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN)
        self.panel_8 = wx.Panel(self, wx.ID_ANY)
        self.panel_3 = wx.Panel(self, wx.ID_ANY)
        self.panel_5 = wx.Panel(self, wx.ID_ANY)
        self.button_select = wx.Button(self, wx.ID_OK, _("Select"))
        self.panel_9 = wx.Panel(self, wx.ID_ANY)
        self.button_cancel = wx.Button(self, wx.ID_CANCEL, _("Cancel"))
        self.panel_6 = wx.Panel(self, wx.ID_ANY)
        self.panel_2 = wx.Panel(self, wx.ID_ANY)

        self.__set_properties()
        self.__do_layout()

        self.Bind(wx.EVT_BUTTON, self.button_select_click, id=wx.ID_OK)
        self.Bind(wx.EVT_BUTTON, self.button_cancel_click, id=wx.ID_CANCEL)
        # end wxGlade

        self.PopulateVolumes()
项目:PancakeViewer    作者:forensicmatt    | 项目源码 | 文件源码
def OpenSource(self, event):  # wxGlade: MainFrame.<event_handler>
        dlg = wx.FileDialog(
            self,
            message="Choose Image",
            wildcard="All files (*.*)|*.*",
            style=wx.OPEN | wx.CHANGE_DIR
        )

        if dlg.ShowModal() == wx.ID_OK:
            paths = dlg.GetPaths()
            for path in paths:
                self.EnumerateSource(path)
                print('           %s\n' % path)

        dlg.Destroy()
        event.Skip()
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def OnColourSelect(self, event):
        cdata = wx.ColourData()
        cdata.SetColour((self.r,self.g,self.b))
        dlg = wx.ColourDialog(self, data=cdata)
        dlg.GetColourData().SetChooseFull(True)
        if dlg.ShowModal() == wx.ID_OK:
            self.r,self.g,self.b = dlg.GetColourData().GetColour().Get(includeAlpha=False)
            r = float(self.r)/255.0
            g = float(self.g)/255.0
            b = float(self.b)/255.0
            renderers = self.renWin.GetRenderWindow().GetRenderers()
            renderers.InitTraversal()
            no_renderers = renderers.GetNumberOfItems()
            for i in range(no_renderers):
                renderers.GetItemAsObject(i).SetBackground(r, g, b)
            self.RefreshScene()
        dlg.Destroy()
项目:bonsu    作者:bonsudev    | 项目源码 | 文件源码
def PageSetup(self):
        """Brings up the page setup dialog"""
        data = self.pageSetupData
        data.SetPrintData(self.print_data)
        dlg = wx.PageSetupDialog(self.parent, data)
        try:
            if dlg.ShowModal() == wx.ID_OK:
                data = dlg.GetPageSetupData()  # returns wx.PageSetupDialogData
                # updates page parameters from dialog
                self.pageSetupData.SetMarginBottomRight(
                    data.GetMarginBottomRight())
                self.pageSetupData.SetMarginTopLeft(data.GetMarginTopLeft())
                self.pageSetupData.SetPrintData(data.GetPrintData())
                self._print_data = wx.PrintData(
                    data.GetPrintData())  # updates print_data
        finally:
            dlg.Destroy()
项目:AppAutoViewer    作者:RealLau    | 项目源码 | 文件源码
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))
项目:laplacian-meshes    作者:bmershon    | 项目源码 | 文件源码
def OnLoadMesh(self, evt):
        dlg = wx.FileDialog(self, "Choose a file", ".", "", "OFF files (*.off)|*.off|TOFF files (*.toff)|*.toff|OBJ files (*.obj)|*.obj", wx.FD_OPEN)
        if dlg.ShowModal() == wx.ID_OK:
            filename = dlg.GetFilename()
            dirname = dlg.GetDirectory()
            filepath = os.path.join(dirname, filename)
            print dirname
            self.glcanvas.mesh = PolyMesh()
            print "Loading mesh %s..."%filename
            self.glcanvas.mesh.loadFile(filepath)
            self.glcanvas.meshCentroid = self.glcanvas.mesh.getCentroid()
            self.glcanvas.meshPrincipalAxes = self.glcanvas.mesh.getPrincipalAxes()
            print "Finished loading mesh"
            print self.glcanvas.mesh
            self.glcanvas.initMeshBBox()
            self.glcanvas.clearAllSelections()
            self.glcanvas.Refresh()
        dlg.Destroy()
        return
项目:pyjam    作者:10se1ucgo    | 项目源码 | 文件源码
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
项目:nvda-ocr    作者:nvaccess    | 项目源码 | 文件源码
def onOCRSettings(self, event):
        # Pop a dialog with available OCR languages to set
        langs = sorted(getAvailableTesseractLanguages())
        curlang = getConfig()['language']
        try:
            select = langs.index(curlang)
        except ValueError:
            select = langs.index('eng')
        choices = [languageHandler.getLanguageDescription(tesseractLangsToLocales[lang]) or tesseractLangsToLocales[lang] for lang in langs]
        log.debug(u"Available OCR languages: %s", u", ".join(choices))
        dialog = wx.SingleChoiceDialog(gui.mainFrame, _("Select OCR Language"), _("OCR Settings"), choices=choices)
        dialog.SetSelection(select)
        gui.mainFrame.prePopup()
        ret = dialog.ShowModal()
        gui.mainFrame.postPopup()
        if ret == wx.ID_OK:
            lang = langs[dialog.GetSelection()]
            getConfig()['language'] = lang
            try:
                getConfig().write()
            except IOError:
                log.error("Error writing ocr configuration", exc_info=True)
项目:pyDataView    作者:edwardsmith999    | 项目源码 | 文件源码
def fdir_dialogue(self, event):

        fdir = ""  # Use  folder as a flag
        currentdir = self.dirchooser.textctrl.GetValue()
        dlg = wx.DirDialog(self, defaultPath = currentdir)
        if dlg.ShowModal() == wx.ID_OK:
            fdir = dlg.GetPath() + "/"
            dlg.SetPath(fdir)
        dlg.Destroy()  # best to do this sooner than later

        if fdir:
            self.dirchooser.textctrl.SetValue(fdir)
            event = wx.PyCommandEvent(wx.EVT_TEXT_ENTER.typeId, 
                                      self.dirchooser.textctrl.GetId())
            self.GetEventHandler().ProcessEvent(event)
            self.fdir = fdir
项目: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()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
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()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
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()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def OnCloseDialog(self):
        errors = []
        for control, name in [(self.Days, _("days")), (self.Hours, _("hours")),
                              (self.Minutes, _("minutes")), (self.Seconds, _("seconds")),
                              (self.Milliseconds, _("milliseconds"))]:
            try:
                value = float(control.GetValue())
            except ValueError, e:
                errors.append(name)
        if len(errors) > 0:
            if len(errors) == 1:
                message = _("Field %s hasn't a valid value!") % errors[0]
            else:
                message = _("Fields %s haven't a valid value!") % ",".join(errors)
            dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR)
            dialog.ShowModal()
            dialog.Destroy()
        else:
            self.EndModal(wx.ID_OK)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
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()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def EditProjectSettings(self):
        old_values = self.Controler.GetProjectProperties()
        dialog = ProjectDialog(self)
        dialog.SetValues(old_values)
        if dialog.ShowModal() == wx.ID_OK:
            new_values = dialog.GetValues()
            new_values["creationDateTime"] = old_values["creationDateTime"]
            if new_values != old_values:
                self.Controler.SetProjectProperties(None, new_values)
                self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU,
                              PROJECTTREE, POUINSTANCEVARIABLESPANEL, SCALING)
        dialog.Destroy()

    # -------------------------------------------------------------------------------
    #                            Notebook Unified Functions
    # -------------------------------------------------------------------------------
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def GenerateAddPouFunction(self, pou_type, type_readonly=False):
        def OnAddPouMenu(event):
            dialog = PouDialog(self, pou_type, type_readonly)
            dialog.SetPouNames(self.Controler.GetProjectPouNames())
            dialog.SetPouElementNames(self.Controler.GetProjectPouVariableNames())
            dialog.SetValues({"pouName": self.Controler.GenerateNewName(None, None, "%s%%d" % pou_type)})
            pou_created = False
            if dialog.ShowModal() == wx.ID_OK:
                values = dialog.GetValues()
                tagname = self.Controler.ProjectAddPou(values["pouName"], values["pouType"], values["language"])
                if tagname is not None:
                    self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, LIBRARYTREE)
                    self.EditProjectElement(ITEM_POU, tagname)
                    dialog.Destroy()
                    pou_created = True
            dialog.Destroy()
            return pou_created
        return OnAddPouMenu
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def ForceValue(self, item):
        """
        Force value of item given
        @param item: Item to force value
        """
        # Check variable data type
        iec_path = item.GetVariable()
        iec_type = self.ParentWindow.GetDataType(iec_path)
        # Return immediately if not found
        if iec_type is None:
            return

        # Open a dialog to enter varaible forced value
        dialog = ForceVariableDialog(self, iec_type, str(item.GetValue()))
        if dialog.ShowModal() == wx.ID_OK:
            self.ParentWindow.ForceDataValue(iec_path.upper(),
                                             dialog.GetValue())
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
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
    # -------------------------------------------------------------------------------
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def AddNewBlock(self, bbox, wire=None):
        dialog = FBDBlockDialog(self.ParentWindow, self.Controler, self.TagName)
        dialog.SetPreviewFont(self.GetFont())
        dialog.SetMinElementSize((bbox.width, bbox.height))
        if dialog.ShowModal() == wx.ID_OK:
            id = self.GetNewId()
            values = dialog.GetValues()
            values.setdefault("name", "")
            block = FBD_Block(
                self, values["type"], values["name"], id,
                values["extension"], values["inputs"],
                executionControl=values["executionControl"],
                executionOrder=values["executionOrder"])
            self.Controler.AddEditedElementBlock(self.TagName, id, values["type"], values.get("name", None))
            connector = None
            if wire is not None:
                for input_connector in block.GetConnectors()["inputs"]:
                    if input_connector.IsCompatible(
                            wire.GetStartConnectedType()):
                        connector = input_connector
                        break
            self.AddNewElement(block, bbox, wire, connector)
            self.RefreshVariablePanel()
            self.ParentWindow.RefreshPouInstanceVariablesPanel()
        dialog.Destroy()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def AddNewConnection(self, bbox, wire=None):
        if wire is not None:
            values = {
                "type": CONNECTOR,
                "name": self.Controler.GenerateNewName(
                    self.TagName, None, "Connection%d", 0)}
        else:
            dialog = ConnectionDialog(self.ParentWindow, self.Controler, self.TagName)
            dialog.SetPreviewFont(self.GetFont())
            dialog.SetMinElementSize((bbox.width, bbox.height))
            values = (dialog.GetValues()
                      if dialog.ShowModal() == wx.ID_OK
                      else None)
            dialog.Destroy()
        if values is not None:
            id = self.GetNewId()
            connection = FBD_Connector(self, values["type"], values["name"], id)
            self.Controler.AddEditedElementConnection(self.TagName, id, values["type"])
            self.AddNewElement(connection, bbox, wire)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def AddNewComment(self, bbox):
        dialog = wx.TextEntryDialog(self.ParentWindow,
                                    _("Edit comment"),
                                    _("Please enter comment text"),
                                    "", wx.OK | wx.CANCEL | wx.TE_MULTILINE)
        dialog.SetClientSize(wx.Size(400, 200))
        if dialog.ShowModal() == wx.ID_OK:
            value = dialog.GetValue()
            id = self.GetNewId()
            comment = Comment(self, value, id)
            comment.SetPosition(bbox.x, bbox.y)
            min_width, min_height = comment.GetMinSize()
            comment.SetSize(*self.GetScaledSize(max(min_width, bbox.width), max(min_height, bbox.height)))
            self.AddComment(comment)
            self.Controler.AddEditedElementComment(self.TagName, id)
            self.RefreshCommentModel(comment)
            self.RefreshBuffer()
            self.RefreshScrollBars()
            self.RefreshVisibleElements()
            comment.Refresh()
        dialog.Destroy()
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def AddNewPowerRail(self, bbox, wire=None):
        if wire is not None:
            values = {
                "type": RIGHTRAIL,
                "pin_number": 1}
        else:
            dialog = LDPowerRailDialog(self.ParentWindow, self.Controler, self.TagName)
            dialog.SetPreviewFont(self.GetFont())
            dialog.SetMinElementSize((bbox.width, bbox.height))
            values = (dialog.GetValues()
                      if dialog.ShowModal() == wx.ID_OK
                      else None)
            dialog.Destroy()
        if values is not None:
            id = self.GetNewId()
            powerrail = LD_PowerRail(self, values["type"], id, values["pin_number"])
            self.Controler.AddEditedElementPowerRail(self.TagName, id, values["type"])
            self.AddNewElement(powerrail, bbox, wire)
项目:beremiz    作者:nucleron    | 项目源码 | 文件源码
def AddNewStep(self, bbox, initial=False, wire=None):
        if wire is not None:
            values = {
                "name":   self.Controler.GenerateNewName(self.TagName, None, "Step%d", 0),
                "input":  True,
                "output": True,
                "action": False
            }
        else:
            dialog = SFCStepDialog(self.ParentWindow, self.Controler, self.TagName, initial)
            dialog.SetPreviewFont(self.GetFont())
            dialog.SetMinElementSize((bbox.width, bbox.height))
            values = (dialog.GetValues()
                      if dialog.ShowModal() == wx.ID_OK
                      else None)
            dialog.Destroy()
        if values is not None:
            id = self.GetNewId()
            step = SFC_Step(self, values["name"], initial, id)
            self.Controler.AddEditedElementStep(self.TagName, id)
            for connector in ["input", "output", "action"]:
                getattr(step, ("Add"
                               if values[connector]
                               else "Remove") + connector.capitalize())()
            self.AddNewElement(step, bbox, wire)