Changeset 1679


Ignore:
Timestamp:
02/08/10 15:52:15 (2 years ago)
Author:
tolteque
Message:

o LoPlug?

  • Change way of working for pyHook. No need to invoke PumpMessage?() which is done by QT
Location:
trunk/loplug/plugins/input
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loplug/plugins/input/pginput.py

    r1672 r1679  
    4646  def addKey( self, key): 
    4747    self.__keyText__ += PGInput.keyReference[key] + "  " 
     48  def clearKey( self): 
     49    self.__keyText__ = "" 
    4850  def getKeys( self): 
    4951    keys = CmdxxxItem( self.__keyText__) 
     
    6870    return False 
    6971 
    70 #  print 'MessageName:',event.MessageName 
    71 #  print 'Message:',event.Message 
    72 #  print 'Time:',event.Time 
    73 #  print 'Window:',event.Window 
    74 #  print 'WindowName:',event.WindowName 
    75 #  print 'Ascii:', event.Ascii, chr(event.Ascii) 
    76 #  print 'Key:', event.Key 
    77 #  print 'KeyID:', event.KeyID 
    78 #  print 'ScanCode:', event.ScanCode 
    79 #  print 'Extended:', event.Extended 
    80 #  print 'Injected:', event.Injected 
    81 #  print 'Alt', event.Alt 
    82 #  print 'Transition', event.Transition 
    83 #  print '---' 
     72  print 'MessageName:',event.MessageName 
     73  print 'Message:',event.Message 
     74  print 'Time:',event.Time 
     75  print 'Window:',event.Window 
     76  print 'WindowName:',event.WindowName 
     77  print 'Ascii:', event.Ascii, chr(event.Ascii) 
     78  print 'Key:', event.Key 
     79  print 'KeyID:', event.KeyID 
     80  print 'ScanCode:', event.ScanCode 
     81  print 'Extended:', event.Extended 
     82  print 'Injected:', event.Injected 
     83  print 'Alt', event.Alt 
     84  print 'Transition', event.Transition 
     85  print '---' 
    8486 
    8587  key = event.KeyID 
     
    8789    if key in keyPressed: 
    8890      keyPressed.remove( key) 
    89       PGInput.processKey( pgInputInstance, keyPressed) 
     91      PGInput.emit( pgInputInstance, SIGNAL("keyReleased"), keyPressed) 
    9092  else: 
    9193    if not ( key in keyPressed): 
    9294      keyPressed.append( key) 
    9395      PGInput.addKeyReference( pgInputInstance, key, event.Key) 
    94       PGInput.processKey( pgInputInstance, keyPressed) 
     96      PGInput.emit( pgInputInstance, SIGNAL("keyPressed"), keyPressed) 
    9597       
    9698  return True 
     
    236238  # @param self                      instance class 
    237239  def _start( self ): 
    238     pass 
     240    # Get instance of hokk manager 
     241    self.hookManager = pyHook.HookManager() 
     242     
     243    self.connect( self, SIGNAL("keyPressed"), self.__onKeyPressed__ ) 
     244     
     245    # Subscribed to keyborad events 
     246    self.hookManager.SubscribeKeyAll( onKeyBoardEvent) 
     247    self.hookManager.HookKeyboard() 
    239248#---------------------------------------------------------------- 
    240249  # Method invoked by the PGPluginClient parent on restart() 
     
    289298  # @param datas                     datas 
    290299  def _selection( self, srcPlugId, list_id, datas): 
    291     pass 
    292 #---------------------------------------------------------------- 
    293   # This method is to be overwrite by the daughter class 
    294   # It is the entry point of the process thread 
    295   # @param self                      instance class 
    296   # @param datas                     datas 
    297   def _process_thread_entry_point( self): 
    298     # Get instance of hokk manager 
    299     self.hookManager = pyHook.HookManager() 
    300      
    301     # Subscribed to keyborad events 
    302     self.hookManager.SubscribeKeyAll( onKeyBoardEvent) 
    303     self.hookManager.HookKeyboard() 
    304      
    305     # Subscribe to mouse move events 
    306     self.hookManager.SubscribeMouseAll( onMouseEvent) 
    307 #    self.hookManager.HookMouse() 
    308      
    309     # Enable feature 
    310     pythoncom.PumpMessages() 
    311      
    312      
     300    pass     
    313301#---------------------------------------------------------------- 
    314302  # To shutdown the instance 
     
    328316# INTERFACE METHODS 
    329317#================================================================ 
    330 #---------------------------------------------------------------- 
    331   # Wait for shutdown complete 
    332   # @param self                      instance class 
    333   # @param keyTable                  table of key pressed 
    334   def processKey( self, keyTable): 
     318  def addKeyReference( self, keyId, keyName): 
     319    if not ( keyId in self.keyReference.keys()): 
     320      self.keyReference[keyId] = keyName 
     321       
     322#================================================================ 
     323# LOCAL METHODS 
     324#================================================================ 
     325 
     326  def __onKeyPressed__( self, keyTable): 
     327    print keyTable 
    335328    if self.workingMode == PGInput.WORKING_MODE_COMBO_EDITION: 
    336329      if len( keyTable) ==1: 
    337330        self.cmdItem.addKey( keyTable[0]) 
    338331        self.__updateUi__() 
     332        print keyTable[0] 
    339333       
    340334    elif self.workingMode == PGInput.WORKING_MODE_CONFIGURATION: 
     
    360354      self.send_object([keyMap], opCode, szObj )  
    361355 
    362        
    363   def addKeyReference( self, keyId, keyName): 
    364     if not ( keyId in self.keyReference.keys()): 
    365       self.keyReference[keyId] = keyName 
    366        
    367 #================================================================ 
    368 # LOCAL METHODS 
    369 #================================================================ 
     356 
    370357  def  _updateCmdList__( self, data, list): 
    371358    rendered_datas = self.get_list_data_to_render_for() 
     
    400387        self.row = index.row() 
    401388        self.cmdItem = self.cmdList[self.row] 
     389        self.cmdItem.clearKey() 
     390        self.__updateUi__() 
    402391        print "Enter combo edition" 
    403392 
  • trunk/loplug/plugins/input/test.py

    r1662 r1679  
    1  
     1import threading 
     2from time import * 
    23import pythoncom 
    34import pyHook 
     
    3637  return True 
    3738 
    38  
    39 hookManager = pyHook.HookManager() 
    40 hookManager.SubscribeKeyAll( OnKeyBoardEvent) 
    41 hookManager.HookKeyboard() 
    42 pythoncom.PumpMessages() 
     39   
     40def process(): 
     41  hookManager = pyHook.HookManager() 
     42  hookManager.SubscribeKeyAll( OnKeyBoardEvent) 
     43  hookManager.HookKeyboard() 
     44  pythoncom.PumpMessages() 
     45     
     46   
     47# ================================================= 
     48if __name__ == "__main__": 
     49  processThread = threading.Thread( target = process) 
     50  processThread.setDaemon( True) 
     51  processThread.start() 
     52  while( 1): 
     53    sleep( 10) 
Note: See TracChangeset for help on using the changeset viewer.