Exemplo n.º 1
0
    def contextMenuAdresses(self, point):
        """
        context menu when address column right-clicked
        """
        def change_address(new_address):
            pic = PyInstrumentsConfig()
            itm = self.tree_widget.itemAt(point)
            pic[itm.val("logical_name")]["address"] = new_address
            pic.save()
            self.refresh()

        class ChangeAddress(QtGui.QAction):
            def change_address_to_mine(self):
                change_address(str(self.text()))

        menu = QtGui.QMenu(self)
        addresses = con.existing_addresses(recheck=True)
        action_addresses = []
        for address in addresses:
            action = ChangeAddress(address, self)
            action_addresses.append(action)
            action.triggered.connect(action.change_address_to_mine)
            menu.addAction(action)

        self.exec_menu_at_right_place(menu, point)
    def contextMenuAdresses(self, point):     
        """
        context menu when address column right-clicked
        """
        
        def change_address(new_address):
            pic = PyInstrumentsConfig()
            itm = self.tree_widget.itemAt(point)
            pic[itm.val("logical_name")]["address"] =  new_address
            pic.save()
            self.refresh()
        
        class ChangeAddress(QtGui.QAction):
            def change_address_to_mine(self):
                change_address(str(self.text()))
        
            
        menu = QtGui.QMenu(self)
        addresses = con.existing_addresses(recheck = True)
        action_addresses = []
        for address in addresses:
            action = ChangeAddress(address, self)
            action_addresses.append(action)
            action.triggered.connect(action.change_address_to_mine)
            menu.addAction(action)
        

        self.exec_menu_at_right_place(menu, point)
Exemplo n.º 3
0
    def _refresh(self, full=False):
        """
        refreshes the gui, if full, sets also the color of the address field
        """

        pic = PyInstrumentsConfig()
        self.tree_widget.blockSignals(True)
        self.tree_widget.remove_all_items()
        for tag, instr in pic.iteritems():
            widgetItem = self.tree_widget.add_item("", "", "", "", "", "")
            try:
                widgetItem.set_values(tag, \
                                  instr["address"],
                                  instr["model"],
                                  instr["simulate"],
                                  instr["code"])
            except KeyError as e:
                print "error"
                print e
            if (instr["model"] in Driver.supported_models()):
                widgetItem.set_color(2, "green")
            else:
                widgetItem.set_color(2, "red")

            if (instr["address"] in con.existing_addresses(full)):
                widgetItem.set_color(1, "green")
            else:
                widgetItem.set_color(1, "red")

        self.tree_widget.blockSignals(False)
 def _refresh(self, full = False):
     """
     refreshes the gui, if full, sets also the color of the address field
     """
     
     pic = PyInstrumentsConfig()
     self.tree_widget.blockSignals(True)
     self.tree_widget.remove_all_items()
     for tag, instr in pic.iteritems():
         widgetItem = self.tree_widget.add_item("",
                                               "",
                                               "",
                                               "",
                                               "",
                                               "")
         try:
             widgetItem.set_values(tag, \
                               instr["address"],
                               instr["model"],
                               instr["simulate"],
                               instr["code"])
         except KeyError as e:
             print "error"
             print e
         if(instr["model"] in Driver.supported_models()):
             widgetItem.set_color(2, "green")
         else:
             widgetItem.set_color(2, "red")
         
         
         if(instr["address"] in con.existing_addresses(full)):
             widgetItem.set_color(1, "green")
         else:
             widgetItem.set_color(1, "red")
                 
     self.tree_widget.blockSignals(False)