当前位置: 首页>>代码示例>>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;未经允许,请勿转载。