本文整理匯總了Python中enaml.qt.QtGui.QApplication.instance方法的典型用法代碼示例。如果您正苦於以下問題:Python QApplication.instance方法的具體用法?Python QApplication.instance怎麽用?Python QApplication.instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類enaml.qt.QtGui.QApplication
的用法示例。
在下文中一共展示了QApplication.instance方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: clearAlert
# 需要導入模塊: from enaml.qt.QtGui import QApplication [as 別名]
# 或者: from enaml.qt.QtGui.QApplication import instance [as 別名]
def clearAlert(self):
""" Clear the current alert level, if any.
"""
if self._alert_data is not None:
self._alert_data.timer.stop()
self._alert_data = None
app = QApplication.instance()
app.focusChanged.disconnect(self._onAppFocusChanged)
self.alerted.emit(u'')
示例2: setUp
# 需要導入模塊: from enaml.qt.QtGui import QApplication [as 別名]
# 或者: from enaml.qt.QtGui.QApplication import instance [as 別名]
def setUp(self):
qt_app = QApplication.instance()
if qt_app is None:
qt_app = QApplication([])
self.qt_app = qt_app
enaml_app = QtApplication.instance()
if enaml_app is None:
enaml_app = QtApplication()
self.enaml_app = enaml_app
self.event_loop_helper = EventLoopHelper(qt_app=self.qt_app)
示例3: alert
# 需要導入模塊: from enaml.qt.QtGui import QApplication [as 別名]
# 或者: from enaml.qt.QtGui.QApplication import instance [as 別名]
def alert(self, level, on=250, off=250, repeat=4, persist=False):
""" Set the alert level on the dock item.
This will override any currently applied alert level.
Parameters
----------
level : unicode
The alert level token to apply to the dock item.
on : int
The duration of the 'on' cycle, in ms. A value of -1 means
always on.
off : int
The duration of the 'off' cycle, in ms. If 'on' is -1, this
value is ignored.
repeat : int
The number of times to repeat the on-off cycle. If 'on' is
-1, this value is ignored.
persist : bool
Whether to leave the alert in the 'on' state when the cycles
finish. If 'on' is -1, this value is ignored.
"""
if self._alert_data is not None:
self.clearAlert()
app = QApplication.instance()
app.focusChanged.connect(self._onAppFocusChanged)
timer = QTimer()
timer.setSingleShot(True)
timer.timeout.connect(self._onAlertTimer)
on, off, repeat = max(-1, on), max(0, off), max(1, repeat)
self._alert_data = _AlertData(timer, level, on, off, repeat, persist)
if on < 0:
self.alerted.emit(level)
else:
self._onAlertTimer()