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


Python SwingUtilities.invokeAndWait方法代码示例

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


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

示例1: invokeThreadsafe

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

示例2: _swingWaitForResult

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

示例3: action

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeAndWait [as 别名]
 def action(self):
     node = ModelFactory.constructModel(constructable)
     if node is None:
         raise Exception("No model was created")
     elif isinstance(node, Node):
         SwingUtilities.invokeAndWait(make_runnable(self.add_and_open))
     else:
         raise Exception("Can not add model of the type: " + node.class.simpleName)
开发者ID:ctn-waterloo,项目名称:nengo_java_gui,代码行数:10,代码来源:reversible.py

示例4: runOnEventDispatchThread

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

示例5: snapshot

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeAndWait [as 别名]
def snapshot(frame, box):
    bi = BufferedImage(box.width, box.height, BufferedImage.TYPE_INT_RGB)
    g = bi.createGraphics()
    g.translate(-box.x, -box.y)
    # all black! # frame.paintAll(g)
    # only swing components! # frame.paint(g)
    # only swing components! # frame.update(g)
    # together, also only swing and with errors
    ##frame.update(g)
    ##frame.paint(g)
    # locks the entire graphics machinery # frame.printAll(g)
    # Finally, the right one:
    SwingUtilities.invokeAndWait(PrintAll(frame, g))
    return bi
开发者ID:Mverp,项目名称:fiji,代码行数:16,代码来源:Record_Window.py

示例6: _swingWaitForResult

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

示例7: callSwing

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

示例8: readInput

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeAndWait [as 别名]
    def readInput(self, message):
	#to be threadsafe on this call we need this to update the command window
	class outputPromptRunner(Runnable):
	    def __init__(self, cw, m):
		self.commandWindow = cw
		self.message = m
		
	    def run(self):
		#display the message and reenable the window to editing
		self.commandWindow.showText(self.message)
		self.commandWindow.setCaretPosition(self.commandWindow.document.getLength() )
		self.commandWindow.setKeymap(self.commandWindow.my_keymap)


	#--------------The Actual work goes here------------------
	
	if not message:
	    message = ""

	#first assign value to null
	self.value = None

	#note that the this interpreter thread needs to wait now
	#until a result comes back from the command window
	self.waitingFlag = True
    
	#update the command window with the ouput
	SwingUtilities.invokeAndWait(outputPromptRunner(self.commandWindow, message))

	#Now we wait for the user to input a value and press ENTER in the command window,
	#pausing a 10th of a second between checks.
	while self.waitingFlag:
		time.sleep(0.1)

	#clean up the return value to remove the prompt since the command
	#window will give us everything
	self.value = self.value[len(message):]

	#return the value to media.py
	return self.value
开发者ID:Alli1223,项目名称:Comp120-moodboard,代码行数:42,代码来源:JESInputManager.py

示例9: invokeAndWait

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

示例10: resizeImage

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeAndWait [as 别名]
        imageReader.setInput(inputStream)
        return imageReader.read(0)

    def resizeImage(self, fullSizeImage):
        bufferedImage = BufferedImage(SwingingMonkeyCommander._preferredWidth, SwingingMonkeyCommander._preferredHeight, BufferedImage.TRANSLUCENT)
        graphics2d = bufferedImage.createGraphics()
        graphics2d.addRenderingHints(RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY))
        graphics2d.drawImage(fullSizeImage, 0, 0, SwingingMonkeyCommander._preferredWidth, SwingingMonkeyCommander._preferredHeight, None)
        graphics2d.dispose()
        SwingingMonkeyCommander._widthScale = float(fullSizeImage.getWidth()) / float(bufferedImage.getWidth())
        SwingingMonkeyCommander._heightScale = float(fullSizeImage.getHeight()) / float(bufferedImage.getHeight())
        return bufferedImage

    def done(self):
        try:
            self.get()  #raise exception if abnormal completion
        except ExecutionException, e:
            raise SystemExit, e.getCause()

class Runnable(Runnable):
    def __init__(self, runFunction):
        self._runFunction = runFunction

    def run(self):
        self._runFunction()

if __name__ == '__main__':
    SwingUtilities.invokeAndWait(Runnable(SwingingMonkeyCommander))
    while True:
        time.sleep(1000)
开发者ID:fejd,项目名称:SwingingMonkeyCommander,代码行数:32,代码来源:SwingingMonkeyCommander.py

示例11: run

# 需要导入模块: from javax.swing import SwingUtilities [as 别名]
# 或者: from javax.swing.SwingUtilities import invokeAndWait [as 别名]
 def run(self):
     SwingUtilities.invokeAndWait(make_runnable(self.createUINetwork(NengoGraphics())))
开发者ID:ctn-waterloo,项目名称:nengo_java_gui,代码行数:4,代码来源:integrator.py


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