本文整理汇总了Python中PyQt5.QtWidgets.QWidget.isVisible方法的典型用法代码示例。如果您正苦于以下问题:Python QWidget.isVisible方法的具体用法?Python QWidget.isVisible怎么用?Python QWidget.isVisible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QWidget
的用法示例。
在下文中一共展示了QWidget.isVisible方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HTMLPopupWidget
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import isVisible [as 别名]
class HTMLPopupWidget(Widget):
'''
Class that represents a widget with popup support.
A Qt Window (QWidget) is created and can be used for drawing, manipulating
this class.
Note: mouseEntersWindow and mouseLeavesWindow should not be replaced with
other functionality (expanding is possible).
'''
def __init__(self, *args, **kwargs):
Widget.__init__(self, *args, **kwargs)
# Create a window which has no border, and which is always on top
self._window = QWidget()
self._window.setWindowFlags(Qt.FramelessWindowHint)
self._window.setWindowFlags(
Qt.X11BypassWindowManagerHint | Qt.WindowStaysOnTopHint)
# Flag which is True when a draw has been requested, but it can not be
# assumed that the focus is in this window.
self.drawrequested = False
# Flag which is True when the mouse is in the window
self.mouseinwindow = False
# If the mouse enters or leaves the window, act!
self._window.enterEvent = self.mouseEntersWindow
self._window.leaveEvent = self.mouseLeavesWindow
# Some colors stuff
self._window.setStyleSheet("QWidget { background-color: #1B1D1E; "
"color: #FFFFFF; border: 2px solid #804000;"
" border-top: none}")
def showPopup(self, top, left):
'''Method to be overwritten.
This method is called when the Window is allowed to show a popup. If
the Widget decides to show a popup, it should call the self._drawPopup
method.'''
raise NotImplemented()
def hidePopup(self):
'''Method to be overwritten. Is called when the Window is supposed to
close it's active popup. If the Widget decides to hide the popup, it
should call the self._hidePopup() method.'''
raise NotImplemented()
#################################
def mouseEntersWindow(self, *args, **kwargs):
self.mouseinwindow = True
def mouseLeavesWindow(self, *args, **kwargs):
self.mouseinwindow = False
self.hidePopupRequest()
def changeGeometry(self, top, left, width, height, autocorrect=True):
self._window.setGeometry(QRect(left, top, width, height))
# TODO: Autocorrect if left+width > screenwidth
def showPopupRequest(self, top, left):
self.drawrequested = True
if not self._window.isVisible():
self.showPopup(top, left)
def hidePopupRequest(self):
self.drawrequested = False
if not self.mouseinwindow and not self.drawrequested:
self.hidePopup()
def _drawPopup(self, top, left, width, height, autocorrect=True):
self.changeGeometry(top, left, width, height, autocorrect)
self._window.show()
self.drawrequested = True
def _hidePopup(self):
self._window.hide()
示例2: LedgerAuthDialog
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import isVisible [as 别名]
#.........这里部分代码省略.........
vbox.addWidget(self.cardbox)
self.pairbox = QWidget()
pairlayout = QVBoxLayout()
self.pairbox.setLayout(pairlayout)
pairhelp = QTextEdit(helpTxt[5])
pairhelp.setStyleSheet("QTextEdit { background-color: lightgray; }")
pairhelp.setReadOnly(True)
pairlayout.addWidget(pairhelp, 1)
self.pairqr = QRCodeWidget()
pairlayout.addWidget(self.pairqr, 4)
self.pairbox.setVisible(False)
vbox.addWidget(self.pairbox)
self.update_dlg()
if self.cfg['mode'] > 1 and not self.ws:
self.req_validation()
def populate_modes(self):
self.modes.blockSignals(True)
self.modes.clear()
self.modes.addItem(_("Summary Text PIN (requires dongle replugging)") if self.txdata['confirmationType'] == 1 else _("Summary Text PIN is Disabled"))
if self.txdata['confirmationType'] > 1:
self.modes.addItem(_("Security Card Challenge"))
if not self.cfg['pair']:
self.modes.addItem(_("Mobile - Not paired"))
else:
self.modes.addItem(_("Mobile - {}").format(self.cfg['pair'][1]))
self.modes.blockSignals(False)
def update_dlg(self):
self.modes.setCurrentIndex(self.cfg['mode'])
self.modebox.setVisible(True)
self.addPair.setText(_("Pair") if not self.cfg['pair'] else _("Re-Pair"))
self.addPair.setVisible(self.txdata['confirmationType'] > 2)
self.helpmsg.setText(helpTxt[self.cfg['mode'] if self.cfg['mode'] < 2 else 2 if self.cfg['pair'] else 4])
self.helpmsg.setMinimumHeight(180 if self.txdata['confirmationType'] == 1 else 100)
self.pairbox.setVisible(False)
self.helpmsg.setVisible(True)
self.pinbox.setVisible(self.cfg['mode'] == 0)
self.cardbox.setVisible(self.cfg['mode'] == 1)
self.pintxt.setFocus(True) if self.cfg['mode'] == 0 else self.cardtxt.setFocus(True)
self.setMaximumHeight(400)
def do_pairing(self):
rng = os.urandom(16)
pairID = (hexlify(rng) + hexlify(hashlib.sha256(rng).digest()[0:1])).decode('utf-8')
self.pairqr.setData(pairID)
self.modebox.setVisible(False)
self.helpmsg.setVisible(False)
self.pinbox.setVisible(False)
self.cardbox.setVisible(False)
self.pairbox.setVisible(True)
self.pairqr.setMinimumSize(300,300)
if self.ws:
self.ws.stop()
self.ws = LedgerWebSocket(self, pairID)
self.ws.pairing_done.connect(self.pairing_done)
self.ws.start()
def pairing_done(self, data):
if data is not None:
self.cfg['pair'] = [ data['pairid'], data['name'], data['platform'] ]
self.cfg['mode'] = 2
self.handler.win.wallet.get_keystore().cfg = self.cfg
self.handler.win.wallet.save_keystore()
self.pin = 'paired'
self.accept()
def req_validation(self):
if self.cfg['pair'] and 'secureScreenData' in self.txdata:
if self.ws:
self.ws.stop()
self.ws = LedgerWebSocket(self, self.cfg['pair'][0], self.txdata)
self.ws.req_updated.connect(self.req_updated)
self.ws.start()
def req_updated(self, pin):
if pin == 'accepted':
self.helpmsg.setText(helpTxt[3])
else:
self.pin = str(pin)
self.accept()
def getDevice2FAMode(self):
apdu = [0xe0, 0x24, 0x01, 0x00, 0x00, 0x01] # get 2fa mode
try:
mode = self.dongle.exchange( bytearray(apdu) )
return mode
except BTChipException as e:
debug_msg('Device getMode Failed')
return 0x11
def closeEvent(self, evnt):
debug_msg("CLOSE - Stop WS")
if self.ws:
self.ws.stop()
if self.pairbox.isVisible():
evnt.ignore()
self.update_dlg()
示例3: __evt_yeahdoc_contextMenu
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import isVisible [as 别名]
#.........这里部分代码省略.........
else:
menu = QMenu()
# menu top
action = QWidgetAction(self)
title = item.text(0)
if len(title) < 25:
for i in range(len(title), 25):
title = title + " "
action.setDefaultWidget(
QLabel(" <img src='%s'/> %s" % (getPath("iconDir", "yeahdoc/item.png"), title)))
menu.addAction(action)
menu.addSeparator()
menu.addAction(self.__actions["__yeahdoc_open__"])
menu.addAction(self.__actions["__yeahdoc_edit__"])
# change class
change_class_menu = QMenu()
entry = YeahdocDatasSupply().bb_read1_simple(item.getMark())
current_categoryid = entry['categoryid']
for class_item in YeahdocDatasSupply().bc_list():
action = QAction(class_item["title"], self, \
triggered=lambda re, item=item, categoryid=str(class_item["id"]): \
self.__evt_change_category(categoryid, item))
action.setIcon(QIcon(getPath("iconDir", "yeahdoc/flag/%s" % str(class_item["img"]))))
action.setIconVisibleInMenu(True)
# mark current class id menu checked
if class_item['id'] == current_categoryid:
action.setCheckable(True)
action.setChecked(True)
action.setDisabled(True)
change_class_menu.addAction(action)
action = QAction(QIcon(getPath("iconDir", "yeahdoc/change.png")),
QApplication.translate("YeahdocList", "Change Category"), self)
action.setIconVisibleInMenu(True)
action.setMenu(change_class_menu)
menu.addAction(action)
menu.addAction(self.__actions["__yeahdoc_star__"])
menu.addAction(self.__actions["__yeahdoc_rename__"])
menu.addAction(self.__actions["__yeahdoc_delete__"])
menu.addSeparator()
setmode = True if entry['lock'] == 0 else False
action = QWidgetAction(self)
widget = QWidget()
layout = QHBoxLayout()
layout.setSpacing(0)
layout.setMargin(0)
widget.setLayout(layout)
widgetMore = QWidget()
widgetMore.setVisible(False)
layoutMore = QHBoxLayout()
layoutMore.setSpacing(0)
layoutMore.setMargin(0)
widgetMore.setLayout(layoutMore)
layout.addWidget(QLabel("<img src='%s'/>" % getPath("iconDir", "yeahdoc/password.png")))
passwordMore = QPushButton(
QApplication.translate("YeahdocEditor", "Encrypt") if setmode else QApplication.translate(
"YeahdocEditor", "Decrypt"))
passwordMore.setFlat(True)
layout.addWidget(passwordMore)
passwordInput = QLineEdit()
passwordInput.setEchoMode(QLineEdit.Password)
passwordInput.setMaximumWidth(70)
layoutMore.addWidget(passwordInput)
if setmode:
passwordInputAgain = QLineEdit()
passwordInputAgain.setEchoMode(QLineEdit.Password)
passwordInputAgain.setMaximumWidth(70)
layoutMore.addWidget(QLabel(QApplication.translate("YeahdocEditor", "Re")))
layoutMore.addWidget(passwordInputAgain)
passwordSubmit = QPushButton("OK")
passwordSubmit.setFlat(True)
layoutMore.addWidget(passwordSubmit)
layout.addWidget(widgetMore)
layout.addItem(QSpacerItem(0, 20, QSizePolicy.Expanding, QSizePolicy.Expanding))
action.setDefaultWidget(widget)
QObject.connect(passwordSubmit, SIGNAL("clicked ()"),
lambda: self.__evt_password(setmode, passwordInput.text(),
passwordInputAgain.text() if setmode else ""))
QObject.connect(passwordMore, SIGNAL("clicked ()"),
lambda: widgetMore.setVisible(not widgetMore.isVisible()))
menu.addAction(action)
# show it.
menu.exec_(self.mapToGlobal(self.yeahdoclisttree.mapTo(self, p)))
示例4: _s_StatusBar
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import isVisible [as 别名]
class _s_StatusBar(QStatusBar):
def __init__(self, parent=None):
super(_s_StatusBar, self).__init__(parent)
self._widgetStatus = QWidget()
vbox = QVBoxLayout(self._widgetStatus)
vbox.setContentsMargins(0, 0, 0, 0)
vbox.setSpacing(0)
#Search Layout
self._searchWidget = SearchWidget(self)
vbox.addWidget(self._searchWidget)
#Replace Layout
self._replaceWidget = ReplaceWidget(self)
vbox.addWidget(self._replaceWidget)
self._replaceWidget.setVisible(False)
#Code Locator
self._codeLocator = locator.CodeLocatorWidget(self)
vbox.addWidget(self._codeLocator)
self._codeLocator.setVisible(False)
#File system completer
self._fileSystemOpener = FileSystemOpener()
vbox.addWidget(self._fileSystemOpener)
self._fileSystemOpener.setVisible(False)
self.addWidget(self._widgetStatus)
self.messageChanged[str].connect(self.message_end)
self._replaceWidget._btnCloseReplace.clicked['bool'].connect(lambda: self._replaceWidget.setVisible(False))
self._replaceWidget._btnReplace.clicked['bool'].connect(self.replace)
self._replaceWidget._btnReplaceAll.clicked['bool'].connect(self.replace_all)
self._replaceWidget._btnReplaceSelection.clicked['bool'].connect(self.replace_selected)
self._fileSystemOpener.btnClose.clicked['bool'].connect(self.hide_status)
self._fileSystemOpener.requestHide.connect(self.hide_status)
def handle_tab_changed(self, new_tab):
"""
Re-run search if tab changed, we use the find of search widget because
we want the widget to be updated.
"""
editor = main_container.MainContainer().get_actual_editor()
if self._searchWidget.isVisible():
self._searchWidget.find_matches(editor)
if editor:
try:
editor.textChanged.disconnect(self._notify_editor_changed)
except Exception:
pass# ignorar la desconexión
editor.textChanged.connect(self._notify_editor_changed)
def _notify_editor_changed(self):
"""
Lets search widget know that the editor contents changed and find
needs to be re-run
"""
if self._searchWidget.isVisible():
editor = main_container.MainContainer().get_actual_editor()
self._searchWidget.contents_changed(editor)
def explore_code(self):
self._codeLocator.explore_code()
def explore_file_code(self, path):
self._codeLocator.explore_file_code(path)
def show(self):
self.clearMessage()
QStatusBar.show(self)
editor = main_container.MainContainer().get_actual_editor()
if editor and editor.textCursor().hasSelection():
text = editor.textCursor().selectedText()
self._searchWidget._line.setText(text)
self._searchWidget.find_matches(editor, True)
if self._widgetStatus.isVisible():
self._searchWidget._line.setFocus()
self._searchWidget._line.selectAll()
def show_replace(self):
self.clearMessage()
self.show()
editor = main_container.MainContainer().get_actual_editor()
if editor:
if editor.textCursor().hasSelection():
word = editor.textCursor().selectedText()
self._searchWidget._line.setText(word)
self._replaceWidget.setVisible(True)
def show_with_word(self):
self.clearMessage()
editor = main_container.MainContainer().get_actual_editor()
if editor:
word = editor._text_under_cursor()
self._searchWidget._line.setText(word)
editor = main_container.MainContainer().get_actual_editor()
editor.moveCursor(QTextCursor.WordLeft)
self._searchWidget.find_matches(editor)
self.show()
def show_locator(self):
if not self._codeLocator.isVisible():
#.........这里部分代码省略.........