示例#1
0
    def UpdateSerialPorts (self, spl=None, sph=None):
        if spl is None:
            spl = []
            sph = 0
            for order, port, desc, hwid in sorted (comports (False)):
                spl.append (port)
                sph += hash (port)

        store = self.SerialPortsList.get_model ()
        if store is None:
            selport = None

            store = gtk.ListStore (str)
            cell = gtk.CellRendererText ()
            self.SerialPortsList.pack_start (cell, True)
            self.SerialPortsList.add_attribute (cell, 'text', 0)
            self.SerialPortsList.set_model (store)
        else:
            selport = self.SerialPortsList.get_active_text ()

        store.clear ()
        idx = 0
        act = 0
        for port in spl:
            store.append ([port])
            if selport == port:
                act = idx
            idx += 1
        self.SerialPortsList.set_active (act)
        self.SerialPortsHash = sph

        self.SetStatus (_("Serial ports list updated"))
示例#2
0
    def UpdateSerialPorts(self, spl=None, sph=None):
        if spl is None:
            spl = []
            sph = 0
            for order, port, desc, hwid in sorted(comports()):
                spl.append(port)
                sph += hash(port)

        store = self.SerialPortsList.get_model()
        if store is None:
            selport = None

            store = gtk.ListStore(str)
            cell = gtk.CellRendererText()
            self.SerialPortsList.pack_start(cell, True)
            self.SerialPortsList.add_attribute(cell, 'text', 0)
            self.SerialPortsList.set_model(store)
        else:
            selport = self.SerialPortsList.get_active_text()

        store.clear()
        idx = 0
        act = 0
        for port in spl:
            store.append([port])
            if selport == port:
                act = idx
            idx += 1
        self.SerialPortsList.set_active(act)
        self.SerialPortsHash = sph

        self.SetStatus(_("Serial ports list updated"))
示例#3
0
    def ScanComPorts (self):
        store = gtk.ListStore (str)
        cell = gtk.CellRendererText ()
        self.ComPortsList.pack_start (cell, True)
        self.ComPortsList.add_attribute (cell, 'text', 0)

        for order, port, desc, hwid in sorted (comports ()):
            store.append ([port])

        self.ComPortsList.set_model (store)
        self.ComPortsList.set_active (0)
示例#4
0
    def RefreshSerialPorts(self):
        if self.Dead:
            return False
        if self.ButtonCancelUpload.get_visible():
            return True

        spl = []
        sph = 0
        for order, port, desc, hwid in sorted(comports()):
            spl.append(port)
            sph += hash(port)

        if (sph == self.SerialPortsHash):
            return True

        self.UpdateSerialPorts(spl, sph)
        return True
示例#5
0
    def RefreshSerialPorts(self):
        if self.Dead:
            return False
        if self.ButtonCancelUpload.get_visible():
            return True

        spl = []
        sph = 0
        for order, port, desc, hwid in sorted(comports()):
            spl.append(port)
            sph += hash(port)

        if sph == self.SerialPortsHash:
            return True

        self.UpdateSerialPorts(spl, sph)
        return True
示例#6
0
    def RefreshSerialPorts (self):
        while not self.Dead:
            if not self.ButtonCancelUpload.get_visible ():
                spl = []
                sph = 0
                for order, port, desc, hwid in sorted (comports (False)):
                    spl.append (port)
                    sph += hash (port)

            if (sph == self.SerialPortsHash) or self.ButtonCancelUpload.get_visible ():
                for n in range (10):
                    if self.Dead:
                        break
                    time.sleep (0.1)
                continue

            gtk.gdk.threads_enter ()
            self.UpdateSerialPorts (spl, sph)
            gtk.gdk.threads_leave ()