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


Python SwingUtilities.invokeLater方法代码示例

本文整理汇总了Python中javax.swing.SwingUtilities.invokeLater方法的典型用法代码示例。如果您正苦于以下问题:Python SwingUtilities.invokeLater方法的具体用法?Python SwingUtilities.invokeLater怎么用?Python SwingUtilities.invokeLater使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.SwingUtilities的用法示例。


在下文中一共展示了SwingUtilities.invokeLater方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run_example

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [as 别名]
def run_example(network, runner):
    """Used to conveniently create a NengoGraphics instance
    with an existing Network model.

    """
    if isinstance(network, UINetwork):
        model = network
        model_ui = network
    elif isinstance(network, NetworkImpl):
        model = network
        nengo = NengoGraphics()

        task = TrackedStatusMsg("Creating Model UI")
        model_ui = UINetwork(model)
        nengo.world.ground.addChild(model_ui)
        model_ui.openViewer()
        task.finished()

    print "Running example: " + network.name

    # All UI functions and constructors must be invoked from the Swing
    # Event Thread

    if not isinstance(runner, Runnable):
        runner = make_runnable(runner)
    SwingUtilities.invokeLater(runner)
开发者ID:ctn-waterloo,项目名称:nengo_java_gui,代码行数:28,代码来源:__init__.py

示例2: _swingRunner

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [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

示例3: runSwingLater

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [as 别名]
def runSwingLater(func, *args, **kwargs):
    """
    Queues the given task to be run in the Event Dispatch Thread, regardless
    of whether the calling thread is the EDT itself.

    """
    runnable = RunnableWrapper(func, args, kwargs)
    SwingUtilities.invokeLater(runnable)
开发者ID:URVnutrigenomica-CTNS,项目名称:VHELIBS,代码行数:10,代码来源:swing.py

示例4: undoAction

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [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

示例5: runSwing

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [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

示例6: buildNetwork

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [as 别名]
    def buildNetwork(self, network):
        network.name = "Integrator"

        # Util.debugMsg("Network building started")

        f = ConstantFunction(1, 1.0)
        input = FunctionInput("input", [f], Units.UNK)

        # uiViewer.addNeoNode(uiInput);

        ef = NEFEnsembleFactoryImpl()
        integrator = ef.make("integrator", 500, 1, "integrator1", False)
        interm = integrator.addDecodedTermination("input", [[tau]], tau, False)
        fbterm = integrator.addDecodedTermination("feedback", [[1.0]], tau, False)

        network.addNode(integrator)
        time.sleep(1)
        network.addNode(input)
        time.sleep(1)
        # UINEFEnsemble uiIntegrator = new UINEFEnsemble(integrator);
        # uiViewer.addNeoNode(uiIntegrator);
        # uiIntegrator.collectSpikes(true);

        # UITermination uiInterm =
        # uiIntegrator.showTermination(interm.getName());
        # UITermination uiFbterm =
        # uiIntegrator.showTermination(fbterm.getName());

        network.addProjection(input.getOrigin(FunctionInput.ORIGIN_NAME), interm)
        time.sleep(0.5)
        network.addProjection(integrator.getOrigin(NEFEnsemble.X), fbterm)
        time.sleep(0.5)

        # Test removing projections
        network.removeProjection(interm)
        time.sleep(0.5)
        # add the projection back
        network.addProjection(input.getOrigin(FunctionInput.ORIGIN_NAME), interm)
        time.sleep(0.5)
        # Add probes
        integratorXProbe = network.simulator.addProbe("integrator", NEFEnsemble.X, True)
        time.sleep(0.5)
        # Test adding removing probes
        network.simulator.removeProbe(integratorXProbe)
        time.sleep(0.5)
        # add the probe back
        network.simulator.addProbe("integrator", NEFEnsemble.X, True)
        time.sleep(0.5)

        SwingUtilities.invokeLater(make_runnable(self.doPostUIStuff))
开发者ID:ctn-waterloo,项目名称:nengo_java_gui,代码行数:52,代码来源:integrator.py

示例7: _swingRunner

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [as 别名]
def _swingRunner(func, *args, **kwargs):
    # the naming of this function, along with _swingWaitForResult, is kinda
    # misleading; both functions will "wait" for the result (due to the get()).
    # the difference between the two is that this function "wraps" invokeLater,
    # while _swingWaitForResult "wraps" invokeAndWait.
    #
    # the real world difference is that this function appends to the end of the
    # event dispatch thread, while _swingWaitForResult puts its Task at the
    # beginning of the queue.
    if SwingUtilities.isEventDispatchThread():
        return func(*args, **kwargs)
    else:
        wrappedCode = _JythonCallable(func, args, kwargs)
        task = FutureTask(wrappedCode)
        SwingUtilities.invokeLater(task)
        return task.get()
开发者ID:mhiley,项目名称:mcidasv,代码行数:18,代码来源:decorators.py

示例8: toInt

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [as 别名]
     self.started = Calendar.getInstance().getTimeInMillis();
     #print self.textfield1.getText()  
     #time.sleep(5)
     iters = toInt(self.textfield1.getText())
     jocl_smoother(iters)
     elapsed = Calendar.getInstance().getTimeInMillis() - self.started;
     self.clockLabel.setText( 'JOCL Elapsed: %.2f seconds' % ( float( elapsed ) / 1000.0 ) )
    
    def onJava(self, e): 
     self.clockLabel.setText('running')
     self.started = Calendar.getInstance().getTimeInMillis();
     #print self.textfield1.getText()  
     #time.sleep(5)
     iters = toInt(self.textfield1.getText())
     java_smoother(iters)
     elapsed = Calendar.getInstance().getTimeInMillis() - self.started;
     self.clockLabel.setText( 'Java Elapsed: %.2f seconds' % ( float( elapsed ) / 1000.0 ) )
     

     
     
    
if ( __name__ == '__main__' ) or ( __name__ == 'main' ) :
    SwingUtilities.invokeLater( Demo() )
    raw_input();
    sys.exit();
else :
  print 'Error - script must be executed, not imported.\n';
  print 'Usage: jython %s.py\n' % __name__;
  print '   or: wsadmin -conntype none -f %s.py' % __name__;
开发者ID:ke0m,项目名称:jtk,代码行数:32,代码来源:LocalSmoothingFilterOpenCLDemo.py

示例9: invokeLater

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [as 别名]
def invokeLater(func, *args, **kwargs):
    """Convenience method for SwingUtilities.invokeLater()."""
    SwingUtilities.invokeLater(ProcRunnable(func, *args, **kwargs))
    return
开发者ID:151706061,项目名称:Slicer3,代码行数:6,代码来源:runutils.py

示例10: Almost

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [as 别名]
  equal = False
  while not equal and digits>0:
    almost = Almost(digits)
    equal = almost.equal(xa,xb)
    if not equal:
      digits -= 1
  return digits

def dot(u,v):
  return sum(mul(u,v))

def zfloat(n1,n2):
  return zerofloat(n1,n2)

def rfloat(n1,n2):
  r = randfloat(random,n1,n2)
  sub(r,0.5,r)
  mul(2.0,r,r)
  return r

##############################################################################
# Do everything on Swing thread.

import sys
from java.lang import Runnable
from javax.swing import SwingUtilities
class RunMain(Runnable):
  def run(self):
    main(sys.argv)
SwingUtilities.invokeLater(RunMain())
开发者ID:amunozNFX,项目名称:lss,代码行数:32,代码来源:adjointExamples.py

示例11: buttonInputReceived

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [as 别名]
    def buttonInputReceived(self, evt):
#        print("Wiimote Button event: ", evt)
        self.sync.acquire()
        self.evt = evt
        self.sync.release()
        SwingUtilities.invokeLater(self) # Delegate processing to Swing thread (when we are here, we're in the WiiRemoteJ driver thread)
开发者ID:Klb4ever,项目名称:JMRI,代码行数:8,代码来源:WiimoteThrottle.py

示例12: invokeLater

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [as 别名]
def invokeLater(fn, *args, **kwargs):
    task = FunctionCall(fn, args, kwargs)
    SwingUtilities.invokeLater(task)
开发者ID:HenryStevens,项目名称:jes,代码行数:5,代码来源:threading.py

示例13: postAction

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [as 别名]
 def postAction(self):
     """Only add the action once to the Action manager."""
     if not self.finished and isinstance(self, ReversibleAction):
         SwingUtilities.invokeLater(RunWrapper(
             lambda: nengoinstance.actionManager.addReversibleAction(self)))
开发者ID:ctn-waterloo,项目名称:nengo_java_gui,代码行数:7,代码来源:reversible.py

示例14: later

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [as 别名]
def later(f, *args, **kwargs):
    SwingUtilities.invokeLater(Later(f, args, kwargs))
    return f
开发者ID:aeriksson,项目名称:geogebra,代码行数:5,代码来源:gui.py

示例15: updateTextArea

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeLater [as 别名]
 def updateTextArea(self, text):
     """ generated source for method updateTextArea """
     SwingUtilities.invokeLater(Runnable())
开发者ID:hobson,项目名称:ggpy,代码行数:5,代码来源:ConsolePanel.py


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