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


Python QListWidget.setCurrentRow方法代碼示例

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


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

示例1: GUIdot_cleanMac

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

# 需要導入模塊: from PySide.QtGui import QListWidget [as 別名]
# 或者: from PySide.QtGui.QListWidget import setCurrentRow [as 別名]
class PysideGui(generic.GenericGui):

    def __init__(self):
        generic.GenericGui.__init__(self)
        window = QWidget()
        window.setWindowTitle('quichem-pyside')

        self.compiler_view = QListWidget()
        self.compiler_view.currentRowChanged.connect(self.show_source)
        self.stacked_widget = QStackedWidget()
        self.stacked_widget.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
        self.edit = QLineEdit()
        self.edit.setPlaceholderText('Type quichem input...')
        self.edit.textChanged.connect(self.change_value)
        self.view = QWebView()
        self.view.page().mainFrame().setScrollBarPolicy(Qt.Vertical,
                                                        Qt.ScrollBarAlwaysOff)
        self.view.page().action(QWebPage.Reload).setVisible(False)
        self.view.setMaximumHeight(0)
        self.view.setUrl('qrc:/web/page.html')
        self.view.setZoomFactor(2)
        self.view.page().mainFrame().contentsSizeChanged.connect(
            self._resize_view)
        # For debugging JS:
        ## from PySide.QtWebKit import QWebSettings
        ## QWebSettings.globalSettings().setAttribute(
        ##     QWebSettings.DeveloperExtrasEnabled, True)

        button_image = QPushButton('Copy as Image')
        button_image.clicked.connect(self.set_clipboard_image)
        button_image.setToolTip('Then paste into any graphics program')
        button_word = QPushButton('Copy as MS Word Equation')
        button_word.clicked.connect(self.set_clipboard_word)
        button_html = QPushButton('Copy as Formatted Text')
        button_html.clicked.connect(self.set_clipboard_html)
        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)

        button_layout = QHBoxLayout()
        button_layout.addStretch()
        button_layout.addWidget(button_image)
        button_layout.addWidget(button_word)
        button_layout.addWidget(button_html)
        source_layout = QHBoxLayout()
        source_layout.addWidget(self.compiler_view)
        source_layout.addWidget(self.stacked_widget, 1)
        QVBoxLayout(window)
        window.layout().addWidget(self.edit)
        window.layout().addWidget(self.view)
        window.layout().addLayout(button_layout)
        window.layout().addWidget(line)
        window.layout().addLayout(source_layout, 1)

        window.show()
        window.resize(window.minimumWidth(), window.height())
        # To prevent garbage collection of internal Qt object.
        self._window = window

    def show_source(self, index):
        if not self.sources:
            return
        self.stacked_widget.setCurrentIndex(index)
        self.change_value(self.edit.text())

    def _resize_view(self):
        """Set the QWebView's minimum height based on its current
        contents.

        """
        div = self.view.page().mainFrame().findFirstElement('.output')
        scrollbar_width = QApplication.style().pixelMetric(
            QStyle.PM_ScrollBarExtent)
        self.view.setMaximumHeight(
            div.geometry().height() + scrollbar_width + 16)

    def make_source(self, name):
        self.compiler_view.addItem(name)
        self.compiler_view.setCurrentRow(0)
        scrollbar_width = QApplication.style().pixelMetric(
            QStyle.PM_ScrollBarExtent)
        self.compiler_view.setMaximumWidth(
            self.compiler_view.sizeHintForColumn(0) + scrollbar_width + 16)
        page = QWidget()
        QHBoxLayout(page)
        page.layout().setContentsMargins(*(0,) * 4)
        source = QTextEdit()
        source.setStyleSheet('min-width: 0; min-height: 0')
        source.setReadOnly(True)
        QVBoxLayout(source)
        button = QPushButton('Copy')
        button.clicked.connect(functools.partial(self.set_clipboard, source))
        page.layout().addWidget(source)
        source.layout().addWidget(button, 0, Qt.AlignRight | Qt.AlignBottom)
        self.stacked_widget.addWidget(page)
        return source

    def run_script(self, js):
        self.view.page().mainFrame().evaluateJavaScript(js)

#.........這裏部分代碼省略.........
開發者ID:spamalot,項目名稱:quichem,代碼行數:103,代碼來源:pyside.py


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