Add mouse events, event demo.
#!/usr/bin/env python3
from demos.base import setup
import sys
import os
import re
def list_demos():
return sorted(fname for fname in os.listdir('demos')
if re.match(r'[0-9]+_.*\.py', fname))
def print_usage(names):
print("Usage: %s <name>\n" % sys.argv[0])
print("Where <name> is one of (or part of):")
print('\n'.join([' '+name for name in names]))
if __name__ == '__main__':
setup()
names = list_demos()
if len(sys.argv) != 2:
print_usage(names)
sys.exit(0)
arg = sys.argv[1]
name = None
for name in names:
if arg in name:
break
else:
print("Demo '%s' not found." % arg)
sys.exit(1)
print("Executing %s..." % name)
with open('demos/' + name, 'r') as f:
exec(f.read())