m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
1.2 KiB

6 months ago
  1. from __future__ import print_function, unicode_literals, absolute_import
  2. class Event(object):
  3. '''Represent events from the console.'''
  4. def __init__(self, console, input):
  5. pass
  6. def __repr__(self):
  7. '''Display an event for debugging.'''
  8. if self.type in ['KeyPress', 'KeyRelease']:
  9. chr = self.char
  10. if ord(chr) < ord("A"):
  11. chr = "?"
  12. s = "%s char='%s'%d keysym='%s' keycode=%d:%x state=%x keyinfo=%s" % \
  13. (self.type, chr, ord(self.char), self.keysym, self.keycode, self.keycode,
  14. self.state, self.keyinfo)
  15. elif self.type in ['Motion', 'Button']:
  16. s = '%s x=%d y=%d state=%x' % (self.type, self.x, self.y, self.state)
  17. elif self.type == 'Configure':
  18. s = '%s w=%d h=%d' % (self.type, self.width, self.height)
  19. elif self.type in ['FocusIn', 'FocusOut']:
  20. s = self.type
  21. elif self.type == 'Menu':
  22. s = '%s state=%x' % (self.type, self.state)
  23. else:
  24. s = 'unknown event type'
  25. return s
  26. # def __str__(self):
  27. # return "('%s',%s,%s,%s)"%(self.char,self.key,self.state,self.keyinfo)