當前位置: 首頁>>代碼示例>>Python>>正文


Python QListWidget.currentItem方法代碼示例

本文整理匯總了Python中PySide.QtGui.QListWidget.currentItem方法的典型用法代碼示例。如果您正苦於以下問題:Python QListWidget.currentItem方法的具體用法?Python QListWidget.currentItem怎麽用?Python QListWidget.currentItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PySide.QtGui.QListWidget的用法示例。


在下文中一共展示了QListWidget.currentItem方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: GUIdot_cleanMac

# 需要導入模塊: from PySide.QtGui import QListWidget [as 別名]
# 或者: from PySide.QtGui.QListWidget import currentItem [as 別名]
class GUIdot_cleanMac(QDialog):
    def __init__(self, parent = None):
        super(GUIdot_cleanMac, self).__init__(parent)
        siguiente_btn = QPushButton('Siguiente')
        layout = QVBoxLayout()
        layout.addWidget(QLabel('Seleccione memoria:'))
        hlayout = QHBoxLayout()
        hlayout.addStretch()
        hlayout.addWidget(siguiente_btn)
        self.lista = QListWidget()
        nodos = self.getNodos()
        self.lista.addItems(nodos)
        layout.addWidget(self.lista)
        layout.addLayout(hlayout)
        layout.addWidget(QLabel('Hecho por: www.ehmsoft.com'))
        self.setLayout(layout)
        self.connect(siguiente_btn, SIGNAL('clicked()'), self.siguienteClicked)
        self.setWindowTitle('Dot Clean')
        if len(nodos) > 0:
            self.lista.setCurrentRow(0)

    def getNodos(self): #Lista todos los volumenes y quita el Disco Duro del sistema
        path = '/Volumes'
        folders = os.listdir(path)
        try:
            folders.remove('Macintosh HD')
        except ValueError:
            carpetas = copy.copy(folders)
            for folder in carpetas:
                if os.path.isdir(os.path.join('/Volumes', folder)):
                    if os.path.exists(os.path.join('/Volumes', folder, 'Applications')):
                        folders.remove(folder)
        finally:
            return folders
        
    def dot_clean(self, path):
        return os.system('dot_clean %s' % path)
    
    def siguienteClicked(self):
        if self.lista.currentItem():
            selected = self.lista.currentItem().text()
            path = os.path.join('/Volumes', selected)
            if self.dot_clean(path) == 0:
                title = 'Proceso exitoso'
                msg = u'Se limpió la memoria con éxito'
            else:
                title = 'Proceso fallido'
                msg = u'Ocurrió un error inesperado. Verifique que la memoria esté montada.'
        else:
            title = 'Proceso fallido'
            msg = u'No se encuentra ninguna memoria, por favor introduzca una y vuelva a iniciar la apliación'
        QMessageBox.information(self, title, msg)
        self.close()
開發者ID:ehmsoft,項目名稱:GUIdot_cleanMac,代碼行數:55,代碼來源:GUIdot_cleanMac.py

示例2: Console

# 需要導入模塊: from PySide.QtGui import QListWidget [as 別名]
# 或者: from PySide.QtGui.QListWidget import currentItem [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


注:本文中的PySide.QtGui.QListWidget.currentItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。