4/29/2023 0 Comments Pyqt5 popup window![]() ![]() focusWidget () while focus_widget_ancestor is not None : if focus_widget_ancestor is self : return True try : focus_widget_ancestor = focus_widget_ancestor. Also note that we can't use Qt's isAncestorOf() function to check ancestry, since combo box drop downs are considered to be their own window and isAncestorOf() requires ancestors to be part of the same window. As a result, we check the full ancestry of the focus widget here rather than just checking it's parent. :note: Note that combo boxes have various list view and frame children that can receive focus (and which of these widgets can receive focus varies by OS). def subWidgetHasFocus ( self ): """ Return True if any widget within the pop up has focus. pyqtSignal ( str ) popUpResized = QtCore. :vartype visibilit圜hanged: QtCore.pyqtSignal """ dataChanged = QtCore. Includes whether the pop up is now visible (`True`) or not (`False`). ![]() :vartype popUpResized: `` :cvar visibilit圜hanged: A signal emitted when the pop up is shown or hidden. ![]() The line edit will respond by repositioning the pop up. :vartype dataChanged: `` :cvar popUpResized: A signal emitted when the size of the pop up changes. This signal is emitted with the desired contents of the line edit (str). :cvar dataChanged: A signal emitted when a change in the pop up should trigger a change in the contents of the line edit. Important Note: at least one strong focus widget should be part of the popup dialog, otherwise a widget's focus policy should be set to `Qt.StrongFocus` in order for the popup closing behavior to execute properly. Subclasses may also emit dataChanged and popUpResized when appropriate. This class is not intended to be instantiated directly and should be subclassed. QFrame ): """ The base class for pop up widgets. REJECT if the user closed the pop up by pressing Esc - ACCEPT if the user closed the pop up by hitting Enter or by shifting focus - ACCEPT_MULTI if the user closed the pop up by hitting Ctrl+Enter - UNKNOWN if the event that closed the widget is not known (this happens when we use the Qt.PopUp window flag to do the popup closing for us) """ These enums are emitted by the popUpClosing signal. Enum ( "PopUpAlignment", ) ( REJECT, ACCEPT, ACCEPT_MULTI, UNKNOWN ) = list ( range ( 4 )) """ Constants representing what event triggered the closing of a popup. """ import enum import sys import weakref import schrodinger.ui.qt.utils as qt_utils from schrodinger.Qt import QtCore from schrodinger.Qt import QtGui from schrodinger.Qt import QtWidgets from schrodinger.Qt.QtCore import Qt from schrodinger.ui.qt.standard.icons import icons from schrodinger.ui.qt.standard_widgets import hyperlink PopUpAlignment = enum. `_init_` takes the `PopUp` subclass as an argument. Instantiate `LineEditWithPopUp` for a stand-alone line edit or `PopUpDelegate` for a table delegate. In `setup()`, define and layout the desired widgets. To create a new pop up editor: - Create a subclass of `PopUp`. 最後串接QDialog的 finished()函式定設定Result就可以了! self._(self.finish_dialog) def finish_dialog(self, code): self._tResult(self.""" Widgets for creating a line edit with a pop up editor. 設定按鈕 def set_buttons(self): """Setup buttons""" self._nd_btn.setText('Send Msg') self._window.exit_btn.setText('Exit') ret22_button = QPushButton('Ret 22') ret10_button = QPushButton('Ret 10') self._window.dialogbtn_tLayout(QVBoxLayout()) self._window.dialogbtn_widget.layout().addWidget(ret22_button) self._window.dialogbtn_widget.layout().addWidget(ret10_button) ret22_(self.ret22_clicked) ret10_(self.ret10_clicked) self._window.exit_(self.exit) def ret22_clicked(self): self._ret = 22 self._window.close() def ret10_clicked(self): self._ret = 10 self._window.close() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |