本文整理汇总了Python中PyQt5.QtWidgets.QTreeWidget.setMaximumWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QTreeWidget.setMaximumWidth方法的具体用法?Python QTreeWidget.setMaximumWidth怎么用?Python QTreeWidget.setMaximumWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QTreeWidget
的用法示例。
在下文中一共展示了QTreeWidget.setMaximumWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QTreeWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeWidget import setMaximumWidth [as 别名]
class MainWindow(QMainWindow):
def __init__(self, screen_height, screen_width, version, parent=None):
super(MainWindow, self).__init__(parent)
self.screen_width = screen_width
self.screen_height = screen_height
self.version = version
# basic main window settings
self.resize(MAIN_WINDOW_WIDTH, MAIN_WINDOW_HEIGHT)
self.setWindowTitle('Linguistica {}'.format(self.version))
# lexicon and lexicon tree
self.lexicon = None
self.lexicon_tree = None
self.initialize_lexicon_tree()
# set up major display, parameter window, then load main window
self.majorDisplay = QWidget()
self.parameterWindow = QWidget()
self.load_main_window()
# 'File' menu and actions
select_corpus_action = self.create_action(text='&Select corpus...',
slot=self.corpus_dir_dialog,
tip='Select a corpus file',
shortcut='Ctrl+N')
select_wordlist_action = self.create_action(text='&Select wordlist...',
slot=self.wordlist_dir_dialog,
tip='Select a wordlist file',
shortcut='Ctrl+W')
run_file_action = self.create_action(text='&Run...',
slot=self.run_file,
tip='Run the input file',
shortcut='Ctrl+D')
parameters_action = self.create_action(text='&Parameters...',
slot=self.parameters_dialog,
tip='Change parameters',
shortcut='Ctrl+P')
file_menu = self.menuBar().addMenu('&File')
file_menu.addAction(select_corpus_action)
file_menu.addAction(select_wordlist_action)
file_menu.addAction(run_file_action)
file_menu.addAction(parameters_action)
self.status = self.statusBar()
self.status.setSizeGripEnabled(False)
self.status.showMessage('No input file loaded. To select one: File --> '
'Select corpus... or Select wordlist...')
def initialize_lexicon_tree(self):
self.lexicon_tree = QTreeWidget()
self.lexicon_tree.setEnabled(True)
self.lexicon_tree.setMinimumWidth(TREEWIDGET_WIDTH_MIN)
self.lexicon_tree.setMaximumWidth(TREEWIDGET_WIDTH_MAX)
self.lexicon_tree.setMinimumHeight(TREEWIDGET_HEIGHT_MIN)
self.lexicon_tree.setHeaderLabel('')
self.lexicon_tree.setItemsExpandable(True)
# noinspection PyUnresolvedReferences
self.lexicon_tree.itemClicked.connect(self.tree_item_clicked)
def create_action(self, text=None, slot=None, tip=None, shortcut=None):
"""
This create actions for the File menu, things like
Read Corpus, Rerun Corpus etc
"""
action = QAction(text, self)
if shortcut:
action.setShortcut(shortcut)
if tip:
action.setToolTip(tip)
action.setStatusTip(tip)
if slot:
# noinspection PyUnresolvedReferences
action.triggered.connect(slot)
if shortcut:
# noinspection PyUnresolvedReferences
QShortcut(QKeySequence(shortcut), self).activated.connect(slot)
return action
def _get_filename_from_dialog(self, ftype='input'):
self.determine_last_file()
if self.last_file_path and self.last_file_type == ftype:
open_dir = self.last_file_path
else:
open_dir = os.getcwd()
# noinspection PyTypeChecker,PyCallByClass
fname = QFileDialog.getOpenFileName(self,
'Select the {} file'.format(ftype),
open_dir)
process_all_gui_events()
# HACK: fname is supposed to be a string (at least according to the
# PyQt5 documentation), but for some reason fname is a tuple.
# So we need this hack to make sure that fname is a string of a filename
# -- Jackson Lee, 2015/06/22
# update: it's turned out that this behavior is due to compatibility
# between PyQt and PySide. The "tuple" behavior is in line with the
#.........这里部分代码省略.........
示例2: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QTreeWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QTreeWidget import setMaximumWidth [as 别名]
class MainWindow(QMainWindow):
var1 = ""
var2 = ""
def __init__(self):
super(MainWindow, self).__init__()
self.setUpMenus()
CSRWidgets.changeCentralWidget(self, CSRWidgets.createDesignButtons(self, 'default')) #Sets central widget on init.
self.setWindowTitle("CSR Proving Ground")
self.resize(1500, 900)
qr = self.frameGeometry()
cp = QDesktopWidget().availableGeometry().center()
qr.moveCenter(cp)
self.move(qr.topLeft())
def setUpMenus(self):
self.createMenus()
self.createToolBars()
self.createStatusBar()
self.createDockWindows()
def about(self):
QMessageBox.about(self, "C3PO", "His high exaltedness, the Great Jabba the Hutt, has decreed that you are to be terminated immediately.")
def createMenus(self):
CSRWidgets.createActions(self)
self.fileMenu = self.menuBar().addMenu("&File")
self.fileMenu.addSeparator()
self.fileMenu.addAction(self.quitAct)
self.editMenu = self.menuBar().addMenu("&Edit")
self.viewMenu = self.menuBar().addMenu("&View")
self.menuBar().addSeparator()
self.helpMenu = self.menuBar().addMenu("&Help")
self.helpMenu.addAction(self.aboutAct)
def createToolBars(self):
self.homeToolBar = self.addToolBar("Home")
self.homeToolBar.addAction(self.homeAct)
self.homeToolBar.addAction(self.quitAct)
self.searchToolBar = self.addToolBar("Search")
self.searchToolBar.addAction(self.searchAct)
self.searchBar = QLineEdit()
self.searchBar.setMaximumWidth(150)
self.searchBar.returnPressed.connect(self.btnSearch_Click)
self.searchToolBar.addWidget(self.searchBar)
self.searchToolBar.addSeparator()
self.searchToolBar.addAction(self.undoAct)
self.searchToolBar.addSeparator()
btnNameChange = QPushButton('Change Name', self)
btnNameChange.clicked.connect(self.btnNameChange_Click)
self.lblVar1 = QLabel()
self.lblVar1.setFont(QFont('Veranda', 14, QFont.Bold))
#self.lblVar1.setMargin(10)
self.lblVar1.setStyleSheet('padding-left:10px')
self.lblTxtVar1 = QLabel()
self.lblTxtVar1.setFont(QFont('Veranda', 14, QFont.Bold))
#self.lblTxtVar1.setMargin(0)
self.lblTxtVar1.setStyleSheet('padding-left:1px')
self.lblVar2 = QLabel()
self.lblVar2.setFont(QFont('Veranda', 14, QFont.Bold))
self.lblVar2.setMargin(10)
self.lblTxtVar2 = QLabel()
self.lblTxtVar2.setFont(QFont('Veranda', 14, QFont.Bold))
self.lblTxtVar2.setMargin(0)
self.lblSkuName = QLabel()
self.lblSkuName.setFont(QFont('Veranda', 14, QFont.Bold))
self.lblSkuName.setMargin(10)
self.searchToolBar.addWidget(btnNameChange)
self.searchToolBar.addWidget(self.lblVar1)
self.searchToolBar.addWidget(self.lblTxtVar1)
self.searchToolBar.addWidget(self.lblVar2)
self.searchToolBar.addWidget(self.lblTxtVar2)
self.searchToolBar.addWidget(self.lblSkuName)
def createStatusBar(self):
self.statusBar().showMessage("Ready")
def createDockWindows(self):
dock = QDockWidget("Available Garments Types", self)
#dock.setAllowedAreas(Qt.LeftDockWidgetArea | Qt.RightDockWidgetArea)
self.availableItems = QListWidget(dock)
#.........这里部分代码省略.........