本文整理汇总了Python中PyQt5.QtWidgets.QListView.update方法的典型用法代码示例。如果您正苦于以下问题:Python QListView.update方法的具体用法?Python QListView.update怎么用?Python QListView.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QListView
的用法示例。
在下文中一共展示了QListView.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MDIHistory
# 需要导入模块: from PyQt5.QtWidgets import QListView [as 别名]
# 或者: from PyQt5.QtWidgets.QListView import update [as 别名]
class MDIHistory(QWidget, _HalWidgetBase):
def __init__(self, parent=None):
super(MDIHistory, self).__init__(parent)
self.setMinimumSize(QSize(300, 200))
self.setWindowTitle("PyQt5 editor test example")
lay = QVBoxLayout()
lay.setContentsMargins(0,0,0,0)
self.setLayout(lay)
self.list = QListView()
self.list.setEditTriggers(QListView.NoEditTriggers)
self.list.activated.connect(self.activated)
self.list.setAlternatingRowColors(True)
self.list.selectionChanged = self.selectionChanged
self.model = QStandardItemModel(self.list)
self.MDILine = MDILine()
self.MDILine.soft_keyboard = False
self.MDILine.line_up = self.line_up
self.MDILine.line_down = self.line_down
# add widgets
lay.addWidget(self.list)
lay.addWidget(self.MDILine)
self.reload()
def _hal_init(self):
STATUS.connect('state-off', lambda w: self.setEnabled(False))
STATUS.connect('state-estop', lambda w: self.setEnabled(False))
STATUS.connect('interp-idle', lambda w: self.setEnabled(STATUS.machine_is_on()
and (STATUS.is_all_homed()
or INFO.NO_HOME_REQUIRED)))
STATUS.connect('interp-run', lambda w: self.setEnabled(not STATUS.is_auto_mode()))
STATUS.connect('all-homed', lambda w: self.setEnabled(STATUS.machine_is_on()))
def reload(self, w=None ):
print 'RELOAD'
try:
fp = os.path.expanduser(INFO.MDI_HISTORY_PATH)
with open(fp,'r') as inputfile:
for line in inputfile:
line = line.rstrip('\n')
item = QStandardItem(line)
self.model.appendRow(item)
self.list.setModel(self.model)
self.list.scrollToBottom()
except Exception as e:
print e
LOG.error('File path is not valid: {}]n,()'.format(fp),e)
def line_up(self):
print 'up'
def line_down(self):
print 'down'
def selectionChanged(self,old, new):
cmd = self.getSelected()
self.MDILine.setText(cmd)
def getSelected(self):
selected_indexes = self.list.selectedIndexes()
selected_rows = [item.row() for item in selected_indexes]
# iterates each selected row in descending order
for selected_row in sorted(selected_rows, reverse=True):
text = self.model.item(selected_row).text()
return text
def activated(self):
cmd = self.getSelected()
self.MDILine.setText(cmd)
self.MDILine.submit()
item = QStandardItem(cmd)
self.model.appendRow(item)
self.list.update()
#########################################################################
# This is how designer can interact with our widget properties.
# designer will show the pyqtProperty properties in the editor
# it will use the get set and reset calls to do those actions
#########################################################################
def set_soft_keyboard(self, data):
self.MDILine.soft_keyboard = data
def get_soft_keyboard(self):
return self.MDILine.soft_keyboard
def reset_soft_keyboard(self):
self.MDILine.soft_keyboard = False
# designer will show these properties in this order:
soft_keyboard_option = pyqtProperty(bool, get_soft_keyboard, set_soft_keyboard, reset_soft_keyboard)
示例2: AppletNoticeWindow
# 需要导入模块: from PyQt5.QtWidgets import QListView [as 别名]
# 或者: from PyQt5.QtWidgets.QListView import update [as 别名]
class AppletNoticeWindow(QWidget):
def __init__(self, controller):
super(AppletNoticeWindow, self).__init__()
self.__controller = controller
self.__pkglist = []
# setup widgets
self.__vbox_up = QVBoxLayout()
self.__critical_label = QLabel()
self.__critical_label.setWordWrap(True)
self.__list_model = QStringListModel()
self.__list_view = QListView()
self.__list_view.setModel(self.__list_model)
self.__vbox_up.addWidget(self.__critical_label)
self.__vbox_up.addWidget(self.__list_view)
# bottom buttons
self.__vbox = QVBoxLayout()
self.__vbox.addLayout(self.__vbox_up)
self.__button_hbox = QHBoxLayout()
self.__close_button = QPushButton(_("Close"))
self.__launch_pm_button = QPushButton(_("Launch Application Browser"))
self.__button_hbox.addWidget(self.__launch_pm_button)
self.__button_hbox.addWidget(self.__close_button)
self.__vbox.addLayout(self.__button_hbox)
self.setLayout(self.__vbox)
# set window settings
self.resize(400, 200)
self.setWindowTitle(_("Application updates"))
self.__close_button.clicked.connect(self.on_close)
self.__launch_pm_button.clicked.connect(self.on_pm)
def closeEvent(self, event):
"""
We don't want to kill the window, since the whole app will close
otherwise.
"""
event.ignore()
self.on_close()
def on_pm(self):
self.__controller.launch_package_manager()
def on_close(self):
self.__controller.trigger_notice_window()
def populate(self, pkg_data, critical_txt):
self.__list_model.setStringList(pkg_data)
self.__critical_label.setText(critical_txt)
self.__list_view.update()