return True return super(RichEdit, self).onKey(key) Edit = RichEdit if __name__ == '__main__': from window import Window from pprint import pprint koan.init() w = Window() w.create(0, 0, 640, 480, caption = True) w.bgColor = color.darkgray w.bind('Key', pprint) e = Edit(w) e.rect = 10,10,300,200 e.align = 'MTL' e.vscroll = False e.font = 'Segoe UI' e.hscroll = False #e.bgColor = color.lightgray e.bgColor = color.darkblue e.fontColor = color.green #koan.anim.PostEvent(setattr, e, 'text', 'Testing, hello world') e.maxlen = 5 e.text = 'Hello world' def trace(self):
self.bind('Mouse RUp', self.trace, 'Mouse RUp') self.bind('Click', self.trace, 'Click') self.bind('Dbl Click', self.trace, 'Dbl Click') self.bind('RDbl Click', self.trace, 'RDbl Click') def trace(self, *argv, **argd): print self, argv koan.init() w = Window() w.create(0, 0, 800, 600, caption = True) w.bgColor = color.darkblue from dialog import Dialog from pprint import pprint w.d = Dialog(w) w.d.bind('Mouse Enter', pprint, 'Mouse Enter') w.d.bind('Mouse Leave', pprint, 'Mouse Leave') w.d.size = 400, 300 w.d.bgColor = color.blue w.bind('Key', koan.action.PureAction(w.d.doModal)) o = MyComponent(w.d) o.rect = 100, 50, 300, 100 o.bgColor = color.yellow w.show() koan.run(1) koan.final()
self.bind('Mouse RUp', self.trace, 'Mouse RUp') self.bind('Click', self.trace, 'Click') self.bind('Dbl Click', self.trace, 'Dbl Click') self.bind('RDbl Click', self.trace, 'RDbl Click') def trace(self, *argv, **argd): print self, argv koan.init() w = Window() w.create(0, 0, 800, 600, caption=True) w.bgColor = color.darkblue from dialog import Dialog from pprint import pprint w.d = Dialog(w) w.d.bind('Mouse Enter', pprint, 'Mouse Enter') w.d.bind('Mouse Leave', pprint, 'Mouse Leave') w.d.size = 400, 300 w.d.bgColor = color.blue w.bind('Key', koan.action.PureAction(w.d.doModal)) o = MyComponent(w.d) o.rect = 100, 50, 300, 100 o.bgColor = color.yellow w.show() koan.run(1) koan.final()
mi.fontSize = 20 mi.header = text mi.bgColor = color.gray mi.bind('Mouse Enter', setattr, mi, 'bgColor', color.lightgray) mi.bind('Mouse Leave', setattr, mi, 'bgColor', color.gray) return mi for i in range(30): mi = createMenuItem(m, 'hello %d' % i) ''' mi = m.children[5] mi.bgColor = color.red for i in range(50): mi2 = createMenuItem(mi, 'sub %d' %i) mi = m.children[15] for i in range(20): mi2 = createMenuItem(mi, 'small %d' %i) m.bgColor = color.purple m.xy = x, y ''' print '--------', time.time() - t m.doModal() w.bind('Mouse RUp', popup) w.show() koan.run(1) koan.final()
mi.fontSize = 20 mi.header = text mi.bgColor = color.gray mi.bind("Mouse Enter", setattr, mi, "bgColor", color.lightgray) mi.bind("Mouse Leave", setattr, mi, "bgColor", color.gray) return mi for i in range(30): mi = createMenuItem(m, "hello %d" % i) """ mi = m.children[5] mi.bgColor = color.red for i in range(50): mi2 = createMenuItem(mi, 'sub %d' %i) mi = m.children[15] for i in range(20): mi2 = createMenuItem(mi, 'small %d' %i) m.bgColor = color.purple m.xy = x, y """ print "--------", time.time() - t m.doModal() w.bind("Mouse RUp", popup) w.show() koan.run(1) koan.final()