[aardio notes] (1) Basic use, call python and drop-down box

Because I want to be a code editor who can quickly develop small desktop applications, I have been looking for python-related GUI production tools in the past two days and found that several mainstream libraries in python are fully functional, such as pyqt pyside2, but they are big frameworks after all It is more complicated to use, and it is not as convenient as the GUI that comes with matlab, especially the method of code layout, which makes me feel dizzy. If I only want to achieve the needs of making a small interface for my own use at any time, use pyqt and other libraries. There is no need to kill chickens with a sledgehammer

I looked around and found a relatively unpopular small language arrdio. After comparison, I found that it is closer to the GUI of matlab in the development of desktop applications, so I plan to get into the pit, and write down my own learning arrdio and using arrdio here.

Attached arrdio language forum: http://bbs.aardio.com

Installation tutorial reference:

http://bbs.aardio.com/forum.php?mod=viewthread&tid=8663&extra=page%3D1 The
Insert picture description here
design interface and code backend can be cut with one click, which is very convenient.
At the same time, in the design interface, right-click on the space -> response command/attribute is similar to matlab, which is quite appetizing to me.

First try drawing a few buttons.
Insert picture description here

Since I usually develop in python, the requirement is that arrdio can call the function of the python code I wrote.
Therefore, one of the two buttons is designed by me to call related python
functions, and the returned result is displayed in the text box Edit.

About calling Python

First write a function in python

def p():
	return 123

Then name the file test.py and put it under the res folder:
Insert picture description here
In the arrdio interface, right-click the resource file -> synchronize the local directory, and it will be updated.
Insert picture description here
Switch to the code behind view,

import win.ui;
import console
//添加所需要的py库,软件会提示你下载
import py

//DSG这个部分是不用自己写的,软件自动生成
/*DSG{
    
    {*/
mainForm = win.form(text="第一个工程";right=959;bottom=591)
mainForm.add(
button={
    
    cls="button";text="你好";left=91;top=69;right=264;bottom=163;z=1};
button2={
    
    cls="button";text="python";left=89;top=221;right=269;bottom=327;z=2};
combobox={
    
    cls="combobox";left=607;top=246;right=714;bottom=272;edge=1;hscroll=1;items={
    
    "a";"b";"c"};mode="dropdown";z=4};
edit={
    
    cls="edit";text="Edit";left=336;top=235;right=452;bottom=285;edge=1;multiline=1;z=3}
)
/*}}*/

//添加调用函数的路径,string指pycode为字符类型
pyCode = string.load("\res\test.py");
//执行pycode
py.exec(pyCode);

//mainForm就是我们制作的窗口
mainForm.button.oncommand = function(id,event){
    
    
	//msgbox 消息弹窗
	mainForm.msgbox("hello")
}

//button2为执行python函数的按钮
mainForm.button2.oncommand = function(id,event){
    
    
	//var为声明,p为函数名
	var result = py.main.p()
	//结果返回到edit处
	mainForm.edit.text = result;
}

mainForm.edit.oncommand = function(id,event){
    
    
	
}

mainForm.combobox.oncommand = function(id,event){
    
    
	
}

mainForm.show();
return win.loopMessage();

Click the run button above , the
effect is as follows:
Insert picture description here
Insert picture description here

Drop-down box: The
Insert picture description here
drop-down options are set in the property bar on the right,
Insert picture description here
separated by semicolons in the middle! !
You can add this sentence in the background of the drop-down box to make the text box display the text selected by the drop-down box

mainForm.edit.text = mainForm.combobox.text;

Guess you like

Origin blog.csdn.net/Sgmple/article/details/112559764