本文整理汇总了Python中PyQt5.QtWidgets.QWidget.setWindowFlags方法的典型用法代码示例。如果您正苦于以下问题:Python QWidget.setWindowFlags方法的具体用法?Python QWidget.setWindowFlags怎么用?Python QWidget.setWindowFlags使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtWidgets.QWidget
的用法示例。
在下文中一共展示了QWidget.setWindowFlags方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SquidGui
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setWindowFlags [as 别名]
class SquidGui( QMainWindow ):
defaults = {}
defaults.update(SquidAxon.defaults)
defaults.update(ClampCircuit.defaults)
defaults.update({'runtime': 50.0,
'simdt': 0.01,
'plotdt': 0.1,
'vclamp.holdingV': 0.0,
'vclamp.holdingT': 10.0,
'vclamp.prepulseV': 0.0,
'vclamp.prepulseT': 0.0,
'vclamp.clampV': 50.0,
'vclamp.clampT': 20.0,
'iclamp.baseI': 0.0,
'iclamp.firstI': 0.1,
'iclamp.firstT': 40.0,
'iclamp.firstD': 5.0,
'iclamp.secondI': 0.0,
'iclamp.secondT': 0.0,
'iclamp.secondD': 0.0
})
def __init__(self, *args):
QMainWindow.__init__(self, *args)
self.squid_setup = SquidSetup()
self._plotdt = SquidGui.defaults['plotdt']
self._plot_dict = defaultdict(list)
self.setWindowTitle('Squid Axon simulation')
self.setDockNestingEnabled(True)
self._createRunControl()
self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self._runControlDock)
self._runControlDock.setFeatures(QDockWidget.AllDockWidgetFeatures)
self._createChannelControl()
self._channelCtrlBox.setWindowTitle('Channel properties')
self._channelControlDock.setFeatures(QDockWidget.AllDockWidgetFeatures)
self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self._channelControlDock)
self._createElectronicsControl()
self._electronicsDock.setFeatures(QDockWidget.AllDockWidgetFeatures)
self._electronicsDock.setWindowTitle('Electronics')
self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self._electronicsDock)
self._createPlotWidget()
self.setCentralWidget(self._plotWidget)
self._createStatePlotWidget()
self._createHelpMessage()
self._helpWindow.setVisible(False)
self._statePlotWidget.setWindowFlags(QtCore.Qt.Window)
self._statePlotWidget.setWindowTitle('State plot')
self._initActions()
self._createRunToolBar()
self._createPlotToolBar()
def getFloatInput(self, widget, name):
try:
return float(str(widget.text()))
except ValueError:
QMessageBox.critical(self, 'Invalid input', 'Please enter a valid number for {}'.format(name))
raise
def _createPlotWidget(self):
self._plotWidget = QWidget()
self._plotFigure = Figure()
self._plotCanvas = FigureCanvas(self._plotFigure)
self._plotCanvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self._plotCanvas.updateGeometry()
self._plotCanvas.setParent(self._plotWidget)
self._plotCanvas.mpl_connect('scroll_event', self._onScroll)
self._plotFigure.set_canvas(self._plotCanvas)
# Vm and command voltage go in the same subplot
self._vm_axes = self._plotFigure.add_subplot(2,2,1, title='Membrane potential')
self._vm_axes.set_ylim(-20.0, 120.0)
# Channel conductances go to the same subplot
self._g_axes = self._plotFigure.add_subplot(2,2,2, title='Channel conductance')
self._g_axes.set_ylim(0.0, 0.5)
# Injection current for Vclamp/Iclamp go to the same subplot
self._im_axes = self._plotFigure.add_subplot(2,2,3, title='Injection current')
self._im_axes.set_ylim(-0.5, 0.5)
# Channel currents go to the same subplot
self._i_axes = self._plotFigure.add_subplot(2,2,4, title='Channel current')
self._i_axes.set_ylim(-10, 10)
for axis in self._plotFigure.axes:
axis.set_autoscale_on(False)
layout = QVBoxLayout()
layout.addWidget(self._plotCanvas)
self._plotNavigator = NavigationToolbar(self._plotCanvas, self._plotWidget)
layout.addWidget(self._plotNavigator)
self._plotWidget.setLayout(layout)
def _createStatePlotWidget(self):
self._statePlotWidget = QWidget()
self._statePlotFigure = Figure()
self._statePlotCanvas = FigureCanvas(self._statePlotFigure)
self._statePlotCanvas.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self._statePlotCanvas.updateGeometry()
self._statePlotCanvas.setParent(self._statePlotWidget)
self._statePlotFigure.set_canvas(self._statePlotCanvas)
self._statePlotFigure.subplots_adjust(hspace=0.5)
self._statePlotAxes = self._statePlotFigure.add_subplot(2,1,1, title='State plot')
self._state_plot, = self._statePlotAxes.plot([], [], label='state')
self._activationParamAxes = self._statePlotFigure.add_subplot(2,1,2, title='H-H activation parameters vs time')
self._activationParamAxes.set_xlabel('Time (ms)')
#.........这里部分代码省略.........
示例2: MyApp
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setWindowFlags [as 别名]
class MyApp(QtWidgets.QMainWindow):
mouseLeaveTimer=0
def __init__(self):
# Ui_MainWindow.__init__(self)
#自己有__init__函数时,不会默认调用基类的__init__函数
# 因为这里重写了__init__将基类的覆盖掉了,故需要主动调用之
# QtWidgets.QMainWindow.__init__(self)
# super(MyApp,self).__init__()
#上面两句的作用是相同的,下面这句是python3的新写法
super().__init__()
# Get the Screen size
self.screenWidth=QDesktopWidget().availableGeometry().width()
self.screenHeight=QDesktopWidget().availableGeometry().height()
#初始化字体
font=QFont('黑体')
font.setPointSize(12)
app.setFont(font)
# ColorSetting
self.bgColor=QColor(66,66,77,88)
#
# self.setupUi(self)
self.initUI()
#用来控制半透明的bg面板自动消失
self.timer=QTimer()
self.timer.start(30)
self.setGeometry(0,30,self.screenWidth,self.screenHeight//3)
#Flagsq
self.IsMouseHover=False
self.MouseOver=False
self.Locked=False
self.Hidden=False
self.isDrag=False
self.isResize=False
#变量初始化
GLOBAL.WINDOWWIDTH=self.width()
GLOBAL.WINDOWHEIGHT=self.height()
self.bullets=[]
self.dragPos=QPoint(22,22)
self.savedName=''
# self.screenBuffer=QBitmap(GLOBAL.WINDOWWIDTH,GLOBAL.WINDOWHEIGHT)
# self.bufferPainter=QPainter(self.screenBuffer)
# self.picture=QPicture()
# 建立connection和slot的回调连接
self.createConnections()
# 连接到nodejs建立的服务器
self.connect2Server()
def initUI(self):
#构建托盘
self.trayIcon=QSystemTrayIcon(self)
self.trayIcon.setIcon(QtGui.QIcon("tmpIcon.ico"))
self.trayIcon.show()
self.trayIcon.setToolTip('BulletGo')
# 构建托盘菜单
action_quit=QAction('退出',self)
action_quit.triggered.connect(self.exitApp)
action_switchLock=QAction('锁定/解锁(F6)',self)
action_switchLock.triggered.connect(self.switchLock)
action_showHide=QAction('显示/隐藏(F7)',self)
action_showHide.triggered.connect(lambda:self.switchVisible(self))
action_Settings=QAction('设置',self)
action_Settings.triggered.connect(lambda:self.switchVisible(self.settingWindow))
trayIconMenu=QtWidgets.QMenu(self)
trayIconMenu.addAction(action_switchLock)
trayIconMenu.addAction(action_showHide)
trayIconMenu.addSeparator()
trayIconMenu.addAction(action_Settings)
trayIconMenu.addAction(action_quit)
#设定快捷键
QtWidgets.QShortcut(QtGui.QKeySequence(\
QtCore.Qt.Key_F7),self,\
(lambda:self.switchVisible(self.settingWindow)))
QtWidgets.QShortcut(QtGui.QKeySequence(\
QtCore.Qt.Key_F6),self,\
(self.switchLock))
self.trayIcon.setContextMenu(trayIconMenu)
# 保障不按下鼠标也追踪mouseMove事件
self.setMouseTracking(True)
self.setMinimumSize(600,260)
self.setWindowTitle("BulletGo")
sizeGrip=QtWidgets.QSizeGrip(self)
self.setWindowFlags(Qt.FramelessWindowHint\
|Qt.WindowStaysOnTopHint|Qt.Window|\
Qt.X11BypassWindowManagerHint)
#Plan A
self.setAttribute(Qt.WA_TranslucentBackground,True)
#这一句是给Mac系统用的,防止它绘制(很黯淡的)背景
self.setAutoFillBackground(False)
QSizeGrip(self).setVisible(True)
sizeGrip.setVisible(True)
#Plan B 失败
# palette=QPalette()
# color=QColor(190, 230, 250)
#.........这里部分代码省略.........
示例3: QWidget
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setWindowFlags [as 别名]
from PyQt5.QtWidgets import QSpinBox, QWidget, QVBoxLayout
from PyQt5.QtCore import Qt
w = QWidget()
w.setWindowFlags(Qt.WindowStaysOnTopHint)
w.setAttribute(Qt.WA_ShowWithoutActivating)
vbox = QVBoxLayout()
vbox.addStretch(1)
w.setLayout(vbox)
w.setWindowTitle('Test editor')
w.resize(300,100)
w.show()
b = QSpinBox()
vbox.addWidget(b)
b.valueChanged.connect(PINS.value.set)
示例4: HTMLPopupWidget
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setWindowFlags [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()
示例5: SystemTrayIcon
# 需要导入模块: from PyQt5.QtWidgets import QWidget [as 别名]
# 或者: from PyQt5.QtWidgets.QWidget import setWindowFlags [as 别名]
class SystemTrayIcon(QSystemTrayIcon):
newWindowRequested = Signal()
windowReopenRequested = Signal()
def __init__(self, parent=None):
super(SystemTrayIcon, self).__init__(common.app_icon, parent)
# Set tooltip.
self.setToolTip(common.app_name)
self.widget = QWidget(None)
self.widget.resize(0, 0)
self.widget.setWindowFlags(Qt.FramelessWindowHint)
# Set context menu.
self.menu = QMenu(None)
self.setContextMenu(self.menu)
# New window action
newWindowAction = QAction(common.complete_icon("window-new"), tr("&New Window"), self)
newWindowAction.triggered.connect(self.newWindowRequested.emit)
self.menu.addAction(newWindowAction)
# Reopen window action
reopenWindowAction = QAction(common.complete_icon("reopen-window"), tr("R&eopen Window"), self)
reopenWindowAction.triggered.connect(self.reopenWindow)
self.menu.addAction(reopenWindowAction)
self.menu.addSeparator()
self.sessionManager = session.SessionManager(None)
# Load session action
loadSessionAction = QAction(common.complete_icon("document-open"), tr("&Load Session..."), self)
loadSessionAction.triggered.connect(self.loadSession)
self.menu.addAction(loadSessionAction)
# Save session action
saveSessionAction = QAction(common.complete_icon("document-save-as"), tr("Sa&ve Session..."), self)
saveSessionAction.triggered.connect(self.saveSession)
self.menu.addAction(saveSessionAction)
self.menu.addSeparator()
# Settings action
settingsAction = QAction(common.complete_icon("preferences-system"), tr("&Settings..."), self)
settingsAction.triggered.connect(self.openSettings)
self.menu.addAction(settingsAction)
# Clippings manager
clippingsAction = QAction(common.complete_icon("edit-paste"), tr("&Manage Clippings..."), self)
clippingsAction.triggered.connect(self.openClippings)
self.menu.addAction(clippingsAction)
self.menu.addSeparator()
# About Nimbus action.
aboutAction = QAction(common.complete_icon("help-about"), tr("A&bout %s") % (common.app_name,), self)
aboutAction.triggered.connect(self.about)
self.menu.addAction(aboutAction)
# Quit action
quitAction = QAction(common.complete_icon("application-exit"), tr("Quit"), self)
quitAction.triggered.connect(QApplication.quit)
self.menu.addAction(quitAction)
"""if self.geometry().width() < 8:
self.toolBar = BackgroundToolBar(None)
self.toolBar.setWindowTitle(common.app_name)
#self.toolBar.setStyleSheet("QToolBar{background:palette(window);border:0;}")
self.button = QToolButton(self.toolBar)
self.button.setIcon(common.app_icon)
self.button.clicked.connect(self.showMenu)
self.toolBar.addWidget(self.button)
extender = QLabel(common.app_name, self.toolBar)
self.toolBar.addWidget(extender)
self.toolBar.hide()
timer = QTimer(timeout=self.toggleButton, parent=self)
timer.start(500)"""
def dontBeImpatient(self):
self.showMessage(tr("You already clicked this button"), tr("Don't be impatient."))
def toggleButton(self):
if len(browser.windows) == 0:
self.toolBar.show()
else:
self.toolBar.hide()
# About.
def about(self):
try: parent = browser.activeWindow()
except:
parent = self.widget
self.widget.show()
QMessageBox.about(parent, tr("About %s") % (common.app_name,),\
"<h3>" + common.app_name + " " +\
common.app_version +\
"</h3>" +\
tr("A Qt-based web browser made in Python.<br><br>%s is provided to you free of charge, with no promises of security or stability. By using this software, you agree not to sue me for anything that goes wrong with it.") % (common.app_name,))
self.widget.hide()
#.........这里部分代码省略.........