Example #1
0
 def NetComCallbackVT(self, sender, records, numRecords, objectName):
     thisClass = sender
     msgString = "Received Video Record For: " + objectName + " at DAS TS " + records.qwTimeStamp.ToString(
     )
     RecordLogUpdateDelegate = CallTarget0(
         lambda: self.RecordLogUpdate(msgString))
     self.lbRecordLog.BeginInvoke(RecordLogUpdateDelegate)
Example #2
0
	def commandCompletedCallback(self,processExited):
		# commandCompletedCallback gets called on a different thread; use invoke to change to the creating thread as needed to access controls and forms
			# See http://www.ironpython.info/index.php?title=Invoking_onto_the_GUI_%28Control%29_Thread
		def EnableRunButton():
			self.bRun.Enabled = True
			self.bRun.Text = "Run"
		# self.bRun.Invoke( CallTarget0(EnableRunButton) );
		self.bRun.Invoke( CallTarget0(EnableRunButton) );   # Use CallTarget0 if IronPython is unable to convert to a delegate by itself; see http://www.voidspace.org.uk/ironpython/dark-corners.shtml
Example #3
0
    def funUpdate(self):
        global gstrTemp

        def SetText():
            global gstrTemp
            text = datetime.datetime.now().strftime(
                '%Y-%m-%d %H:%M:%S') + ": " + gstrTemp + "\r\n"
            self.mtbOutput.Text = text + self.mtbOutput.Text

        self.mtbOutput.Invoke(CallTarget0(SetText))
Example #4
0
    def funLogout(self):
        def DisableLeft():
            self.btnLeft.Enabled = False

        def DisableRight():
            self.btnRight.Enabled = False

        def DisableForward():
            self.btnForward.Enabled = False

        def DisableBackward():
            self.btnBackward.Enabled = False

        def DisableStopMotor():
            self.btnStopMotor.Enabled = False

        def DisableDisconnect():
            self.btnDisconnect.Enabled = False

        self.btnLeft.Invoke(CallTarget0(DisableLeft))
        self.btnRight.Invoke(CallTarget0(DisableRight))
        self.btnForward.Invoke(CallTarget0(DisableForward))
        self.btnBackward.Invoke(CallTarget0(DisableBackward))
        self.btnStopMotor.Invoke(CallTarget0(DisableStopMotor))
        self.btnDisconnect.Invoke(CallTarget0(DisableDisconnect))
Example #5
0
def invoke(control, delegate, synchronous=True):
    '''
   Invokes the given delegate (method) on the given control/form's 
   GUI thread.  If the control doesn't have access to a working window 
   handle, usually because the Form it is in was disposed) then do nothing.
   
   The 'synchronous' parameter determines whether or not this method blocks 
   while the given delegate is run.  True means block, false means don't.
   '''
    if not control or not delegate:
        raise TypeError("null parameter not allowed!")

    if control.IsHandleCreated and \
          not control.IsDisposed and not control.Disposing:

        try:
            if synchronous:
                # allow thrown exceptions to bubble up
                if control.InvokeRequired:
                    control.Invoke(CallTarget0(delegate))
                else:
                    delegate()
            else:
                control.BeginInvoke(CallTarget0(delegate))
        except:
            if sys.exc_info()[0].__name__ == "SystemError" and \
                  sstr(sys.exc_info()[1]).find("handle") != -1:
                # deliberately ignore this exception, its unavoidably possible
                # since we might invoke on a control via a thread that doesn't
                # own that control's handle--the handle can dissappear at any time
                #
                # see issue 147 for an example of this happening:
                #
                # "SystemError: Invoke or BeginInvoke cannot be called on a control
                #  until the window handle has been created."
                pass
            else:
                # any other exceptions should be raised and reported as usual
                raise
Example #6
0
 def update():
     while True:
         Misc.Pause(1000)
         if Misc.ReadSharedValue('run') == 'True':
             self.box2.Text = (str(Player.Position.X) + ", " + str(Player.Position.Y))
             hits = ((Player.Hits + .0)/Player.HitsMax)* 100        
             hit = int(hits)
             if hit == 0:
                 hit = 1
             def step():
                 count = 0
                 self.prog.Value = hit
             self.Invoke(CallTarget0(step))                                        
         else:
             self.prog.Value = 1
Example #7
0
        def update():
            while True:
                if Misc.ReadSharedValue('run') == 'True':
                    hits = ((Player.Hits + .0) / Player.HitsMax) * 100
                    hit = int(hits)
                    if hit == 0:
                        hit = 1

                    def step():
                        count = 0
                        self.prog.Value = hit

                    self.Invoke(CallTarget0(step))
                    Thread.Sleep(1000)
                else:
                    self.prog.Value = 1
def dispatch(function):
    dispatcher.Invoke(DispatcherPriority.Normal, CallTarget0(function))