当前位置: 首页>>代码示例>>Python>>正文


Python SwingUtilities.isEventDispatchThread方法代码示例

本文整理汇总了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))
开发者ID:ctn-waterloo,项目名称:nengo_java_gui,代码行数:16,代码来源:reversible.py

示例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()
开发者ID:HenryStevens,项目名称:jes,代码行数:9,代码来源:threading.py

示例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()
开发者ID:TimO-CIMSS,项目名称:mcidasv,代码行数:10,代码来源:decorators.py

示例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()
开发者ID:TimO-CIMSS,项目名称:mcidasv,代码行数:10,代码来源:decorators.py

示例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())
开发者ID:gbtami,项目名称:storytext,代码行数:11,代码来源:util.py

示例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)
开发者ID:talwai,项目名称:jygsaw,代码行数:15,代码来源:graphicswindow.py

示例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)
开发者ID:URVnutrigenomica-CTNS,项目名称:VHELIBS,代码行数:16,代码来源:swing.py

示例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()
开发者ID:mhiley,项目名称:mcidasv,代码行数:18,代码来源:decorators.py

示例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()
开发者ID:URVnutrigenomica-CTNS,项目名称:VHELIBS,代码行数:19,代码来源:swing.py

示例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)
开发者ID:HenryStevens,项目名称:jes,代码行数:6,代码来源:threading.py

示例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)
开发者ID:bgr,项目名称:unnamed_gui_tool,代码行数:5,代码来源:javautils.py


注:本文中的javax.swing.SwingUtilities.isEventDispatchThread方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。