Python PyQt4.QtGui.QListWidgetItem() Examples

The following are 19 code examples of PyQt4.QtGui.QListWidgetItem(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module PyQt4.QtGui , or try the search function .
Example #1
Source File: ddt4all.py    From ddt4all with GNU General Public License v3.0 16 votes vote down vote up
def scan_project(self, project):
        if project == "ALL":
            self.scan()
            return
        self.ecu_scan.clear()
        self.ecu_scan.scan(self.progressstatus, self.infostatus, project)
        self.ecu_scan.scan_kwp(self.progressstatus, self.infostatus, project)

        for ecu in self.ecu_scan.ecus.keys():
            self.ecunamemap[ecu] = self.ecu_scan.ecus[ecu].name
            item = widgets.QListWidgetItem(ecu)
            if '.xml' in self.ecu_scan.ecus[ecu].href.lower():
                item.setForeground(core.Qt.yellow)
            else:
                item.setForeground(core.Qt.green)
            self.treeview_ecu.addItem(item)

        for ecu in self.ecu_scan.approximate_ecus.keys():
            self.ecunamemap[ecu] = self.ecu_scan.approximate_ecus[ecu].name
            item = widgets.QListWidgetItem(ecu)
            item.setForeground(core.Qt.red)
            self.treeview_ecu.addItem(item) 
Example #2
Source File: ddt4all.py    From ddt4all with GNU General Public License v3.0 10 votes vote down vote up
def rescan_ports(self):
        ports = elm.get_available_ports()
        if ports == None:
            self.listview.clear()
            self.ports = {}
            self.portcount = 0
            return

        if len(ports) == self.portcount:
            return

        self.listview.clear()
        self.ports = {}
        self.portcount = len(ports)
        for p in ports:
            item = widgets.QListWidgetItem(self.listview)
            itemname = p[0] + "[" + p[1] + "]"
            item.setText(itemname)
            self.ports[itemname] = (p[0], p[1])

        self.timer.start(1000) 
Example #3
Source File: guiMainQQ.py    From PyLinuxQQ with GNU General Public License v2.0 6 votes vote down vote up
def createWidget(self,listWidget, title,markname,uin):
        self.listWidgetItem = QtGui.QListWidgetItem(listWidget)
        self.listWidgetItem.setSizeHint(QtCore.QSize(0, 48))
        self.widget = QtGui.QWidget()
        self.widget.setProperty('uin',uin)
        self.widget.setGeometry(QtCore.QRect(0, 0, 238, 51))
        self.graphicsView[uin] = QtGui.QGraphicsView(self.widget)
        self.graphicsView[uin].setGeometry(QtCore.QRect(1, 1, 38, 38))
        self.lbl_title = QtGui.QLabel(self.widget)
        self.lbl_title.setGeometry(QtCore.QRect(60, 10, 181, 18))
        self.lbl_title.setFont(self.font2)
        if markname != 'None':
            title=markname+'('+title+')'
        self.lbl_title.setText(_translate("Main", title, None))
        self.lbl_comment = QtGui.QLabel(self.widget)
        self.lbl_comment.setGeometry(QtCore.QRect(60, 30, 181, 18))
        info=self.userdict.get(uin)
        if info['online']:
            self.lbl_comment.setText(_translate("Main", '[在线]', None))
        else:
            self.lbl_comment.setText(_translate("Main", '[离线]', None))
        self.lbl_comment.setFont(self.font3)
        return self.listWidgetItem, self.widget 
Example #4
Source File: main.py    From openairplay with MIT License 6 votes vote down vote up
def updateReceivers(self):
        if list(set(discovery.airplayReceivers) - set(self.oldReceiverList)) != []:
            # The new list has items oldReceiverList doesn't!
            for item in list(set(discovery.airplayReceivers) - set(self.oldReceiverList)):
                self.oldReceiverList.append(item)
                print("Adding device: " + item)
                # Convert item to string to remove the excess info
                item = QtGui.QListWidgetItem(str(item).replace("._airplay._tcp.local.", ""))
                self.deviceSelectList.addItem(item)
        if list(set(self.oldReceiverList) - set(discovery.airplayReceivers)) != []:
            # Items have been removed from the list!
            for item in list(set(self.oldReceiverList) - set(discovery.airplayReceivers)):
                self.oldReceiverList.remove(item)
                print("Removed device: " + item)
                items = self.deviceSelectList.findItems(item, QtCore.Qt.MatchExactly)
                for x in items:
                    self.deviceSelectList.takeItem(self.deviceSelectList.row(x)) 
Example #5
Source File: guiMainQQ.py    From PyLinuxQQ with GNU General Public License v2.0 6 votes vote down vote up
def createWidget_recent(self,listWidget,uin,flag):
        self.listWidgetItem = QtGui.QListWidgetItem(listWidget)
        self.listWidgetItem.setSizeHint(QtCore.QSize(0, 48))
        self.widget = QtGui.QWidget()
        self.widget.setProperty('uin',str(uin)+':'+str(flag))
        self.widget.setGeometry(QtCore.QRect(0, 0, 238, 51))
        self.graphicsView_recent[uin] = QtGui.QGraphicsView(self.widget)
        self.graphicsView_recent[uin].setGeometry(QtCore.QRect(1, 1, 60, 60))
        if flag==0:
            self.graphicsView_recent[uin].setScene(self.createImg('user',uin))
            title=self.userdict[uin]['nickname']
        if flag==1:
            title=self.groupdict[uin]['name']
            self.graphicsView_recent[uin].setScene(self.createImg('group',uin))
        if flag==2:
            title=self.discussdict[uin]['name']
            self.graphicsView_recent[uin].setScene(self.createImg('discuss',uin))
        self.graphicsView_recent[uin].resize(50,50)
        self.lbl_title = QtGui.QLabel(self.widget)
        self.lbl_title.setGeometry(QtCore.QRect(60, 10, 181, 18))
        self.lbl_title.setFont(self.font2)
        self.lbl_title.setText(_translate("Main", title, None))
        return self.listWidgetItem, self.widget 
Example #6
Source File: assetImporterWin.py    From tutorials with MIT License 6 votes vote down vote up
def importedItemSelected(self, item):
        """
        importedItemSelected(QtGui.QListWidgetItem item)

            A callback command that selects the object in the scene
            when the corresponding item is selected in the list
            of imported assets.
        """

        node = str(item.text())

        if cmds.objExists(node):
        
            cmds.select(node, r=True)
            
            # Since we stored the Asset object with each list item
            # we now have access to it and could do something with it
            # such as offering to swap out assets, etc.
            # Lets just print it.
            print "Asset was just selected:"
            print item.asset 
Example #7
Source File: assetImporterWin.py    From tutorials with MIT License 5 votes vote down vote up
def refreshImported(self):
        """
        refreshImported()

            A callback command the refreshes the list of already
            imported assets in the scene. 
            The "Refresh Imported" button calls this when clicked.
        """
        
        self.importedList.clear()

        for item in self.importer.findImported():

            listItem = QtGui.QListWidgetItem()
            listItem.setText(item[0])

            # in python, we can add arbitrary attributes onto these
            # objects for storage, unless of course the class specifically
            # prevents it. If you had a lot more custom stuff to store
            # and process, you would probably want to subclass your own
            # custom ListWidgetItem. But for now, we can just store
            # the Asset on the List item. We will be able to get this
            # back when we look up list items later.
            listItem.asset = item[1]

            self.importedList.addItem(listItem) 
Example #8
Source File: dialogs.py    From deosorg with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, deviceMap):
        """
        Create dialog and fill it with labels from deviceMap
        @param deviceMap: dict device string -> device label
        """
        QtGui.QDialog.__init__(self)
        self.setupUi(self)

        for deviceStr, label in deviceMap.items():
            item = QtGui.QListWidgetItem(label)
            item.setData(QtCore.Qt.UserRole, QtCore.QVariant(deviceStr))
            self.trezorList.addItem(item)
        self.trezorList.setCurrentRow(0) 
Example #9
Source File: guiChatQQ.py    From PyLinuxQQ with GNU General Public License v2.0 5 votes vote down vote up
def createSideButton(self, uin, title):
        # side button
        self.sideButton[uin] = QtGui.QPushButton()
        self.sideButton[uin].setGeometry(QtCore.QRect(0, 0, 101, 27))
        self.sideButton[uin].setText(_translate("Chat", title, None))
        self.sideButton[uin].setStyleSheet("QPushButton{color:red;font-size:10px;}")
        self.button_item = QtGui.QListWidgetItem(self.listWidget_Users)
        self.button_item.setSizeHint(QtCore.QSize(0, 30))
        self.listWidget_Users.setItemWidget(
            self.button_item, self.sideButton[uin])
        self.item_widget[uin]=self.button_item
        # click
        self.sideButton[uin].clicked.connect(
            functools.partial(self.sideButtonOnClick, uin)) 
Example #10
Source File: guiMainQQ.py    From PyLinuxQQ with GNU General Public License v2.0 5 votes vote down vote up
def createWidget_group(self,listWidget,title,guin,flag):
        self.listWidgetItem = QtGui.QListWidgetItem(listWidget)
        self.listWidgetItem.setSizeHint(QtCore.QSize(0, 48))
        self.widget = QtGui.QWidget()
        self.widget.setProperty('uin',guin)
        self.widget.setGeometry(QtCore.QRect(0, 0, 238, 51))
        self.graphicsView_group[guin] = QtGui.QGraphicsView(self.widget)
        self.graphicsView_group[guin].setGeometry(QtCore.QRect(1, 1, 60, 60))
        self.graphicsView_group[guin].setScene(self.createImg(flag,guin))
        self.graphicsView_group[guin].resize(50,50)
        self.lbl_title = QtGui.QLabel(self.widget)
        self.lbl_title.setGeometry(QtCore.QRect(60, 10, 181, 18))
        self.lbl_title.setFont(self.font2)
        self.lbl_title.setText(_translate("Main", title, None))
        return self.listWidgetItem, self.widget 
Example #11
Source File: list_widget_controller.py    From ropa with GNU General Public License v3.0 5 votes vote down vote up
def create_script_item(self, block):
        item = qg.QListWidgetItem()
        item.setData(qc.Qt.UserRole, block)
        item.setData(qc.Qt.DisplayRole, block.content())
        item.setFlags(item.flags() | qc.Qt.ItemIsEditable)
        return item 
Example #12
Source File: list_widget_controller.py    From ropa with GNU General Public License v3.0 5 votes vote down vote up
def create_gadget_item(self, block):
        item = qg.QListWidgetItem()
        item.setData(qc.Qt.UserRole, block)
        item.setData(qc.Qt.DisplayRole, block.content())
        item.setData(qc.Qt.ToolTipRole, block.get_query())
        if block.is_editable():
            item.setFlags(item.flags() | qc.Qt.ItemIsEditable)
        else:
            item.setFlags(item.flags() | ~qc.Qt.ItemIsEditable)

        return item 
Example #13
Source File: Upload.py    From qgis-cartodb with GNU General Public License v2.0 5 votes vote down vote up
def __init__(self, iface, toolbar, parent=None):
        CartoDBPluginUserDialog.__init__(self, toolbar, parent)

        self.iface = iface

        self.ui = Ui_Upload()
        self.ui.setupUi(self)

        self.ui.bar = QgsMessageBar()
        self.ui.bar.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
        self.ui.verticalLayout.insertWidget(0, self.ui.bar)

        self.ui.uploadBT.clicked.connect(self.upload)
        self.ui.cancelBT.clicked.connect(self.reject)
        self.ui.layersList.itemSelectionChanged.connect(self.validateButtons)

        layers = QgsMapLayerRegistry.instance().mapLayers()

        # TODO Implement add to project
        # self.ui.convertCH.hide()
        self.ui.overideCH.hide()

        self.ui.layersList.clear()
        self.ui.uploadBar.setValue(0)
        self.ui.uploadBar.hide()
        self.ui.uploadingLB.hide()
        for id_ly, ly in layers.iteritems():
            qDebug('Layer id {}'.format(stripAccents(id_ly)))
            if ly.type() == QgsMapLayer.VectorLayer and not isinstance(ly, CartoDBLayer):
                item = QListWidgetItem(self.ui.layersList)
                widget = CartoDBLayerListItem(ly.name(), ly, getSize(ly), ly.dataProvider().featureCount())
                item.setSizeHint(widget.sizeHint())
                self.ui.layersList.setItemWidget(item, widget) 
Example #14
Source File: main.py    From openairplay with MIT License 5 votes vote down vote up
def createDeviceListGroupBox(self):
        self.deviceListGroupBox = QtGui.QGroupBox("Airplay to")

        self.deviceSelectList = QtGui.QListWidget()
        deviceSelectListNoDisplayItem = QtGui.QListWidgetItem("No display.")
        self.deviceSelectList.addItem(deviceSelectListNoDisplayItem)

        # layout
        deviceListLayout = QtGui.QHBoxLayout()
        deviceListLayout.addWidget(self.deviceSelectList)
        self.deviceListGroupBox.setLayout(deviceListLayout) 
Example #15
Source File: ddt4all.py    From ddt4all with GNU General Public License v3.0 5 votes vote down vote up
def loadEcu(self, name):
        vehicle_file = "vehicles/" + name + ".ecu"
        jsonfile = open(vehicle_file, "r")
        eculist = json.loads(jsonfile.read())
        jsonfile.close()

        self.treeview_ecu.clear()
        self.treeview_params.clear()
        if self.paramview:
            self.paramview.init(None)

        for ecu in eculist:
            item = widgets.QListWidgetItem(ecu[0])
            self.ecunamemap[ecu[0]] = ecu[1]
            self.treeview_ecu.addItem(item) 
Example #16
Source File: ddt4all.py    From ddt4all with GNU General Public License v3.0 5 votes vote down vote up
def newEcu(self):
        filename_tuple = widgets.QFileDialog.getSaveFileName(self, _("Save ECU (keep '.json' extension)"), "./json/myecu.json",
                                                   "*.json")
        if qt5:
            filename = str(filename_tuple[0])
        else:
            filename = str(filename_tuple)

        if filename == '':
            return

        basename = os.path.basename(utf8(filename))
        filename = os.path.join("./json", basename)
        ecufile = ecu.Ecu_file(None)
        layout = open(filename + ".layout", "w")
        layout.write('{"screens": {}, "categories":{"Category":[]} }')
        layout.close()

        targets = open(filename + ".targets", "w")
        targets.write('[]')
        targets.close()

        layout = open(filename, "w")
        layout.write(ecufile.dumpJson())
        layout.close()

        item = widgets.QListWidgetItem(basename)
        self.treeview_ecu.addItem(item) 
Example #17
Source File: Main.py    From qgis-cartodb with GNU General Public License v2.0 5 votes vote down vote up
def updateList(self, visualizations):
        self.ui.tablesList.clear()
        for visualization in visualizations:
            item = QListWidgetItem(self.ui.tablesList)

            owner = None
            owner = visualization['permission']['owner']['username']

            widget = CartoDBDatasetsListItem(
                visualization['name'], owner, visualization['table']['size'], visualization['table']['row_count'],
                shared=(owner != self.currentUser), multiuser=self.currentMultiuser)
            # item.setText(visualization['name'])
            readonly = False
            # qDebug('Vis:' + json.dumps(visualization, sort_keys=True, indent=2, separators=(',', ': ')))
            if visualization['permission'] is not None and owner != self.currentUser and \
               visualization['permission']['acl'] is not None:
                for acl in visualization['permission']['acl']:
                    if acl['type'] == 'user' and 'username' in acl['entity'] and acl['entity']['username'] == self.currentUser and \
                       acl['access'] == 'r':
                        readonly = True
                        break

            widget.readonly = readonly
            if readonly:
                widget.setTextColor('#999999')

            item.setSizeHint(widget.sizeHint())
            # item.setIcon(QIcon(":/plugins/qgis-cartodb/images/icons/layers.png"))
            self.ui.tablesList.setItemWidget(item, widget) 
Example #18
Source File: ddt4all.py    From ddt4all with GNU General Public License v3.0 4 votes vote down vote up
def scan(self):
        msgBox = widgets.QMessageBox()
        msgBox.setText(_('Scan options'))
        scancan = False
        scancan2 = False
        scankwp = False

        canbutton = widgets.QPushButton('CAN')
        kwpbutton = widgets.QPushButton('KWP')
        cancelbutton = widgets.QPushButton(_('CANCEL'))

        msgBox.addButton(canbutton, widgets.QMessageBox.ActionRole)
        msgBox.addButton(kwpbutton, widgets.QMessageBox.ActionRole)
        msgBox.addButton(cancelbutton, widgets.QMessageBox.NoRole)
        msgBox.exec_()

        if msgBox.clickedButton() == cancelbutton:
            return

        if msgBox.clickedButton() == canbutton:
            self.logview.append(_("Scanning CAN"))
            scancan = True

        if msgBox.clickedButton() == kwpbutton:
            self.logview.append(_("Scanning KWP"))
            scankwp = True

        progressWidget = widgets.QWidget(None)
        progressLayout = widgets.QVBoxLayout()
        progressWidget.setLayout(progressLayout)
        self.progressstatus.setRange(0, self.ecu_scan.getNumAddr())
        self.progressstatus.setValue(0)

        self.ecu_scan.clear()
        if scancan:
            self.ecu_scan.scan(self.progressstatus, self.infostatus, None, self.canlinecombo.currentIndex())
        if scankwp:
            self.ecu_scan.scan_kwp(self.progressstatus, self.infostatus)

        self.treeview_ecu.clear()
        self.treeview_params.clear()
        self.ecunamemap = {}
        if self.paramview:
            self.paramview.init(None)

        for ecu in self.ecu_scan.ecus.keys():
            self.ecunamemap[ecu] = self.ecu_scan.ecus[ecu].name
            item = widgets.QListWidgetItem(ecu)
            if '.xml' in self.ecu_scan.ecus[ecu].href.lower():
                item.setForeground(core.Qt.yellow)
            else:
                item.setForeground(core.Qt.green)
            self.treeview_ecu.addItem(item)

        for ecu in self.ecu_scan.approximate_ecus.keys():
            self.ecunamemap[ecu] = self.ecu_scan.approximate_ecus[ecu].name
            item = widgets.QListWidgetItem(ecu)
            item.setForeground(core.Qt.red)
            self.treeview_ecu.addItem(item)

        self.progressstatus.setValue(0) 
Example #19
Source File: guiChatQQ.py    From PyLinuxQQ with GNU General Public License v2.0 4 votes vote down vote up
def createWidget(self, style, listWidget, chat_msg,uin,flag=0,g_sender=None):
        self.listWidgetItem = QtGui.QListWidgetItem(listWidget)
        self.listWidgetItem.setSizeHint(QtCore.QSize(0, 50))
        self.widget = QtGui.QWidget()
        self.graphicsView = QtGui.QGraphicsView(self.widget)
        self.label = QtGui.QTextBrowser(self.widget)
        self.label.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        orient=''
        if flag==0:
            ruin=uin
        else:
            ruin=g_sender
            print 'img senderuin:',ruin
        if style == 0:
            self.widget.setGeometry(QtCore.QRect(0, 10, 455, 50))
            self.graphicsView.setGeometry(QtCore.QRect(5, 5, 60, 60))
            self.graphicsView.setScene(self.createImg(ruin,flag,g_sender))
            self.graphicsView.resize(50,50)
            self.label.setGeometry(QtCore.QRect(50, 5, 390, 50))
            orient='left'
        elif style == 1:
            self.widget.setGeometry(QtCore.QRect(0, 10, 455, 50))
            self.graphicsView.setGeometry(QtCore.QRect(392, 5, 60, 60))
            self.graphicsView.setScene(self.createImg(ruin,flag,g_sender))
            self.graphicsView.resize(50,50)
            self.label.setGeometry(QtCore.QRect(10, 5, 390, 50))
            orient='right'
        # msg edit
        if flag==1:
            nick=self.groupInfo[uin][g_sender]['nick']
        if flag==2:
            nick=self.discussInfo[uin][g_sender]['nick']
        if flag==1 or flag==2:
            chat_msg=u'<p><b>'+nick+'</b></p><p>'+chat_msg+'</p>'
        content = u'''
<html><body><p align="'''+orient+'''"> ''' + chat_msg + '''</p></body></html>
        '''
        doc = QtGui.QTextDocument(self.label)
        doc.setHtml(content)
        self.label.setDocument(doc)
        # resize
        size = max(self.label.document().size().height() + 5, 50)
        self.listWidgetItem.setSizeHint(QtCore.QSize(445, size))
        self.widget.resize(455, size)
        self.label.resize(380, size)
        return self.listWidgetItem, self.widget