zzdummy.py 961 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "Example extension, also used for testing."
  2. from idlelib.config import idleConf
  3. ztext = idleConf.GetOption('extensions', 'ZzDummy', 'z-text')
  4. class ZzDummy:
  5. ## menudefs = [
  6. ## ('format', [
  7. ## ('Z in', '<<z-in>>'),
  8. ## ('Z out', '<<z-out>>'),
  9. ## ] )
  10. ## ]
  11. def __init__(self, editwin):
  12. self.text = editwin.text
  13. z_in = False
  14. @classmethod
  15. def reload(cls):
  16. cls.ztext = idleConf.GetOption('extensions', 'ZzDummy', 'z-text')
  17. def z_in_event(self, event):
  18. """
  19. """
  20. text = self.text
  21. text.undo_block_start()
  22. for line in range(1, text.index('end')):
  23. text.insert('%d.0', ztest)
  24. text.undo_block_stop()
  25. return "break"
  26. def z_out_event(self, event): pass
  27. ZzDummy.reload()
  28. ##if __name__ == "__main__":
  29. ## import unittest
  30. ## unittest.main('idlelib.idle_test.test_zzdummy',
  31. ## verbosity=2, exit=False)