本文整理汇总了Python中PyQt5.QtWidgets.QCompleter.popup方法的典型用法代码示例。如果您正苦于以下问题:Python QCompleter.popup方法的具体用法?Python QCompleter.popup怎么用?Python QCompleter.popup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QCompleter
的用法示例。
在下文中一共展示了QCompleter.popup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MainWindow
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import popup [as 别名]
#.........这里部分代码省略.........
self.plusplus = QCheckBox("Compile C++ Only on generated source files")
self.experimental = QCheckBox("Experimental features")
self.force_clang = QCheckBox("Force use of CLang")
self.force_mingw = QCheckBox("Force use of MinGW on MS Windows")
self.force_lto = QCheckBox("Use link time optimizations LTO")
self.show_scons = QCheckBox("Show Scons executed commands")
self.show_progress = QCheckBox("Show progress info and statistics")
self.show_summary = QCheckBox("Show final summary of included modules")
self.disable_console = QCheckBox("Disable the Console on MS Windows")
for i, widget in enumerate((
self.module, self.standalone, self.nofreeze, self.python_debug,
self.warning, self.recurse_std, self.recurse_not, self.execute,
self.pythonpath, self.enhaced, self.nolineno, self.rmbuilddir,
self.nuitka_debug, self.keep_debug, self.traced, self.plusplus,
self.experimental, self.force_clang, self.force_mingw,
self.force_lto, self.show_scons, self.show_progress,
self.show_summary, self.disable_console)):
widget.setToolTip(widget.text())
g0grid.addWidget(widget, i if i < i + 1 else i - (i - 1), i % 2)
# group 1 paths
self.target = QLineEdit()
self.outdir = QLineEdit(os.path.expanduser("~"))
self.t_icon = QLineEdit()
self.target.setToolTip("Python App file you want to Compile to Binary")
self.outdir.setToolTip("Folder to write Compiled Output Binary files")
self.t_icon.setToolTip("Icon image file to embed for your Python App")
self.target.setPlaceholderText("/full/path/to/target/python_app.py")
self.outdir.setPlaceholderText("/full/path/to/output/folder/")
self.t_icon.setPlaceholderText("/full/path/to/python_app/icon.png")
self.completer, self.dirs = QCompleter(self), QDirModel(self)
self.completer.setModel(self.dirs)
self.completer.setCaseSensitivity(Qt.CaseInsensitive)
self.completer.setCompletionMode(QCompleter.PopupCompletion)
self.completer.popup().setStyleSheet("border: 1px solid gray")
self.completer.popup().setVerticalScrollBarPolicy(
Qt.ScrollBarAlwaysOff)
self.outdir.setCompleter(self.completer)
self.t_icon.setCompleter(self.completer)
self.target.setCompleter(self.completer)
self.clear_1 = QPushButton(QIcon.fromTheme("edit-clear"), "", self,
clicked=lambda: self.target.clear())
self.clear_2 = QPushButton(QIcon.fromTheme("edit-clear"), "", self,
clicked=lambda: self.t_icon.clear())
self.clear_3 = QPushButton(QIcon.fromTheme("edit-clear"), "", self,
clicked=lambda: self.outdir.clear())
self.open_1 = QPushButton(
QIcon.fromTheme("folder-open"), "", self, clicked=lambda:
self.target.setText(str(QFileDialog.getOpenFileName(
self, __doc__, os.path.expanduser("~"), """Python (*.py);;
Python for Windows (*.pyw);;All (*.*)""")[0])))
self.open_2 = QPushButton(
QIcon.fromTheme("folder-open"), "", self, clicked=lambda:
self.t_icon.setText(str(QFileDialog.getOpenFileName(
self, __doc__, os.path.expanduser("~"),
"PNG (*.png);;JPG (*.jpg);;ICO (*.ico);;All (*.*)")[0])))
self.open_3 = QPushButton(
QIcon.fromTheme("folder-open"), "", self, clicked=lambda:
self.outdir.setText(str(QFileDialog.getExistingDirectory(
self, __doc__, os.path.expanduser("~")))))
self.l_icon = QLabel("Target Icon")
g1vlay.addWidget(QLabel("<b>Target Python"), 0, 0)
g1vlay.addWidget(self.target, 0, 1)
g1vlay.addWidget(self.clear_1, 0, 2)
g1vlay.addWidget(self.open_1, 0, 3)
g1vlay.addWidget(self.l_icon, 1, 0)
g1vlay.addWidget(self.t_icon, 1, 1)
示例2: HelpWebSearchWidget
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import popup [as 别名]
#.........这里部分代码省略.........
self.__model.item(0) != self.__suggestionsItem):
self.__model.clear()
self.__suggestionsItem = None
else:
self.__model.removeRows(1, self.__model.rowCount() - 1)
boldFont = QFont()
boldFont.setBold(True)
if self.__suggestions:
if self.__model.rowCount() == 0:
if not self.__suggestionsItem:
self.__suggestionsItem = QStandardItem(
self.tr("Suggestions"))
self.__suggestionsItem.setFont(boldFont)
self.__model.appendRow(self.__suggestionsItem)
for suggestion in self.__suggestions:
self.__model.appendRow(QStandardItem(suggestion))
if not self.__recentSearches:
self.__recentSearchesItem = QStandardItem(
self.tr("No Recent Searches"))
self.__recentSearchesItem.setFont(boldFont)
self.__model.appendRow(self.__recentSearchesItem)
else:
self.__recentSearchesItem = QStandardItem(
self.tr("Recent Searches"))
self.__recentSearchesItem.setFont(boldFont)
self.__model.appendRow(self.__recentSearchesItem)
for recentSearch in self.__recentSearches:
self.__model.appendRow(QStandardItem(recentSearch))
view = self.__completer.popup()
view.setFixedHeight(view.sizeHintForRow(0) * self.__model.rowCount() +
view.frameWidth() * 2)
self.__searchButton.setEnabled(
bool(self.__recentSearches or self.__suggestions))
def __completerActivated(self, index):
"""
Private slot handling the selection of an entry from the completer.
@param index index of the item (QModelIndex)
"""
if self.__suggestionsItem and \
self.__suggestionsItem.index().row() == index.row():
return
if self.__recentSearchesItem and \
self.__recentSearchesItem.index().row() == index.row():
return
self.__searchNow()
def __completerHighlighted(self, index):
"""
Private slot handling the highlighting of an entry of the completer.
@param index index of the item (QModelIndex)
@return flah indicating a successful highlighting (boolean)
"""
if self.__suggestionsItem and \
self.__suggestionsItem.index().row() == index.row():
return False
示例3: __init__
# 需要导入模块: from PyQt5.QtWidgets import QCompleter [as 别名]
# 或者: from PyQt5.QtWidgets.QCompleter import popup [as 别名]
#.........这里部分代码省略.........
self.stackedWidget.setCurrentIndex(PAGE_LOADING)
# Create the system tray icon
if QSystemTrayIcon.isSystemTrayAvailable():
self.tray_icon = QSystemTrayIcon()
use_monochrome_icon = get_gui_setting(self.gui_settings, "use_monochrome_icon", False, is_bool=True)
self.update_tray_icon(use_monochrome_icon)
# Create the tray icon menu
menu = self.create_add_torrent_menu()
show_downloads_action = QAction('Show downloads', self)
show_downloads_action.triggered.connect(self.clicked_menu_button_downloads)
token_balance_action = QAction('Show token balance', self)
token_balance_action.triggered.connect(lambda: self.on_token_balance_click(None))
quit_action = QAction('Quit Tribler', self)
quit_action.triggered.connect(self.close_tribler)
menu.addSeparator()
menu.addAction(show_downloads_action)
menu.addAction(token_balance_action)
menu.addSeparator()
menu.addAction(quit_action)
self.tray_icon.setContextMenu(menu)
else:
self.tray_icon = None
self.hide_left_menu_playlist()
self.left_menu_button_debug.setHidden(True)
self.top_menu_button.setHidden(True)
self.left_menu.setHidden(True)
self.token_balance_widget.setHidden(True)
self.settings_button.setHidden(True)
self.add_torrent_button.setHidden(True)
self.top_search_bar.setHidden(True)
# Set various icons
self.top_menu_button.setIcon(QIcon(get_image_path('menu.png')))
self.search_completion_model = QStringListModel()
completer = QCompleter()
completer.setModel(self.search_completion_model)
completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
self.item_delegate = QStyledItemDelegate()
completer.popup().setItemDelegate(self.item_delegate)
completer.popup().setStyleSheet("""
QListView {
background-color: #404040;
}
QListView::item {
color: #D0D0D0;
padding-top: 5px;
padding-bottom: 5px;
}
QListView::item:hover {
background-color: #707070;
}
""")
self.top_search_bar.setCompleter(completer)
# Toggle debug if developer mode is enabled
self.window().left_menu_button_debug.setHidden(
not get_gui_setting(self.gui_settings, "debug", False, is_bool=True))
# Start Tribler
self.core_manager.start(core_args=core_args, core_env=core_env)
self.core_manager.events_manager.torrent_finished.connect(self.on_torrent_finished)
self.core_manager.events_manager.new_version_available.connect(self.on_new_version_available)
self.core_manager.events_manager.tribler_started.connect(self.on_tribler_started)
self.core_manager.events_manager.events_started.connect(self.on_events_started)
self.core_manager.events_manager.low_storage_signal.connect(self.on_low_storage)
self.core_manager.events_manager.credit_mining_signal.connect(self.on_credit_mining_error)
self.core_manager.events_manager.tribler_shutdown_signal.connect(self.on_tribler_shutdown_state_update)
self.core_manager.events_manager.upgrader_tick.connect(
lambda text: self.show_status_bar("Upgrading Tribler database: " + text))
self.core_manager.events_manager.upgrader_finished.connect(
lambda _: self.hide_status_bar())
self.core_manager.events_manager.received_search_result.connect(
self.search_results_page.received_search_result)
# Install signal handler for ctrl+c events
def sigint_handler(*_):
self.close_tribler()
signal.signal(signal.SIGINT, sigint_handler)
self.installEventFilter(self.video_player_page)
# Resize the window according to the settings
center = QApplication.desktop().availableGeometry(self).center()
pos = self.gui_settings.value("pos", QPoint(center.x() - self.width() * 0.5, center.y() - self.height() * 0.5))
size = self.gui_settings.value("size", self.size())
self.move(pos)
self.resize(size)
self.show()