awtk/design/default/ui/serial.xml
2022-07-08 17:39:28 +08:00

29 lines
902 B
XML

<window>
<button text="打开设备" x="16" y="15" w="76" h="34" >
<property name="on:click">
var device = widget_get('device', 'text')
widget_set('serial','device', device)
</property>
</button>
<edit name="device" x="119" y="13" w="178" h="38" text="/dev/ttys028" />
<label name="recv" x="5" y="123" w="303" h="101" />
<edit name="send" text="hello serial" x="5" y="273" w="200" h="34" />
<button text="button" tr_text="send" x="220" y="274" w="81" h="34" >
<property name="on:click">
var os = widget_get('serial','ostream')
var msg = widget_get('send', 'text')
ostream_write_string(os, msg)
</property>
</button>
<serial name="serial">
<property name="on:data">
var is = widget_get('self','istream')
var msg = istream_read_string(is, 100, 0)
widget_set('recv', 'text', msg)
</property>
</serial>
</window>