本文整理汇总了Python中PySide.QtGui.QListWidget.setMaximumWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QListWidget.setMaximumWidth方法的具体用法?Python QListWidget.setMaximumWidth怎么用?Python QListWidget.setMaximumWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtGui.QListWidget
的用法示例。
在下文中一共展示了QListWidget.setMaximumWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setMaximumWidth [as 别名]
def __init__(self, parent=None):
super(EditPreferencesDlg, self).__init__(parent)
self.setWindowTitle("Preferences")
# define widgets
pref_list = QListWidget()
pref_list.addItem("General")
pref_list.addItem("Display")
pref_list.setMaximumWidth(150)
pref_list.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding)
button_box = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel)
general_page = QWidget()
general_layout = QGridLayout()
general_layout.setAlignment(Qt.AlignTop)
general_layout.addWidget(QLabel("<b>General</b>"), 0, 0)
general_page.setLayout(general_layout)
display_page = QWidget()
display_layout = QGridLayout()
display_layout.setAlignment(Qt.AlignTop)
display_layout.addWidget(QLabel("<b>Display Options</b>"), 0, 0)
self.multitabs_checkbox = QCheckBox("Limit the display of tabs to one relief device (and the device's scenarios) at a time")
if parent.limit_tabs is True:
self.multitabs_checkbox.setChecked(True)
display_layout.addWidget(self.multitabs_checkbox, 1, 0)
display_page.setLayout(display_layout)
stacked_widget = QStackedWidget()
for page in general_page, display_page:
stacked_widget.addWidget(page)
main_layout = QVBoxLayout()
widgets_layout = QHBoxLayout()
widgets_layout.addWidget(pref_list)
widgets_layout.addWidget(stacked_widget)
buttons_layout = QHBoxLayout()
buttons_layout.addStretch()
buttons_layout.addWidget(button_box)
main_layout.addLayout(widgets_layout)
main_layout.addLayout(buttons_layout)
self.setLayout(main_layout)
pref_list.currentRowChanged.connect(stacked_widget.setCurrentIndex)
button_box.accepted.connect(self.accept)
button_box.rejected.connect(self.reject)
示例2: ConfigEditor
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setMaximumWidth [as 别名]
class ConfigEditor(QMainWindow):
def __init__(self, app, cfg, title='Config Editor'):
super(ConfigEditor, self).__init__()
self.app = app
self.config = cfg
self.title = title
def setup(self):
self.dirty = False
self.def_cfg = copy.deepcopy(self.config)
self.config.update_from_user_file()
self.base_cfg = copy.deepcopy(self.config)
self.categories = QListWidget()
#self.categories.setSizePolicy(QSizePolicy.Fixed,QSizePolicy.Expanding)
self.settings = QStackedWidget()
#self.categories.setSizePolicy(QSizePolicy.MinimumExpanding,QSizePolicy.Expanding)
QObject.connect(self.categories, SIGNAL('itemSelectionChanged()'), self.category_selected)
self.widget_list = {}
for cat in self.config.get_categories():
self.widget_list[cat] = {}
longest_cat = 0
for cat in self.config.get_categories():
if len(cat) > longest_cat:
longest_cat = len(cat)
self.categories.addItem(cat)
settings_layout = QGridLayout()
r = 0
c = 0
for setting in self.config.get_settings(cat):
info = self.config.get_setting(cat, setting, True)
s = QWidget()
s.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed)
sl = QVBoxLayout()
label = QLabel()
if info.has_key('alias'):
label.setText(info['alias'])
else:
label.setText(setting)
if info.has_key('about'):
label.setToolTip(info['about'])
sl.addWidget(label)
if info['type'] == constants.CT_LINEEDIT:
w = LineEdit(self, self.config,cat,setting,info)
elif info['type'] == constants.CT_CHECKBOX:
w = CheckBox(self, self.config,cat,setting,info)
elif info['type'] == constants.CT_SPINBOX:
w = SpinBox(self, self.config,cat,setting,info)
elif info['type'] == constants.CT_DBLSPINBOX:
w = DoubleSpinBox(self, self.config,cat,setting,info)
elif info['type'] == constants.CT_COMBO:
w = ComboBox(self, self.config,cat,setting,info)
w.setSizePolicy(QSizePolicy.Expanding,QSizePolicy.Fixed)
self.widget_list[cat][setting] = w
sl.addWidget(w)
s.setLayout(sl)
c = self.config.config[cat].index(setting) % 2
settings_layout.addWidget(s, r, c)
if c == 1:
r += 1
settings = QWidget()
settings.setLayout(settings_layout)
settings_scroller = QScrollArea()
settings_scroller.setWidget(settings)
settings_scroller.setWidgetResizable(True)
self.settings.addWidget(settings_scroller)
font = self.categories.font()
fm = QFontMetrics(font)
self.categories.setMaximumWidth(fm.widthChar('X')*(longest_cat+4))
self.main = QWidget()
self.main_layout = QVBoxLayout()
self.config_layout = QHBoxLayout()
self.config_layout.addWidget(self.categories)
self.config_layout.addWidget(self.settings)
self.mainButtons = QDialogButtonBox(QDialogButtonBox.RestoreDefaults | QDialogButtonBox.Reset | QDialogButtonBox.Apply)
self.main_apply = self.mainButtons.button(QDialogButtonBox.StandardButton.Apply)
self.main_reset = self.mainButtons.button(QDialogButtonBox.StandardButton.Reset)
self.main_defaults = self.mainButtons.button(QDialogButtonBox.StandardButton.LastButton)
QObject.connect(self.mainButtons, SIGNAL('clicked(QAbstractButton *)'), self.mainbutton_clicked)
self.dirty_check()
self.main_layout.addLayout(self.config_layout)
self.main_layout.addWidget(self.mainButtons)
self.main.setLayout(self.main_layout)
self.setCentralWidget(self.main)
self.setWindowTitle(self.title)
self.setUnifiedTitleAndToolBarOnMac(True)
#.........这里部分代码省略.........
示例3: PysideGui
# 需要导入模块: from PySide.QtGui import QListWidget [as 别名]
# 或者: from PySide.QtGui.QListWidget import setMaximumWidth [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)
#.........这里部分代码省略.........