本文整理汇总了Python中spyderlib.qt.QtGui.QListWidget.setMinimumWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QListWidget.setMinimumWidth方法的具体用法?Python QListWidget.setMinimumWidth怎么用?Python QListWidget.setMinimumWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spyderlib.qt.QtGui.QListWidget
的用法示例。
在下文中一共展示了QListWidget.setMinimumWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FileSwitcher
# 需要导入模块: from spyderlib.qt.QtGui import QListWidget [as 别名]
# 或者: from spyderlib.qt.QtGui.QListWidget import setMinimumWidth [as 别名]
#.........这里部分代码省略.........
if self.initial_editor in self.paths_by_editor:
index = self.paths.index(self.initial_path)
self.sig_goto_file.emit(index)
def set_dialog_position(self):
"""Positions the file switcher dialog in the center of the editor."""
parent = self.parent()
geo = parent.geometry()
width = self.list.width() # This has been set in setup
left = parent.geometry().width()/2 - width/2
top = 0
while parent:
geo = parent.geometry()
top += geo.top()
left += geo.left()
parent = parent.parent()
# Note: the +1 pixel on the top makes it look better
self.move(left, top + self.tabs.tabBar().geometry().height() + 1)
def fix_size(self, content, extra=50):
"""Adjusts the width of the file switcher, based on the content."""
# Update size of dialog based on longest shortened path
strings = []
if content:
for rich_text in content:
label = QLabel(rich_text)
label.setTextFormat(Qt.PlainText)
strings.append(label.text())
fm = label.fontMetrics()
max_width = max([fm.width(s)*1.3 for s in strings])
self.list.setMinimumWidth(max_width + extra)
self.set_dialog_position()
# --- Helper methods: List widget
def count(self):
"""Gets the item count in the list widget."""
return self.list.count()
def current_row(self):
"""Returns the current selected row in the list widget."""
return self.list.currentRow()
def set_current_row(self, row):
"""Sets the current selected row in the list widget."""
return self.list.setCurrentRow(row)
def select_row(self, steps):
"""Select row in list widget based on a number of steps with direction.
Steps can be positive (next rows) or negative (previous rows).
"""
row = self.current_row() + steps
if 0 <= row < self.count():
self.set_current_row(row)
def previous_row(self):
"""Select previous row in list widget."""
self.select_row(-1)
def next_row(self):
"""Select next row in list widget."""
self.select_row(+1)