cherryext/orun/examples/cp.py

29 lines
1016 B
Python
Raw Normal View History

2013-04-30 09:49:34 +04:00
from orun.extjs import *
from orun.extjs import cp
def ok_click(id_, *args, **kwargs):
js.cli << Ext.getCmp(id_).setText('Clicked')
js.cli << js.client.alert('Server side message')
2013-04-30 09:49:34 +04:00
def button_click(id_, *args, **kwargs):
2013-04-30 09:49:34 +04:00
js.write("""
Ext.getCmp("%s").setText('Clicked');
alert('Server side callback message');
""" % id_)
2013-04-30 09:49:34 +04:00
class MyApplication(cp.ExtApplication):
def main(self, *args, **kwargs):
wnd = Ext.create('widget.window', {'title': 'My Window', 'width': 300, 'height': 250,
'items': [{'xtype': 'button', 'text': 'Click Here', 'handler': button_click}],
'buttons': [
2018-08-08 22:15:37 +03:00
{'text': 'OK', 'handler': js.FuncWithParams(ok_click, {'arg1': 1, 'arg2': 'val2', 'arg3': js.cli.this.id})},
{'text': 'Close', 'handler': js.function('this.up(\'window\').close()')}]})
2013-04-30 09:49:34 +04:00
wnd.show()
wnd.setHeight(200)
2018-08-08 22:15:37 +03:00
print(repr(js.live_methods))
2013-04-30 09:49:34 +04:00
2018-08-08 12:53:54 +03:00
cp.THEME = 'classic'
2013-04-30 09:49:34 +04:00
app = MyApplication('Orun (ExtJS Application)')
app.run()