本文整理汇总了Python中PyQt4.QtCore.QStringList.clear方法的典型用法代码示例。如果您正苦于以下问题:Python QStringList.clear方法的具体用法?Python QStringList.clear怎么用?Python QStringList.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QStringList
的用法示例。
在下文中一共展示了QStringList.clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SCJProgress
# 需要导入模块: from PyQt4.QtCore import QStringList [as 别名]
# 或者: from PyQt4.QtCore.QStringList import clear [as 别名]
class SCJProgress(QHBoxLayout):
def __init__(self, parent=None, file=None, format=None, createDir=False ):
super(SCJProgress, self).__init__(parent)
self.format = format
self.filename = file
self.createDir = createDir
self.process = SCJ(self.filename, self.format, createDir)
self.output = QString(self.process.output)
self.command = QStringList(self.process.command)
self.log = QStringList()
self.label = QLabel(self.output)
self.label.setToolTip(self.trUtf8("Destination: %s" % self.output))
self.bar = QProgressBar(parent)
self.bar.setToolTip(self.trUtf8("Source: %s" % self.filename))
self.bar.setValue(0)
self.startbtn = QPushButton(parent)
self.stopbtn = QPushButton(parent)
self.cancelbtn = QPushButton(parent)
self.logbtn = QPushButton(parent)
self.cancelbtn.setMinimumSize(32,32)
self.cancelbtn.setFlat(True)
self.startbtn.setMinimumSize(32,32)
self.startbtn.setFlat(True)
self.stopbtn.setMinimumSize(32,32)
self.stopbtn.setFlat(True)
self.label.setMinimumSize(200,32)
self.bar.setMinimumSize(100,16)
self.bar.setMaximumHeight(16)
self.addWidget(self.logbtn)
self.logbtn.hide()
self.addWidget(self.label)
self.addWidget(self.bar)
self.addWidget(self.startbtn)
self.addWidget(self.stopbtn)
self.addWidget(self.cancelbtn)
self.retranslateUi()
self.connect(self.startbtn, SIGNAL("clicked()"), self.start)
self.connect(self.stopbtn, SIGNAL("clicked()"), self.stop)
self.connect(self.cancelbtn, SIGNAL("clicked()"), self.remove)
self.connect(self.logbtn, SIGNAL('clicked()'), self.showLog)
self.connect(self.process, SIGNAL('progress(int)'), self.bar.setValue)
self.connect(self.process, SIGNAL('error(QString)'), self.addLog)
self.connect(self.process, SIGNAL('finished()'), self.enable)
def retranslateUi(self):
self.startbtn.setIcon(QIcon(u"images/play.png"))
self.startbtn.setToolTip(self.trUtf8("Demarrer"))
self.stopbtn.setIcon(QIcon(u"images/stop.png"))
self.stopbtn.setToolTip(self.trUtf8("Stopper"))
self.cancelbtn.setIcon(QIcon(u"images/remove.png"))
self.cancelbtn.setToolTip(self.trUtf8("Annuler"))
self.logbtn.setIcon(QIcon(u"images/log.png"))
self.logbtn.setToolTip(self.trUtf8("Voir les details"))
def start(self):
self.log.clear()
self.logbtn.hide()
self.disable()
self.process.start()
self.process.resume()
def stop(self):
self.process.cancel()
self.process.terminate()
self.enable()
def remove(self):
self.removeWidget(self.label)
self.removeWidget(self.bar)
self.removeWidget(self.startbtn)
self.removeWidget(self.stopbtn)
self.removeWidget(self.cancelbtn)
self.removeWidget(self.logbtn)
self.label.hide()
self.bar.hide()
self.startbtn.hide()
self.stopbtn.hide()
self.cancelbtn.hide()
self.logbtn.hide()
self.emit(SIGNAL("void removed(QString)"), self.output)
def showLog(self):
QMessageBox.critical(None, u"Ooops", self.log.join("\n"))
def addLog(self, log):
self.log.append(log)
self.logbtn.show()
palette = QPalette()
brush = QBrush(QColor(240, 100, 100))
brush.setStyle(Qt.SolidPattern)
palette.setBrush(QPalette.Normal, QPalette.Background, brush)
self.label.setPalette(palette)
self.label.setAutoFillBackground(True)
def enable(self):
self.process = SCJ(self.filename, self.format, self.createDir)
self.output = QString(self.process.output)
#.........这里部分代码省略.........
示例2: PylouWidget
# 需要导入模块: from PyQt4.QtCore import QStringList [as 别名]
# 或者: from PyQt4.QtCore.QStringList import clear [as 别名]
class PylouWidget(QGraphicsWidget):
"""Main Widget for Pylou."""
def __init__(self, parent):
"""Init class."""
QGraphicsWidget.__init__(self)
self.applet = parent
def init(self):
"""Start Pylou Widget."""
self.layou = QGraphicsLinearLayout(self)
self.stringlist = QStringList()
self.model = QStringListModel(self.applet)
self.model.setStringList(self.stringlist)
self.treeview = MyTreeView(self)
self.treeview.setModel(self.model)
self.lineEdit, self.label = MyLineEdit(self), Plasma.Label(self)
self.label.setText("Search")
self.layou.setOrientation(0x2) # Qt.Vertical
self.layou.addItem(self.treeview)
self.layou.addItem(self.label)
self.layou.addItem(self.lineEdit)
self.setLayout(self.layou)
self.lineEdit.returnPressed.connect(self.addItem)
self.setMinimumSize(200, 99)
self.setMaximumSize(666, 666)
# custom user choosed fonts
user_font_family = QVariant(self.applet.configurations.readEntry(
"TextFont", QVariant(QFont())))
self.treeview.nativeWidget().setFont(QFont(user_font_family))
# custom user choosed styles
user_style_sheet = "color:{};alternate-background-color:{}".format(
self.applet.configurations.readEntry("TextColor"),
self.applet.configurations.readEntry("AlternateBColor"))
self.treeview.nativeWidget().setStyleSheet(user_style_sheet)
# Qt connecting people
Applet.connect(
self.lineEdit, SIGNAL("keyUPPressed"), self.prevHistoryItem)
Applet.connect(
self.lineEdit, SIGNAL("keyDownPressed"), self.nextHistoryItem)
Applet.connect(self.treeview, SIGNAL("DblClick"), self.openFile)
Applet.connect(self.treeview, SIGNAL("Click"), self.openDirectory)
self.applet.appletDestroyed.connect(self.saveHistory)
# History file
self.histfile = HISTORY_FILE_PATH
with open(self.histfile, 'r') as history_file:
self.history = history_file.readlines()
self.historyCurrentItem = 0
self.treeview.nativeWidget().hide()
self.resize(self.minimumSize())
def saveHistory(self):
"""Write History to History file."""
with open(self.histfile, 'w') as history_file:
history_file.writelines(self.history)
def prevHistoryItem(self):
"""Navigate the History 1 Item Backwards."""
if self.historyCurrentItem < len(self.history):
self.historyCurrentItem = self.historyCurrentItem + 1
try:
self.lineEdit.setText(str(self.history[-self.historyCurrentItem]))
except IndexError as error:
print(error)
self.label.setText("ERROR: History Empty.")
def nextHistoryItem(self):
"""Navigate the History 1 Item Forwards."""
if self.historyCurrentItem > 1:
self.historyCurrentItem = self.historyCurrentItem - 1
try:
self.lineEdit.setText(str(self.history[-self.historyCurrentItem]))
except IndexError as error:
print(error)
self.label.setText("ERROR: History Empty.")
def addItem(self):
"""Add Items from Locate command."""
start_time = datetime.now().second
self.stringlist.clear()
lineText = self.lineEdit.text()
if len(lineText) and str(lineText).strip() not in self.history:
self.history.append(lineText + "\n")
self.historyCurrentItem = 1
self.saveHistory()
self.historyCurrentItem = self.historyCurrentItem - 1
command = "ionice --ignore --class 3 chrt --idle 0 " # Nice CPU / IO
command += "locate --ignore-case --existing --quiet --limit 9999 {}"
condition = str(self.applet.configurations.readEntry("Home")) == "true"
if len(str(lineText).strip()) and condition:
command_to_run = command.format( # Only Search inside Home folders
path.join(path.expanduser("~"), "*{}*".format(lineText)))
else:
command_to_run = command.format(lineText)
locate_output = Popen(command_to_run, shell=True, stdout=PIPE).stdout
results = tuple(locate_output.readlines())
banned = self.applet.configurations.readEntry("Banned")
banned_regex_pattern = str(banned).strip().lower().replace(" ", "|")
for item in results:
#.........这里部分代码省略.........