当前位置: 首页>>代码示例>>Python>>正文


Python QListWidget.addItem方法代码示例

本文整理汇总了Python中PySide.QtGui.QListWidget.addItem方法的典型用法代码示例。如果您正苦于以下问题:Python QListWidget.addItem方法的具体用法?Python QListWidget.addItem怎么用?Python QListWidget.addItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PySide.QtGui.QListWidget的用法示例。


在下文中一共展示了QListWidget.addItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SideBar

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]
class SideBar(QScrollArea):
    
    def __init__(self):
    
        QScrollArea.__init__(self)
        self.mainWidget = QListWidget()
        self.setWidget(self.mainWidget)
        self.setWidgetResizable(True)        
                
        self.setFixedWidth(200)
        
        self.setTitle()      
                   
                
    def setProperties(self, signal):
    
        self.mainWidget.clear()
        self.setTitle()
        
        
        for x in signal.properties:
            self.mainWidget.addItem("  " + x[0] + ": " + x[1])    
        
    def setTitle(self):
        self.mainWidget.addItem("Signal Properties")
开发者ID:antiface,项目名称:DSP-Tool,代码行数:27,代码来源:SideBar.py

示例2: initUI

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]
    def initUI(self):
        mainlay = QVBoxLayout()
        mainlay.addWidget(QLabel('<b>Deformers ({0})</b>'.format(len(self.mdl.deformers))))

        def_list = QListWidget()
        for index, el in enumerate(self.mdl.deformers):
            def_list.addItem('{0} - {1}'.format(index, el))
        #def_list.addItems(self.mdl.deformers)
        mainlay.addWidget(def_list)

        self.def_list = def_list

        btns = QHBoxLayout()
        btns.addStretch()

        save = QPushButton('Save')
        save.clicked.connect(self.save)
        close = QPushButton('Close')
        close.clicked.connect(self.close)

        btns.addWidget(save)
        btns.addWidget(close)

        mainlay.addLayout(btns)

        self.setLayout(mainlay)
        self.setGeometry(340, 340, 200, 400)
        self.setWindowTitle('MSH Suite - {0} Deformers'.format(self.mdl.name))
        self.show()
开发者ID:Schlechtwetterfront,项目名称:mshsuite,代码行数:31,代码来源:model_dialogs.py

示例3: HiddenDialog

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]
class HiddenDialog(QDialog):
   
    lifelines = None 

    def __init__(self, hiddenLifeline, parent = None):
        super(HiddenDialog, self).__init__(parent)

        self.lifelines = hiddenLifeline
        layout = QVBoxLayout(self)

        listTitle = QLabel('Hidden Life-lines')
        layout.addWidget(listTitle)

        self.listHiddenLifelines = QListWidget()
        self.listHiddenLifelines.setFixedWidth(400)
        self.listHiddenLifelines.setSelectionMode(QtGui.QAbstractItemView.MultiSelection)

        for text in self.lifelines:
            item = QtGui.QListWidgetItem(text)
            self.listHiddenLifelines.addItem(item)

        layout.addWidget(self.listHiddenLifelines)

        buttons = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok | QtGui.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self)
        buttons.button(QDialogButtonBox.Ok).setText('Show')
        buttons.accepted.connect(self.accept)
        buttons.rejected.connect(self.reject)
        layout.addWidget(buttons)

    @staticmethod
    def getSelectedItems(lifelines, parent = None):
        dialog = HiddenDialog(lifelines,parent)
        result = dialog.exec_()
        return (result, [str(x.text()) for x in dialog.listHiddenLifelines.selectedItems()])
开发者ID:OpenDanbi,项目名称:Sherlock,代码行数:36,代码来源:HiddenDialog.py

示例4: PropertyBar

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]
class PropertyBar(QScrollArea):
    def __init__(self, parent):
    
        QScrollArea.__init__(self)
        self.parent = parent
        self.mainWidget = QListWidget()
        self.setWidget(self.mainWidget)
        self.setWidgetResizable(True)        
                
        self.setFixedHeight(130)
        
        self.setTitle()      
                   
                
    def setProperties(self):
    
        self.mainWidget.clear()
        self.setTitle() 
        
        if self.parent:
            for x in self.parent.project.experimentProperties:
                self.mainWidget.addItem("  " + x[0] + ": " + x[1])    
        
    def setTitle(self):
        self.mainWidget.addItem("Experiment Properties")
开发者ID:antiface,项目名称:DSP-Tool,代码行数:27,代码来源:PropertyBar.py

示例5: Console

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]
class Console():
    def __init__(self, targetLayoutContainer):
        self.textarea = QTextEdit()
        self.commits = QListWidget()
        
        self.commits.addAction(QAction('Rollback to this revision', self.commits, triggered=self.rollback))
        self.commits.setContextMenuPolicy(Qt.ActionsContextMenu)
        
        self.widget = QTabWidget()
        self.widget.addTab(self.textarea, 'Log')
        self.widget.addTab(self.commits, 'Commits')
        
        targetLayoutContainer.addWidget(self.widget)
        
    def color(self, module, function, color,  *args):
        print module, function, args
        
        prettyString = '<font color="' + color + '"><b>', module, '</b><i>::', function, '</i> --> ', ''.join(args), '</font>'
        self.textarea.append(''.join(prettyString))    
        
    def info(self, module, function, *args):
        print module, function, args
        
        prettyString = '<font color="black"><b>', module, '</b><i>::', function, '</i> --> ', ''.join(args), '</font>'
        self.textarea.append(''.join(prettyString))
        
    def error(self, module, function, *args):
        print module, function, args
        
        prettyString = '<font color="red"><b>', module, '</b><i>::', function, '</i> --> ', ''.join(args), '</font>'
        self.textarea.append(''.join(prettyString))
        
    def warn(self, module, function, *args):
        print module, function, args
        
        prettyString = '<font color="#BE9900"><b>', module, '</b><i>::', function, '</i> --> ', ''.join(args), '</font>'
        self.textarea.append(''.join(prettyString))
        
    def set_commits(self, commits):
        self.commits.clear()
        
        for commit in commits:
            self.commits.addItem(commit)
            
    def clear(self):
        self.textarea.clear()
        
    def rollback(self):
        targetCommit = self.commits.currentItem().text().split(' ')[0]
        if QMessageBox.warning(None, 'Rollback to commit?', 'All commits after ' + targetCommit + ' will be lost, proceed?', QMessageBox.Yes, QMessageBox.No) == QMessageBox.Yes:
            rollback(targetCommit)
开发者ID:cefolger,项目名称:favorites,代码行数:53,代码来源:console.py

示例6: __init__

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]
	def __init__(self, parent=None):
		super(EditPreferencesDlg, self).__init__(parent)
		self.setWindowTitle("Preferences")
		# define widgets
		pref_list = QListWidget()
		pref_list.addItem("General")
		pref_list.addItem("Display")
		pref_list.setMaximumWidth(150)
		pref_list.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
		
		button_box = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
		
		general_page = QWidget()
		general_layout = QGridLayout()
		general_layout.setAlignment(Qt.AlignTop)
		general_layout.addWidget(QLabel("<b>General</b>"), 0, 0)
		general_page.setLayout(general_layout)
		
		display_page = QWidget()
		display_layout = QGridLayout()
		display_layout.setAlignment(Qt.AlignTop)
		display_layout.addWidget(QLabel("<b>Display Options</b>"), 0, 0)
		self.multitabs_checkbox = QCheckBox("Limit the display of tabs to one relief device (and the device's scenarios) at a time")
		if parent.limit_tabs is True:
			self.multitabs_checkbox.setChecked(True)
		display_layout.addWidget(self.multitabs_checkbox, 1, 0)
		display_page.setLayout(display_layout)

		stacked_widget = QStackedWidget()
		for page in general_page, display_page:
			stacked_widget.addWidget(page)
		
		main_layout = QVBoxLayout()
		widgets_layout = QHBoxLayout()
		widgets_layout.addWidget(pref_list)
		widgets_layout.addWidget(stacked_widget)
		buttons_layout = QHBoxLayout()
		buttons_layout.addStretch()
		buttons_layout.addWidget(button_box)
		main_layout.addLayout(widgets_layout)
		main_layout.addLayout(buttons_layout)
		self.setLayout(main_layout)
		
		pref_list.currentRowChanged.connect(stacked_widget.setCurrentIndex)
		
		button_box.accepted.connect(self.accept)
		button_box.rejected.connect(self.reject)
开发者ID:nb1987,项目名称:rvac,代码行数:49,代码来源:dlg_classes.py

示例7: display

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]
	def display(self):
		layout = QHBoxLayout()
		layout.setSpacing(10)

		# Left panel - repositories
		qlistWidget = QListWidget()
		for repo in self.args.user.repositories():
			qlistWidget.addItem(repo.name)
		layout.addWidget (qlistWidget)


		# Middle panel - commits
		commitsLabel = QLabel("There will be the commits")
		layout.addWidget (commitsLabel)

		# Something
		somethingLabel = QLabel("There will be something")
		layout.addWidget (somethingLabel)

		self.setLayout(layout)
		self.show()
开发者ID:FrostyX,项目名称:octopy,代码行数:23,代码来源:home.py

示例8: MultiListDialog

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]
class MultiListDialog(QDialog):
    def __init__(self, items):  # , parent=None
        super(MultiListDialog, self).__init__()  # parent
        self.resize(800, 550)
        self.entries = items
        layout = QVBoxLayout(self)

        self.listWidget = QListWidget(self)
        self.listWidget.setSelectionMode(QAbstractItemView.ExtendedSelection)

        self.HlineInputfiles = ConfigLineDir(u"Verzeichnis NI XML:", "dir")
        self.HlineOutputfiles = ConfigLineDir(u"Verzeichnis Report:", "dir")
        if os.path.isfile(PICKLE_TEMP_FILE):
            pkl_file = open(PICKLE_TEMP_FILE, 'rb')
            inPath = pickle.load(pkl_file)
            outPath = pickle.load(pkl_file)
            pkl_file.close()
            if os.path.isdir(inPath):
                self.HlineInputfiles.editText.setText(inPath)
            if os.path.isdir(outPath):
                self.HlineOutputfiles.editText.setText(outPath)
        layout.addLayout(self.HlineInputfiles)
        layout.addLayout(self.HlineOutputfiles)
        layout.addWidget(self.listWidget)

        layout.addWidget(QLabel("Mehrfachauswahl -> Strg + Mausklick"))

        # OK and Cancel buttons
        buttons = QDialogButtonBox(QDialogButtonBox.Apply | QDialogButtonBox.Close, Qt.Horizontal, self)
        # Apply before Close
        buttons.setStyleSheet("* { button-layout: 2 }")
        layout.addWidget(buttons)

        buttons.rejected.connect(self.close)
        buttons.button(QDialogButtonBox.Apply).clicked.connect(self.Apply_Clicked)

        self.SetListItems()
        self.HlineInputfiles.editText.textChanged.connect(self.RefreshList)
        self.HlineInputfiles.editText.textChanged.connect(self.SetListItems)

    # def SetOutputDir(self):
    #     self.HlineOutputfiles.editText.setText(self.HlineInputfiles.getText())

    def SetListItems(self, parent=None):
        itemslist = os.listdir(self.HlineInputfiles.getText())
        for it in itemslist:
            if it.endswith(".xml"):
                self.listWidget.addItem(it)

    def GetMarkedItems(self):
        results = []
        try:
            for el in self.listWidget.selectedItems():
                results.append(str(el.text()))
            return (results)

        except:
            return (None)

    def RefreshList(self):
        self.listWidget.clear()
        print "refresh"

    def Apply_Clicked(self):
        SelectedItems = self.GetMarkedItems()
        textMsg = "Selektierte Dateie(n):\r\n"
        if len(SelectedItems) > 0:
            for file in SelectedItems:
                filePath = os.path.join(self.HlineInputfiles.getText(), file)
                textMsg += (file + "\r\n")
                XmlAnalysis.XmlAnalysis(filePath, self.HlineOutputfiles.getText())

            #QMessageBox.information(self, "Report", textMsg)
            textMsg += "\r\nReport-Verzeichnis öffnen?\r\n"
            msgBox = QMessageBox.StandardButton.Yes
            msgBox |= QMessageBox.StandardButton.No
            if QMessageBox.question(self, "Report", textMsg, msgBox) == QMessageBox.Yes:
                os.startfile(self.HlineOutputfiles.getText())

        else:
            QMessageBox.warning(self, "Achtung", "Keine Datei selektiert!")
            pass
开发者ID:qbvn,项目名称:PyCharm-Projects,代码行数:84,代码来源:main.py

示例9: SubscriberDialog

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]
class SubscriberDialog(QDialog):

    if USE_MAEMO_5:
        switchRequested = Signal()

    def __init__(self, parent=None):
        QDialog.__init__(self, parent)
        self.ui = Ui_SubscriberDialog()
        self.ui.setupUi(self)

        self.subscriber = None
        self.tableWidget = None
        self.listWidget = None

        if USE_MAEMO_5:
            switchButton = self.ui.buttonBox.addButton(self.tr('Switch'), QDialogButtonBox.ActionRole)
            switchButton.clicked.connect(self.switchRequested)

            self.tableWidget = self.ui.tableWidget
            headerLabels = ('Key', 'Value', 'Type')
            self.tableWidget.setColumnCount(3)
            self.tableWidget.setHorizontalHeaderLabels(headerLabels)
            horizontalHeader = self.tableWidget.horizontalHeader()
            horizontalHeader.setStretchLastSection(True)
            verticalHeader = self.tableWidget.verticalHeader()
            verticalHeader.setVisible(False)
            self.tableWidget.setColumnWidth(0, 200)
            self.tableWidget.setColumnWidth(1, 400)
        else:
            desktopWidget = QDesktopWidget()
            if desktopWidget.availableGeometry().width() < 400:
                # Screen is too small to fit a table widget without scrolling, use a list widget instead.
                self.listWidget = QListWidget()
                self.listWidget.setAlternatingRowColors(True)
                self.ui.verticalLayout.insertWidget(2, self.listWidget)
            else:
                self.tableWidget = QTableWidget()
                headerLabels = ('Key', 'Value', 'Type')
                self.tableWidget.setColumnCount(3)
                self.tableWidget.setHorizontalHeaderLabels(headerLabels)
                horizontalHeader = self.tableWidget.horizontalHeader()
                horizontalHeader.setStretchLastSection(True)
                self.tableWidget.verticalHeader()
                self.setVisible(False)
                self.ui.verticalLayout.insertWidget(2, self.tableWidget)

        self.ui.connectButton.clicked.connect(self.changeSubscriberPath)
        self.changeSubscriberPath()

        # if the default path does not exist reset it to /
        value = self.subscriber.value()
        subPaths = self.subscriber.subPaths()
        if not value and not subPaths:
            self.ui.basePath.setText('/')
            self.changeSubscriberPath()

    def changeEvent(self, e):
        QDialog.changeEvent(self, e)
        if e.type() == QEvent.LanguageChange:
            self.ui.retranslateUi(self)

    def changeSubscriberPath(self):
        if self.listWidget:
            self.listWidget.clear()
        elif self.tableWidget:
            self.tableWidget.clearContents()

        if not self.subscriber:
            self.subscriber = QValueSpaceSubscriber(self.ui.basePath.text(), self)
        else:
            self.subscriber.setPath(self.ui.basePath.text())

        self.subscriber.contentsChanged.connect(self.subscriberChanged)
        self.subscriber.connectNotify("contentsChanged()")
        self.subscriberChanged()

    def subscriberChanged(self):
        subPaths = self.subscriber.subPaths()

        if self.listWidget:
            self.listWidget.clear()
        elif self.tableWidget:
            self.tableWidget.clearContents()
            self.tableWidget.setRowCount(len(subPaths))

        for i in xrange(len(subPaths)):
            v = self.subscriber.value(subPaths[i])
            if self.listWidget:
                item = QListWidgetItem('%s (%s)\n%s' % (subPaths[i], str(type(v)), str(v)))
                item.setFlags(item.flags() & ~Qt.ItemIsEditable)
                self.listWidget.addItem(item)
            elif self.tableWidget:
                pathItem = QTableWidgetItem(subPaths[i])
                pathItem.setFlags(pathItem.flags() & ~Qt.ItemIsEditable)
                valueItem = QTableWidgetItem(str(v))
                valueItem.setFlags(pathItem.flags() & ~Qt.ItemIsEditable)
                typeItem = QTableWidgetItem(str(type(v)))
                typeItem.setFlags(pathItem.flags() & ~Qt.ItemIsEditable)

                self.tableWidget.setItem(i, 0, pathItem)
#.........这里部分代码省略.........
开发者ID:AmerGit,项目名称:Examples,代码行数:103,代码来源:subscriberdialog.py

示例10: ToolBox

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]

#.........这里部分代码省略.........
            self.buttonCapture.setText('Capture')
        if const.STATE_INTERACTIVE_RESET == state:
            self.buttonCapture.setEnabled(True)
            self.buttonCapture.setText('Capture')
        elif const.STATE_INTERACTIVE_ACTIVE == state:
            self.buttonCapture.setEnabled(True)
            self.buttonCapture.setText('Capture')

    def setMessageInfo(self,info):
        self.msgInfo.setText(info)

    def setAvailable(self,threads):
        self.sig.emit(threads)

    def toggleThreadDisplay(self,item):
        print(self.listThread.currentRow())
        #if item.isSelected():
        #    print(item.text() + "  is selected")
        #else:
        #    print(item.text() + "  is not selected")
        self.diagramView.showThread(self.listThread.currentRow(),item.isSelected())

    def hideAllMsgNamedAsSelected(self):
        self.diagramView.hideAllMessageSelected()

    def addThreadList(self,threads):

        if not self.groupBoxThreadInfo:
            self.groupBoxThreadInfo = QGroupBox()
            self.threadInfo = QLabel("Thread Info.")
            self.groupBoxThreadInfo.setStyleSheet("QGroupBox {border: 1px solid gray; border-radius: 9px; margin-top: 0.5em} QGroupBox::title {subcontrol-origin: margin; left: 10px; padding: 0 3px 0 3px;")

        if not self.threadvbox:
            self.threadvbox = QVBoxLayout()

        if not self.listThread:
            self.listThread = QListWidget()
            
        self.listThread.setFixedWidth(200)
        self.listThread.setSelectionMode(QtGui.QAbstractItemView.MultiSelection)
        QtCore.QObject.connect(self.listThread, QtCore.SIGNAL("itemClicked(QListWidgetItem *)"), self.toggleThreadDisplay)
        self.threadvbox.addWidget(self.threadInfo)
        self.threadvbox.addWidget(self.listThread)
        self.groupBoxThreadInfo.setLayout(self.threadvbox)
        self.addWidget(self.groupBoxThreadInfo)
        self.groupBoxThreadInfo.setSizePolicy(self.sizePolicy)

        for id in threads:
            item = QtGui.QListWidgetItem(id)
            self.listThread.addItem(item)

    def connectController(self,controller):
        self.controller = controller
        self.connect(controller,QtCore.SIGNAL('setAvailable()'),self.setAvailable)
       
    def connectDiagramView(self,view):
        self.diagramView = view
 
    def disconnectMsgRcv(self,receiver):
        print("Implement this method !!! disconnectMsgRcv")

    def connectMsgRcv(self,receiver):
        self.msgRcv.append(receiver)

    def notifyHide(self):
        for rcv in self.msgRcv:
            rcv.activateHide(True)

    def showHiddenLifelines(self):
        response, selected_items = HiddenDialog.HiddenDialog.getSelectedItems(self.diagramView.getHiddenLifeLines())
        if response:
            self.diagramView.showLifelines(selected_items)

    def showHiddenMessages(self):
        response, selected_items = HiddenMessageDialog.HiddenMessageDialog.getSelectedItems(self.diagramView.getHiddenMessages(),self.diagramView.getHiddenLifeLines())
        if response:
            if selected_items[3] in self.diagramView.getHiddenLifeLines():
                confirmation = ShowLifeLineDialog.ShowLifeLineDialog.confirmToShowLifeLine(selected_items[3])
                if confirmation:
                    self.diagramView.showLifelines([selected_items[3]])
                    self.diagramView.showMessages(selected_items)
            else:
                self.diagramView.showMessages(selected_items)

    def notifyCapture(self):
        for rcv in self.msgRcv:
            rcv.activateCapture(True)
    
    def moveToPrev(self):
        for rcv in self.msgRcv:
            rcv.moveToPrev()
        
    def moveToNext(self):
        for rcv in self.msgRcv:
            rcv.moveToNext()

    def searchMsg(self):
        str = self.editTextSearch.toPlainText()
        for rcv in self.msgRcv:
            rcv.searchMessage(str)
开发者ID:OpenDanbi,项目名称:Sherlock,代码行数:104,代码来源:ToolBox.py

示例11: ListEditor

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]
class ListEditor ( BaseEditor ):
    """ Enumeration editor, used for the "custom" style, that displays a list
        box.
    """

    #-- Public Methods ---------------------------------------------------------

    def init ( self, parent ):
        """ Finishes initializing the editor by creating the underlying toolkit
            widget.
        """
        super( ListEditor, self ).init( parent )

        self.control = QListWidget( parent )
        QObject.connect( self.control, SIGNAL( 'currentTextChanged(QString)' ),
                         self.update_object )

        self.rebuild_editor()
        self.set_tooltip()


    def update_object ( self, text ):
        """ Handles the user selecting a list box item.
        """
        value = unicode( text )
        try:
            value = self.mapping[ value ]
        except:
            try:
                value = self.factory.evaluate( value )
            except:
                pass
        try:
            self.value = value
        except:
            pass


    def update_editor ( self ):
        """ Updates the editor when the object facet changes externally to the
            editor.
        """
        control = self.control
        try:
            value = self.inverse_mapping[ self.value ]

            for row in range( control.count() ):
                itm = control.item( row )

                if itm.text() == value:
                    control.setCurrentItem( itm )
                    control.scrollToItem( itm )
                    break
        except:
            pass


    def rebuild_editor ( self ):
        """ Rebuilds the contents of the editor whenever the original factory
            object's **values** facet changes.
        """
        self.control.clear()

        for name in self.names:
            self.control.addItem( name )

#-- EOF ------------------------------------------------------------------------
开发者ID:davidmorrill,项目名称:facets,代码行数:69,代码来源:enum_editor.py

示例12: ServiceBrowser

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]
class ServiceBrowser(QWidget):
    def __init__(self, parent = None):
        QWidget.__init__(self, parent)
        self.serviceManager = QServiceManager(self)
        self.registerExampleServices()
        self.initWidgets()
        self.reloadServicesList()
        self.setWindowTitle(self.tr("Services Browser"))

    def __del__(self):
        self.unregisterExampleServices()

    def currentInterfaceImplChanged(self, current, previous):
        if not current:
            return

        descriptor = current.data(Qt.UserRole)
        self.reloadAttributesList()
        self.reloadAttributesRadioButtonText()
        if descriptor.isValid():
            self.defaultInterfaceButton.setText(self.tr("Set as default implementation for %s" % str(descriptor.interfaceName())))
        self.defaultInterfaceButton.setEnabled(True)

    def reloadServicesList(self):
        self.servicesListWidget.clear()
        services = self.serviceManager.findServices()
        for serv in services:
            self.servicesListWidget.addItem(serv)

        self.servicesListWidget.addItem(self.showAllServicesItem)
        self._services = services

    def reloadInterfaceImplementationsList(self):
        serviceName = None
        allServices = self.servicesListWidget.currentItem().text() == self.showAllServicesItem.text()
        if self.servicesListWidget.currentItem() and not allServices:
            serviceName = self.servicesListWidget.currentItem().text()
            self.interfacesGroup.setTitle(self.tr("Interfaces implemented by %s" % str(serviceName)))
        else:
            self.interfacesGroup.setTitle(self.tr("All interface implementations"))

        descriptors = self.serviceManager.findInterfaces(serviceName)
        self.attributesListWidget.clear()
        self.interfacesListWidget.clear()
        self._i = []
        for desc in descriptors:
            text = "%s %d.%d" % (desc.interfaceName(), desc.majorVersion(), desc.minorVersion())

            if not serviceName:
                text += " (" + desc.serviceName() + ")"

            defaultInterfaceImpl = self.serviceManager.interfaceDefault(desc.interfaceName())
            if desc == defaultInterfaceImpl:
                text += self.tr(" (default)")

            item = QListWidgetItem(text)
            item.setData(Qt.UserRole, desc)
            item._data = desc
            self.interfacesListWidget.addItem(item)

        self.defaultInterfaceButton.setEnabled(False)

    def reloadAttributesList(self):
        item = self.interfacesListWidget.currentItem()
        if not item:
            return

        selectedImpl = item.data(Qt.UserRole)
        implementationRef = None
        if self.selectedImplRadioButton.isChecked():
            implementationRef = self.serviceManager.loadInterface(selectedImpl)
        else:
            implementationRef = self.serviceManager.loadInterface(selectedImpl.interfaceName())

        self.attributesListWidget.clear()
        if not implementationRef:
            self.attributesListWidget.addItem(self.tr("(Error loading service plugin)"))
            return

        metaObject = implementationRef.metaObject()
        self.attributesGroup.setTitle(self.tr("Invokable attributes for %s class" % metaObject.className()))
        for i in range(metaObject.methodCount()):
            method = metaObject.method(i)
            self.attributesListWidget.addItem("[METHOD] " + method.signature())

        for i in range(metaObject.propertyCount()):
            p = metaObject.property(i)
            self.attributesListWidget.addItem("[PROPERTY] " + p.name())

    def setDefaultInterfaceImplementation(self):
        item = self.interfacesListWidget.currentItem()
        if not item:
            return

        descriptor = item.data(Qt.UserRole)
        if descriptor.isValid():
            if self.serviceManager.setInterfaceDefault(descriptor):
                currentIndex = self.interfacesListWidget.row(item)
                self.reloadInterfaceImplementationsList()
                self.interfacesListWidget.setCurrentRow(currentIndex)
#.........这里部分代码省略.........
开发者ID:AmerGit,项目名称:Examples,代码行数:103,代码来源:servicebrowser.py

示例13: mainwin

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]

#.........这里部分代码省略.........
	def listwidcall(self, item):
		self.comboBox.setText(item.text())
		self.setevent()

	def search(self, text, *args):
		li = []
		tplus = text + "%"
		cur.execute("select ENGW from ENGTAM where ENGW like ? limit 20", (tplus, ))
		cuf = cur.fetchall()
		model = QStringListModel()
		for i in range(len(cuf)):
			k = cuf[i][0]
			li.append(k)
		model.setStringList(li)
		self.completer.setModel(model)

	def returnpressedevent(self, *args):
		self.comboBox.selectAll()
		self.returncount += 1
		if self.returncount % 2 == 0:
			self.setevent()
		else:
			self.comboBox.selectAll()

	def setevent(self):
		self.comboBox.selectAll()
		self.bkm_addfav.setEnabled(True)
		lis = []
		eng = self.comboBox.text()
		cur.execute("SELECT rowid, TAMW FROM ENGTAM WHERE ENGW like ? limit 1", (eng,))
		cuf = cur.fetchall()
		if len(cuf) == 0:
			self.tamtext.setText("No words found. . . ")
			self.listview.addItem("No Suggestions. . .")
		else:
			for i in range(len(cuf)):
				tam = cuf[0][1]
				rowid = cuf[0][0]
				self.tamtext.setText(tam)
				if rowid <= 25:
					start = 0
					end = 50
				elif rowid >= 190513:
					start = rowid - 190487
					end = rowid + 190537
				else:
					start = rowid - 25
					end = rowid + 25
				cur.execute("SELECT ENGW FROM ENGTAM WHERE rowid>=? and rowid<=?", (start, end, ))
				cuff = cur.fetchall()
				for i in range(len(cuff)):
					engw = cuff[i][0]
					lis.append(engw)
				if self.listview.count() is not None:
					self.listview.clear()
				self.listview.addItems(lis)
				self.addtoli(eng, self.histlis)
				if self.histlis[0] >= 2:
					self.go_prev.setEnabled(True)
				self.comboBox.setFocus()
				if self.histdock:
					self.histli.addItem(eng)

	def addtoli(self, addw, lis, c=1):
		if len(lis) > 0:
			if type(lis[0]) == int:
开发者ID:jnoortheen,项目名称:nigandu,代码行数:70,代码来源:mainwin.py

示例14: ProfileSelection

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]
class ProfileSelection(QDialog):
    '''
    classdocs
    '''
    
    removeProfile = Signal(Athlete_Model)
    profileSelected = Signal(Athlete_Model)
    profileUpdate_request = Signal(Athlete_Model, Athlete_Model)
    lastProfileDeleted = Signal()
    
    def __init__(self, athletesList):
        '''
        Constructor
        '''  
        QDialog.__init__(self)
        self.setWindowTitle("Profile Selection")
        
        self.athletesList = athletesList
            
        self._initGUI()      
    
    def _initGUI(self):
        topHLayout = QHBoxLayout()
        hLayout = QHBoxLayout()
        vLayout = QVBoxLayout()
        
        # Label
        greeterText = QLabel("Welcome to <b>Pushup app</b>." + \
                             "<br><br> Select a profile:")
        vLayout.addWidget(greeterText)        
            
        # List 
        self.list = QListWidget()
        self.list.setMinimumWidth(150)
        self.list.setSelectionMode(QAbstractItemView.SingleSelection)
        # SingleSelection is the default value, but I prefer to be sure
        self.list.itemSelectionChanged.connect(self._activateButtons) 
        
        for athlete in self.athletesList:
            iconW = QIcon.fromTheme("user-available")
            # doens't work on Mac and Windows
            # http://qt-project.org/doc/qt-4.8/qicon.html#fromTheme
            
            listW = QListWidgetItem(iconW, athlete._name)
            listW.setData(Qt.UserRole, athlete)
            
            self.list.addItem(listW)
        
        topHLayout.addWidget(self.list)
        self.profileWidget = ProfileFormWidget()
        self.profileWidget.hide()
        
        topHLayout.addWidget(self.profileWidget)    
       
        vLayout.addLayout(topHLayout)        
        vLayout.addLayout(hLayout)
        
        # Buttons
        self.okBtn = QPushButton("Ok")
        self.okBtn.setDisabled(True)
        self.okBtn.setDefault(True)
        self.okBtn.clicked.connect(self._okButtonSlot)
        self.list.itemDoubleClicked.connect(self._okButtonSlot)
                
        cancelBtn = QPushButton("Cancel")      
        cancelBtn.clicked.connect(self._cancelButtonSlot)
        
        self.editBtn = QPushButton("Edit")
        self.editBtn.setDisabled(True)
        self.editBtn.setCheckable(True)
        self.editBtn.clicked.connect(self._toggleProfileEdit)
        
        self.saveBtn = QPushButton("Save changes") # Saves the changes made on the profile 
        self.saveBtn.hide()
        self.saveBtn.clicked.connect(self._saveButtonSlot)
    
        self.removeProfileBtn = QPushButton("Remove Profile")
        self.removeProfileBtn.setDisabled(True)
        self.removeProfileBtn.clicked.connect(self._removeProfile_Dialog)
        
        hLayout.addWidget(self.editBtn)
        hLayout.addWidget(self.removeProfileBtn)
        hLayout.addWidget(cancelBtn)
        hLayout.addWidget(self.okBtn)
        hLayout.addWidget(self.saveBtn)

        self.setLayout(vLayout)
    
    def getSelectedProfile(self):
        selectedListItem = self.list.selectedItems()[0]
        athleteProfile = selectedListItem.data(Qt.UserRole)
        
        return athleteProfile
    
    def updateList(self, athletes):
        self.list.clear()
        self.athletesList = athletes
        
        for athlete in self.athletesList:
            iconW = QIcon.fromTheme("user-available")
#.........这里部分代码省略.........
开发者ID:davcri,项目名称:Pushup-app,代码行数:103,代码来源:ProfileSelection.py

示例15: MainControl

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import addItem [as 别名]
class MainControl(QWidget):

    toChangeChunk = Signal(tuple)
    toChangeSlice = Signal(int)

    def __init__(self, parent):
        super(MainControl, self).__init__(parent)
        self.parent = parent
        self.selectedMinerals = parent.selectedMinerals
        self.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
        lb0 = QLabel('Minecraft Prism chunk minerals finder')
        lb1 = QLabel('Chunk X')
        lb2 = QLabel('Chunk Z')
        lb3 = QLabel('Show deposits of:')
        lb4 = QLabel('Slice Elevation')
        #lb0.setFrameStyle(QFrame.Box)
        lb0.setAlignment(Qt.AlignVCenter | Qt.AlignCenter)
        lb2.setAlignment(Qt.AlignVCenter | Qt.AlignRight)

        self.txtChunkX = QLineEdit()
        self.txtChunkZ = QLineEdit()
        self.txtElevation = QLineEdit(str(self.parent.presenter.elevation))
        self.txtChunkX.setAlignment(Qt.AlignVCenter | Qt.AlignCenter)
        self.txtChunkZ.setAlignment(Qt.AlignVCenter | Qt.AlignCenter)
        self.txtElevation.setAlignment(Qt.AlignVCenter | Qt.AlignCenter)

        self.btnViewChunk = QPushButton('View Chunk')
        self.btnViewChunk.clicked.connect(self.btnViewChunk_OnClick)
        
        self.btnSliceUp = QPushButton('Slice Up')
        self.btnSliceUp.clicked.connect(self.btnSliceUp_OnClick)
        self.btnSliceDown = QPushButton('Slice Down')
        self.btnSliceDown.clicked.connect(self.btnSliceDown_OnClick)
        
        self.lstMinerals = QListWidget()
        self.lstMinerals.setSelectionMode(QAbstractItemView.ExtendedSelection)
        self.lstMinerals.addItem(SelectedMineral('Gold', 14))
        self.lstMinerals.addItem(SelectedMineral('Iron', 15))
        self.lstMinerals.addItem(SelectedMineral('Diamond', 56))
        self.lstMinerals.addItem(SelectedMineral('Redstone', 73))
        self.lstMinerals.addItem(SelectedMineral('Obsidian', 49))
        self.lstMinerals.addItem(SelectedMineral('Coal', 16))
        self.lstMinerals.addItem(SelectedMineral('Lazurit', 21))
        self.lstMinerals.setCurrentItem(self.lstMinerals.item(0))
        self.lstMinerals.itemSelectionChanged.connect(self.onSelectedMinerals)

        elevBox = QHBoxLayout()
        elevBox.addWidget(lb4)
        elevBox.addWidget(self.txtElevation)
        elevBox.addWidget(self.btnSliceUp)
        elevBox.addWidget(self.btnSliceDown)
        
        ly = QGridLayout()
        ly.addWidget(lb0,               0, 0, 1, 4)
        ly.addWidget(lb1,               1, 0, 1, 1)
        ly.addWidget(self.txtChunkX,    1, 1, 1, 1)
        ly.addWidget(lb2,               1, 2, 1, 1)
        ly.addWidget(self.txtChunkZ,    1, 3, 1, 1)
        ly.addWidget(lb3,               2, 0, 1, 2)
        ly.addWidget(self.lstMinerals,  2, 2, 1, 2)
        ly.addWidget(self.btnViewChunk, 3, 1, 1, 2)
        ly.addLayout(elevBox,           4, 0, 1, 4)
        ly.setColumnStretch(0, 20)
        ly.setColumnStretch(1, 15)
        ly.setColumnStretch(2, 46)
        ly.setColumnStretch(3, 19)

        self.setLayout(ly)

    def sizeHint(self):
        return QSize(self.parent.controlsWidth, 180)

    def btnViewChunk_OnClick(self):
        chX = int(self.txtChunkX.text())
        chZ = int(self.txtChunkZ.text())
        self.toChangeChunk.emit((chX, chZ))

    def btnSliceUp_OnClick(self):
        elev = int(self.txtElevation.text()) + 1
        if elev < 64:
            self.toChangeSlice.emit(elev)
            self.txtElevation.setText(str(elev))

    def btnSliceDown_OnClick(self):
        elev = int(self.txtElevation.text()) - 1
        if elev > -1:
            self.toChangeSlice.emit(elev)
            self.txtElevation.setText(str(elev))

    def onSelectedMinerals(self):
        selMin = []
        for item in self.lstMinerals.selectedItems():
            selMin.append(item.blockCode)
        self.parent.selectedMinerals.setSelectedMinerals(selMin)
开发者ID:ydanilin,项目名称:MinecraftMinerals,代码行数:96,代码来源:mcw.py


注:本文中的PySide.QtGui.QListWidget.addItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。