cherryext/orun/examples/cp.py

27 lines
972 B
Python
Raw Normal View History

2018-08-09 08:57:18 +03:00
from orun.extjs import js, Ext, cp
2013-04-30 09:49:34 +04:00
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-11 16:25:59 +03:00
{'text': 'OK', 'handler': js.FuncWithParams(ok_click, params = {'arg1': 1, 'arg2': 'val2', 'arg3': js.cli.this.id})},
2018-08-08 22:15:37 +03:00
{'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 12:53:54 +03:00
cp.THEME = 'classic'
2013-04-30 09:49:34 +04:00
app = MyApplication('Orun (ExtJS Application)')
app.run()