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


Python QListWidget.clear方法代码示例

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


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

示例1: PropertyBar

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import clear [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

示例2: SideBar

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import clear [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

示例3: Console

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import clear [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

示例4: MultiListDialog

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import clear [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

示例5: SubscriberDialog

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import clear [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

示例6: ListEditor

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import clear [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

示例7: mainwin

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

#.........这里部分代码省略.........
		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:
				if len(lis) >= 2:
					for i in range(1, len(lis)):
						if lis[i] == addw:
							c = 0
							pass
					if c == 1:
						lis.append(addw)
				else:
					lis.append(addw)
				lis[0] = len(lis) - 1

	def addtobkmli(self, addw, lis, nc=1):
		for i in range(len(lis)):
			if lis[i] == addw:
				nc = 0
				pass
		if nc == 1:
			lis.append(addw)

	def onenter(self, *args):
		self.comboBox.selectAll()
开发者ID:jnoortheen,项目名称:nigandu,代码行数:70,代码来源:mainwin.py

示例8: ProfileSelection

# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import clear [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


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