本文整理汇总了Python中javax.swing.SwingUtilities.isEventDispatchThread方法的典型用法代码示例。如果您正苦于以下问题:Python SwingUtilities.isEventDispatchThread方法的具体用法?Python SwingUtilities.isEventDispatchThread怎么用?Python SwingUtilities.isEventDispatchThread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.SwingUtilities
的用法示例。
在下文中一共展示了SwingUtilities.isEventDispatchThread方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: undoAction
# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import isEventDispatchThread [as 别名]
def undoAction(self):
"""Undo the action."""
if not self.finished:
messages.showError("Action was never done, so it can't be undone")
return
"""Does the action layer, starts an appropriate thread"""
if self.spawn_thread and SwingUtilities.isEventDispatchThread():
threading.Thread(target=self.undoInternal).start()
elif self.spawn_thread or SwingUtilities.isEventDispatchThread():
# In the thread we want to be
self.undoInternal()
else:
SwingUtilities.invokeLater(RunWrapper(self.undoInternal))
示例2: invokeThreadsafe
# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import isEventDispatchThread [as 别名]
def invokeThreadsafe(fn, *args, **kwargs):
if SwingUtilities.isEventDispatchThread():
return fn(*args, **kwargs)
else:
task = FunctionCall(fn, args, kwargs)
SwingUtilities.invokeAndWait(task)
return task.getResult()
示例3: _swingWaitForResult
# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import isEventDispatchThread [as 别名]
def _swingWaitForResult(func, *args, **kwargs):
if SwingUtilities.isEventDispatchThread():
return func(*args, **kwargs)
wrappedCode = _JythonCallable(func, args, kwargs)
task = FutureTask(wrappedCode)
SwingUtilities.invokeAndWait(task)
return task.get()
示例4: _swingRunner
# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import isEventDispatchThread [as 别名]
def _swingRunner(func, *args, **kwargs):
if SwingUtilities.isEventDispatchThread():
return func(*args, **kwargs)
else:
wrappedCode = _JythonCallable(func, args, kwargs)
task = FutureTask(wrappedCode)
SwingUtilities.invokeLater(task)
return task.get()
示例5: runOnEventDispatchThread
# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import isEventDispatchThread [as 别名]
def runOnEventDispatchThread(method, *args):
class EDTRunnable(Runnable):
def run(self):
method(*args)
if SwingUtilities.isEventDispatchThread():
method(*args)
else:
SwingUtilities.invokeAndWait(EDTRunnable())
示例6: redraw
# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import isEventDispatchThread [as 别名]
def redraw(self, delay=0.0):
"""
Redraws the :py:class:`~jygsaw.graphicswindow.Canvas`.
Only returns when done. An optional float can also be used to sleep after redrawing.
"""
# Use non-blocking redraw because there is no one-to-one relation
# between calling cavas.repaint() and execution of paintComponent()
#
if SwingUtilities.isEventDispatchThread():
self.frame.contentPane.repaint()
else:
self.frame.contentPane.blocking_redraw()
sleep(delay)
示例7: runSwing
# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import isEventDispatchThread [as 别名]
def runSwing(func, *args, **kwargs):
"""
Runs the given function in the Event Dispatch Thread.
If this is invoked inside the EDT, the given function will be run normally.
Otherwise, it'll be queued to be run later.
:return: None
"""
if SwingUtilities.isEventDispatchThread():
func(*args, **kwargs)
else:
runnable = RunnableWrapper(func, args, kwargs)
SwingUtilities.invokeLater(runnable)
示例8: _swingWaitForResult
# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import isEventDispatchThread [as 别名]
def _swingWaitForResult(func, *args, **kwargs):
# the naming of this function, along with _swingRunner, is kinda
# misleading; both functions will "wait" for the result (due to the get()).
# the difference between the two is that this function "wraps"
# invokeAndWait, while _swingRunner "wraps" invokeLater.
#
# the real world difference is that this function puts its Task at the
# beginning of the event dispatch thread, while _swingRunner appends to the
# end of the queue.
if SwingUtilities.isEventDispatchThread():
return func(*args, **kwargs)
wrappedCode = _JythonCallable(func, args, kwargs)
task = FutureTask(wrappedCode)
SwingUtilities.invokeAndWait(task)
return task.get()
示例9: callSwing
# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import isEventDispatchThread [as 别名]
def callSwing(func, *args, **kwargs):
"""
Runs the given function in the Event Dispatch Thread.
If this is invoked inside the EDT, the given function will be run normally.
Otherwise, it'll be queued to be run and the calling thread will block
until the function has been executed.
:return: func's return value
"""
if SwingUtilities.isEventDispatchThread():
return func(*args, **kwargs)
callable = CallableWrapper(func, args, kwargs)
task = FutureTask(callable)
SwingUtilities.invokeAndWait(task)
return task.get()
示例10: decorated
# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import isEventDispatchThread [as 别名]
def decorated(*args, **kwargs):
if not SwingUtilities.isEventDispatchThread():
raise RuntimeError("Not on the AWT event dispatch thread")
return fn(*args, **kwargs)
示例11: run
# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import isEventDispatchThread [as 别名]
def run(self):
assert SwingUtilities.isEventDispatchThread(), "not on EDT"
self.func(*self.args, **self.kwargs)