本文整理汇总了Python中AnyQt.QtWidgets.QComboBox.setMinimumWidth方法的典型用法代码示例。如果您正苦于以下问题:Python QComboBox.setMinimumWidth方法的具体用法?Python QComboBox.setMinimumWidth怎么用?Python QComboBox.setMinimumWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtWidgets.QComboBox
的用法示例。
在下文中一共展示了QComboBox.setMinimumWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OWPubmed
# 需要导入模块: from AnyQt.QtWidgets import QComboBox [as 别名]
# 或者: from AnyQt.QtWidgets.QComboBox import setMinimumWidth [as 别名]
class OWPubmed(OWWidget):
name = 'Pubmed'
description = 'Fetch data from Pubmed.'
icon = 'icons/Pubmed.svg'
priority = 20
outputs = [(Output.CORPUS, Corpus)]
want_main_area = False
resizing_enabled = False
QT_DATE_FORMAT = 'yyyy-MM-dd'
PY_DATE_FORMAT = '%Y-%m-%d'
MIN_DATE = date(1800, 1, 1)
# Settings.
recent_emails = Setting([])
author = Setting('')
pub_date_from = Setting('')
pub_date_to = Setting('')
recent_keywords = Setting([])
last_advanced_query = Setting('')
num_records = Setting(1000)
# Text includes checkboxes.
includes_authors = Setting(True)
includes_title = Setting(True)
includes_mesh = Setting(True)
includes_abstract = Setting(True)
includes_url = Setting(True)
class Warning(OWWidget.Warning):
no_query = Msg('Please specify the keywords for this query.')
class Error(OWWidget.Error):
api_error = Msg('API error: {}.')
def __init__(self):
super().__init__()
self.output_corpus = None
self.pubmed_api = None
self.progress = None
self.email_is_valid = False
self.record_count = 0
self.download_running = False
# To hold all the controls. Makes access easier.
self.pubmed_controls = []
h_box = gui.hBox(self.controlArea)
label = gui.label(h_box, self, 'Email:')
label.setMaximumSize(label.sizeHint())
# Drop-down for recent emails.
self.email_combo = QComboBox(h_box)
self.email_combo.setMinimumWidth(150)
self.email_combo.setEditable(True)
self.email_combo.lineEdit().textChanged.connect(self.sync_email)
h_box.layout().addWidget(self.email_combo)
self.email_combo.activated[int].connect(self.select_email)
# RECORD SEARCH
self.search_tabs = gui.tabWidget(self.controlArea)
# --- Regular search ---
regular_search_box = gui.widgetBox(self.controlArea, addSpace=True)
# Author
self.author_input = gui.lineEdit(regular_search_box, self, 'author',
'Author:', orientation=Qt.Horizontal)
self.pubmed_controls.append(self.author_input)
h_box = gui.hBox(regular_search_box)
year_box = gui.widgetBox(h_box, orientation=Qt.Horizontal)
min_date = QDate.fromString(
self.MIN_DATE.strftime(self.PY_DATE_FORMAT),
self.QT_DATE_FORMAT
)
if not self.pub_date_from:
self.pub_date_from = self.MIN_DATE.strftime(self.PY_DATE_FORMAT)
if not self.pub_date_to:
self.pub_date_to = date.today().strftime(self.PY_DATE_FORMAT)
self.date_from = QDateEdit(
QDate.fromString(self.pub_date_from, self.QT_DATE_FORMAT),
displayFormat=self.QT_DATE_FORMAT,
minimumDate=min_date,
calendarPopup=True
)
self.date_to = QDateEdit(
QDate.fromString(self.pub_date_to, self.QT_DATE_FORMAT),
displayFormat=self.QT_DATE_FORMAT,
minimumDate=min_date,
calendarPopup=True
)
self.date_from.dateChanged.connect(
lambda date: setattr(self, 'pub_date_from',
date.toString(self.QT_DATE_FORMAT)))
self.date_to.dateChanged.connect(
lambda date: setattr(self, 'pub_date_to',
#.........这里部分代码省略.........
示例2: FileWidget
# 需要导入模块: from AnyQt.QtWidgets import QComboBox [as 别名]
# 或者: from AnyQt.QtWidgets.QComboBox import setMinimumWidth [as 别名]
class FileWidget(QWidget):
on_open = pyqtSignal(str)
def __init__(self, dialog_title='', dialog_format='',
start_dir=os.path.expanduser('~/'),
icon_size=(12, 20), minimal_width=200,
browse_label='Browse', on_open=None,
reload_button=True, reload_label='Reload',
recent_files=None, directory_aliases=None,
allow_empty=True, empty_file_label='(none)'):
""" Creates a widget with a button for file loading and
an optional combo box for recent files and reload buttons.
Args:
dialog_title (str): The title of the dialog.
dialog_format (str): Formats for the dialog.
start_dir (str): A directory to start from.
icon_size (int, int): The size of buttons' icons.
on_open (callable): A callback function that accepts filepath as the only argument.
reload_button (bool): Whether to show reload button.
reload_label (str): The text displayed on the reload button.
recent_files (List[str]): List of recent files.
directory_aliases (dict): An {alias: dir} dictionary for fast directories' access.
allow_empty (bool): Whether empty path is allowed.
"""
super().__init__()
self.dialog_title = dialog_title
self.dialog_format = dialog_format
self.start_dir = start_dir
self.recent_files = recent_files
self.directory_aliases = directory_aliases or {}
self.check_existence()
self.on_open.connect(on_open)
self.allow_empty = allow_empty
self.empty_file_label = empty_file_label
layout = QHBoxLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
if recent_files is not None:
self.file_combo = QComboBox()
self.file_combo.setMinimumWidth(minimal_width)
self.file_combo.activated[int].connect(self.select)
self.update_combo()
layout.addWidget(self.file_combo)
self.browse_button = QPushButton(browse_label)
self.browse_button.setFocusPolicy(Qt.NoFocus)
self.browse_button.clicked.connect(self.browse)
self.browse_button.setIcon(self.style()
.standardIcon(QStyle.SP_DirOpenIcon))
self.browse_button.setIconSize(QSize(*icon_size))
self.browse_button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
layout.addWidget(self.browse_button)
if reload_button:
self.reload_button = QPushButton(reload_label)
self.reload_button.setFocusPolicy(Qt.NoFocus)
self.reload_button.clicked.connect(self.reload)
self.reload_button.setIcon(self.style()
.standardIcon(QStyle.SP_BrowserReload))
self.reload_button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.reload_button.setIconSize(QSize(*icon_size))
layout.addWidget(self.reload_button)
def browse(self, start_dir=None):
start_dir = start_dir or self.start_dir
path, _ = QFileDialog().getOpenFileName(self, self.dialog_title,
start_dir, self.dialog_format)
if path and self.recent_files is not None:
if path in self.recent_files:
self.recent_files.remove(path)
self.recent_files.insert(0, path)
self.update_combo()
self.open_file(path)
def select(self, n):
name = self.file_combo.currentText()
if n < len(self.recent_files):
name = self.recent_files[n]
del self.recent_files[n]
self.recent_files.insert(0, name)
self.open_file(self.recent_files[0])
self.update_combo()
elif name == self.empty_file_label:
self.open_file(self.empty_file_label)
elif name in self.directory_aliases:
self.browse(self.directory_aliases[name])
def update_combo(self):
if self.recent_files is not None:
self.file_combo.clear()
for file in self.recent_files:
self.file_combo.addItem(os.path.split(file)[1])
if self.allow_empty or not self.recent_files:
#.........这里部分代码省略.........
示例3: FileWidget
# 需要导入模块: from AnyQt.QtWidgets import QComboBox [as 别名]
# 或者: from AnyQt.QtWidgets.QComboBox import setMinimumWidth [as 别名]
class FileWidget(QWidget):
on_open = pyqtSignal(str)
# TODO consider removing directory_aliases since it is not used any more
def __init__(self, dialog_title='', dialog_format='',
start_dir=os.path.expanduser('~/'),
icon_size=(12, 20), minimal_width=200,
browse_label='Browse', on_open=None,
reload_button=True, reload_label='Reload',
recent_files=None, directory_aliases=None,
allow_empty=True, empty_file_label='(none)'):
""" Creates a widget with a button for file loading and
an optional combo box for recent files and reload buttons.
Args:
dialog_title (str): The title of the dialog.
dialog_format (str): Formats for the dialog.
start_dir (str): A directory to start from.
icon_size (int, int): The size of buttons' icons.
on_open (callable): A callback function that accepts filepath as the only argument.
reload_button (bool): Whether to show reload button.
reload_label (str): The text displayed on the reload button.
recent_files (List[str]): List of recent files.
directory_aliases (dict): An {alias: dir} dictionary for fast directories' access.
allow_empty (bool): Whether empty path is allowed.
"""
super().__init__()
self.dialog_title = dialog_title
self.dialog_format = dialog_format
self.start_dir = start_dir
# Recent files should also contain `empty_file_label` so
# when (none) is selected this is stored in settings.
self.recent_files = recent_files if recent_files is not None else []
self.directory_aliases = directory_aliases or {}
self.allow_empty = allow_empty
self.empty_file_label = empty_file_label
if self.empty_file_label not in self.recent_files \
and (self.allow_empty or not self.recent_files):
self.recent_files.append(self.empty_file_label)
self.check_existence()
self.on_open.connect(on_open)
layout = QHBoxLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
if recent_files is not None:
self.file_combo = QComboBox()
self.file_combo.setMinimumWidth(minimal_width)
self.file_combo.activated[int].connect(self.select)
self.update_combo()
layout.addWidget(self.file_combo)
self.browse_button = QPushButton(browse_label)
self.browse_button.setFocusPolicy(Qt.NoFocus)
self.browse_button.clicked.connect(self.browse)
self.browse_button.setIcon(self.style()
.standardIcon(QStyle.SP_DirOpenIcon))
self.browse_button.setIconSize(QSize(*icon_size))
self.browse_button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
layout.addWidget(self.browse_button)
if reload_button:
self.reload_button = QPushButton(reload_label)
self.reload_button.setFocusPolicy(Qt.NoFocus)
self.reload_button.clicked.connect(self.reload)
self.reload_button.setIcon(self.style()
.standardIcon(QStyle.SP_BrowserReload))
self.reload_button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
self.reload_button.setIconSize(QSize(*icon_size))
layout.addWidget(self.reload_button)
def browse(self, start_dir=None):
start_dir = start_dir or self.start_dir
path, _ = QFileDialog().getOpenFileName(self, self.dialog_title,
start_dir, self.dialog_format)
if path and self.recent_files is not None:
if path in self.recent_files:
self.recent_files.remove(path)
self.recent_files.insert(0, path)
self.update_combo()
if path:
self.open_file(path)
def select(self, n):
name = self.file_combo.currentText()
if name == self.empty_file_label:
del self.recent_files[n]
self.recent_files.insert(0, self.empty_file_label)
self.update_combo()
self.open_file(self.empty_file_label)
elif name in self.directory_aliases:
self.browse(self.directory_aliases[name])
elif n < len(self.recent_files):
name = self.recent_files[n]
del self.recent_files[n]
self.recent_files.insert(0, name)
#.........这里部分代码省略.........