Python wx 模块,PD_CAN_ABORT 实例源码

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

项目:wintenApps    作者:josephsl    | 项目源码 | 文件源码
def start(self):
            """Start the download.
            """
            self._shouldCancel = False
            # Use a timer because timers aren't re-entrant.
            self._guiExecTimer = wx.PyTimer(self._guiExecNotify)
            gui.mainFrame.prePopup()
            # Translators: The title of the dialog displayed while downloading add-on update.
            self._progressDialog = wx.ProgressDialog(_("Downloading Add-on Update"),
                # Translators: The progress message indicating that a connection is being established.
                _("Connecting"),
                # PD_AUTO_HIDE is required because ProgressDialog.Update blocks at 100%
                # and waits for the user to press the Close button.
                style=wx.PD_CAN_ABORT | wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME | wx.PD_AUTO_HIDE,
                parent=gui.mainFrame)
            self._progressDialog.Raise()
            t = threading.Thread(target=self._bg)
            t.daemon = True
            t.start()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def OnPopupDeleteAll(self, event):
        dlg = wxskinMessageDialog(self, self.delete_confirm_text,
                              'Confirm Deletion', wx.YES_NO | wx.ICON_INFORMATION)
        ret = dlg.ShowModal()
        dlg.Destroy()
        if ret == wx.ID_YES:

            dlg = wxskinProgressDialog("Phonebook deletion", "Deleting your %d phonebook entries" % len(self.itemDataMap), len(self.itemDataMap) + 1, self, wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
            try:
                self.SIM.gotoFile(LND_FILE_PATH)
                if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE):
                    raise "Access conditions not met."
                i = 1
                for key in self.itemDataMap.keys()[:]:   # Make a copy of key table!!
                    if not dlg.Update(i):
                        break
                    self.writePhonebookEntry(key)
                    del self.itemDataMap[key]
                    i += 1
            except:
                print_exc()
                pySIMmessage(self, "Unable to delete all phonebook entries!", "SIM card error")

            dlg.Destroy()
            self.UpdateView()

    # Override the column sorting function. We need to compare 'a' and 'A' as equal
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def OnPopupDeleteAll(self, event):
        dlg = wxskinMessageDialog(self, self.delete_confirm_text,
                              'Confirm Deletion', wx.YES_NO | wx.ICON_INFORMATION)
        ret = dlg.ShowModal()
        dlg.Destroy()
        if ret == wx.ID_YES:

            dlg = wxskinProgressDialog("Phonebook deletion", "Deleting your %d phonebook entries" % len(self.itemDataMap), len(self.itemDataMap) + 1, self, wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
            try:
                self.SIM.gotoFile(self.filepath)
                if not self.SIM.checkAndVerifyCHV1(CHV_UPDATE):
                    raise "Access conditions not met."
                i = 1
                for key in self.itemDataMap.keys()[:]:   # Make a copy of key table!!
                    if not dlg.Update(i):
                        break
                    self.writePhonebookEntry(key)
                    del self.itemDataMap[key]
                    i += 1
            except:
                print_exc()
                pySIMmessage(self, "Unable to delete all phonebook entries!", "SIM card error")

            dlg.Destroy()
            self.UpdateView()

    # Override the column sorting function. We need to compare 'a' and 'A' as equal
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def read(self):
        try:
            self.SIM.gotoFile(SMS_FILE_PATH)
            # Send the get response command, to find out record length
            data, sw = self.SIM.sendAPDUmatchSW("A0C000000F", SW_OK)
            self.recordLength  = int(data[28:30], 16) # Should be 0xB0 (176)
            self.numberRecords = int(data[4:8], 16) / self.recordLength
        except:
            pySIMmessage(self, "Unable to access your SMS folder on your SIM card.", "SIM card error")
            return

        if not self.SIM.checkAndVerifyCHV1(CHV_READ, data):
            return

        apdu = "A0B2%s04" + IntToHex(self.recordLength)
        dlg = wxskinProgressDialog("SMS", "Reading your SMS messages", self.numberRecords + 1, self, wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
        try:
            for i in range(1, self.numberRecords + 1):
                if not dlg.Update(i):
                    break
                data, sw = self.SIM.sendAPDUmatchSW(apdu % IntToHex(i), SW_OK)
                # See if SMS record is used
                status = int(data[0:2], 16)
                if status & 1 or data[2:4] != 'FF':
                    try:
                        sms = SMSmessage()
                        sms.smsFromData(data)
                        self.itemDataMap[i] = (sms.status, sms.timestamp, sms.number, sms.message, sms)
                    except:
                        #~ print i
                        #~ print data
                        #~ print_exc()
                        pass
        except:
            # Finished with the guage
            print_exc()
            pySIMmessage(self, "Unable to read your SMS messages on your SIM card.", "SIM card error")
        dlg.Destroy()
项目:multiplierz    作者:BlaisProteomics    | 项目源码 | 文件源码
def __init__(self, title, entries):
        self.progressBar = wx.ProgressDialog(title, "Time remaining", entries, style=wx.PD_ELAPSED_TIME | wx.PD_REMAINING_TIME | wx.PD_AUTO_HIDE | wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def read(self, *args):
        print "reading last numbers!"
        try:
            self.SIM.gotoFile(LND_FILE_PATH)
            # Send the get response command, to find out record length
            data, sw = self.SIM.sendAPDUmatchSW("A0C000000F", SW_OK)
            self.recordLength  = int(data[28:30], 16) # Usually 0x20
            # Now we can work out the name length & number of records
            self.nameLength = self.recordLength - 14 # Defined GSM 11.11
            self.numberRecords = int(data[4:8], 16) / self.recordLength
        except:
            pySIMmessage(self, "Unable to find your phonebook on your SIM card.", "SIM card error")
            return

        if not self.SIM.checkAndVerifyCHV1(CHV_READ, data):
            return

        apdu = "A0B2%s04" + IntToHex(self.recordLength)
        dlg = wxskinProgressDialog("Last Dialed Numbers", "Reading your last dialed numbers", self.numberRecords + 1, self, wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
        try:
            hexNameLen = self.nameLength << 1
            for i in range(1, self.numberRecords + 1):
                if not dlg.Update(i):
                    self.abortedRead = 1
                    break
                data, sw = self.SIM.sendAPDUmatchSW(apdu % IntToHex(i), SW_OK)
                # Find the end of the name
                #print data

                name = ""
                number = ""
                if data[0:2] != 'FF':
                    name = GSM3_38ToASCII(unhexlify(data[:hexNameLen]))
                    if ord(name[-1]) > 0x80:
                        # Nokia phones add this as a group identifier. Remove it.
                        name = name[:-1].rstrip()
                if data[hexNameLen:hexNameLen+2] != 'FF':
                    if name == "":
                        name == "(unknown)"
                    numberLen = int(data[hexNameLen:hexNameLen+2], 16)
                    if numberLen > 0 and numberLen <= (11): # Includes TON/NPI byte
                        hexNumber = data[hexNameLen+2:hexNameLen+2+(numberLen<<1)]
                        if hexNumber[:2] == '91':
                            number = "+"
                        number += GSMPhoneNumberToString(hexNumber[2:])
                    self.itemDataMap[i] = (name, number)
            self.abortedRead = 0
        except:
            # Finished with the guage
            self.abortedRead = 1
            print_exc()
            pySIMmessage(self, "Unable to read the phonebook on your SIM card.", "SIM card error")
        dlg.Destroy()
项目:SIMreader    作者:stoic1979    | 项目源码 | 文件源码
def read(self, *args):
        try:
            self.SIM.gotoFile(self.filepath)
            # Send the get response command, to find out record length
            data, sw = self.SIM.sendAPDUmatchSW("A0C000000F", SW_OK)
            self.recordLength  = int(data[28:30], 16) # Usually 0x20
            # Now we can work out the name length & number of records
            self.nameLength = self.recordLength - 14 # Defined GSM 11.11
            self.numberRecords = int(data[4:8], 16) / self.recordLength
        except:
            pySIMmessage(self, "Unable to find your phonebook on your SIM card.", "SIM card error")
            return

        if not self.SIM.checkAndVerifyCHV1(CHV_READ, data):
            return

        apdu = "A0B2%s04" + IntToHex(self.recordLength)
        dlg = wxskinProgressDialog("Phonebook", "Reading your phonebook entries", self.numberRecords + 1, self, wx.PD_CAN_ABORT | wx.PD_APP_MODAL)
        try:
            hexNameLen = self.nameLength << 1
            for i in range(1, self.numberRecords + 1):
                if not dlg.Update(i):
                    self.abortedRead = 1
                    break
                data, sw = self.SIM.sendAPDUmatchSW(apdu % IntToHex(i), SW_OK)
                # Find the end of the name
                #print data
                if data[0:2] != 'FF':
                    name = GSM3_38ToASCII(unhexlify(data[:hexNameLen]))
                    if ord(name[-1]) > 0x80:
                        # Nokia phones add this as a group identifier. Remove it.
                        name = name[:-1].rstrip()
                    number = ""
                    numberLen = int(data[hexNameLen:hexNameLen+2], 16)
                    if numberLen > 0 and numberLen <= (11): # Includes TON/NPI byte
                        hexNumber = data[hexNameLen+2:hexNameLen+2+(numberLen<<1)]
                        if hexNumber[:2] == '91':
                            number = "+"
                        number += GSMPhoneNumberToString(hexNumber[2:])
                    self.itemDataMap[i] = (name, number)
            self.abortedRead = 0
        except:
            # Finished with the guage
            self.abortedRead = 1
            print_exc()
            pySIMmessage(self, "Unable to read the phonebook on your SIM card.", "SIM card error")
        dlg.Destroy()