jerryxjr1220 / aardiogui2python Goto Github PK
View Code? Open in Web Editor NEWTransfer an aardio GUI to TKinter GUI of Python
License: BSD 2-Clause "Simplified" License
Transfer an aardio GUI to TKinter GUI of Python
License: BSD 2-Clause "Simplified" License
用aardio画的测试gui,使用了图像控件,但是转成tkinter代码后图像却不显示。
这是aardio代码:
import win.ui;
/*DSG{{*/
var math_correct = win.form(text="correct";right=319;bottom=639)
math_correct.add(
picturebox={cls="picturebox";left=128;top=96;right=160;bottom=120;image=$"\images\对勾.jpg";z=4};
picturebox2={cls="picturebox";left=216;top=96;right=248;bottom=120;image=$"\images\叉.jpg";z=5};
picturebox3={cls="picturebox";left=24;top=320;right=288;bottom=504;image=$"E:\my3d\steem\topgun.bmp";z=16};
picturebox5={cls="picturebox";left=128;top=152;right=160;bottom=176;image=$"\images\对勾.jpg";z=9};
picturebox6={cls="picturebox";left=216;top=152;right=246;bottom=176;image=$"\images\叉.jpg";z=10};
picturebox7={cls="picturebox";left=128;top=216;right=160;bottom=240;image=$"\images\对勾.jpg";z=14};
picturebox8={cls="picturebox";left=216;top=216;right=246;bottom=240;image=$"\images\叉.jpg";z=15};
radiobutton={cls="radiobutton";text="正确";left=168;top=96;right=224;bottom=112;z=2};
radiobutton2={cls="radiobutton";text="错误";left=248;top=96;right=304;bottom=112;z=3};
radiobutton5={cls="radiobutton";text="正确";left=168;top=152;right=224;bottom=168;z=7};
radiobutton6={cls="radiobutton";text="错误";left=248;top=152;right=304;bottom=168;z=8};
radiobutton7={cls="radiobutton";text="正确";left=168;top=216;right=224;bottom=232;z=12};
radiobutton8={cls="radiobutton";text="错误";left=248;top=216;right=304;bottom=232;z=13};
static={cls="static";text="Static";left=16;top=96;right=127;bottom=124;font=LOGFONT(h=-24);transparent=1;z=1};
static14={cls="static";text="Static";left=16;top=152;right=127;bottom=180;font=LOGFONT(h=-24);transparent=1;z=6};
static15={cls="static";text="Static";left=16;top=216;right=127;bottom=244;font=LOGFONT(h=-24);transparent=1;z=11}
)
/*}}*/
import GUI2Py
g2p=GUI2Py.GUI2Tk(math_correct);
code=g2p.transfer2place('correct_math');
import console
console.log(code);
string.save("correct_math.py",code )
math_correct.show();
win.loopMessage();
这是aardio运行后的界面:
这是转换后的tkinter代码:
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.font as tkFont
class correct_math():
### 界面设计部分 ###
def __init__(self, master):
self.mainframe = ttk.Frame(master, width=336, height=679)
self.pic1_frame = ttk.Frame(width=30, height=24)
self.pic1 = ttk.Label(self.pic1_frame, justify="left")
self.pic1.place(x=0, y=0, width=30, height=24)
self.pic1_frame.place(x=216, y=152)
self.label1_frame = ttk.Frame(width=111, height=28)
self.label1 = ttk.Label(self.label1_frame, text="Static", justify="left")
self.label1.place(x=0, y=0, width=111, height=28)
self.label1_font = tkFont.Font(family="Segoe UI", size=18, weight="normal", slant="roman", underline=False)
self.label1.configure(font=self.label1_font)
self.label1_frame.place(x=16, y=96)
self.pic2_frame = ttk.Frame(width=264, height=184)
self.pic2 = ttk.Label(self.pic2_frame, justify="left")
self.pic2.place(x=0, y=0, width=264, height=184)
self.pic2_frame.place(x=24, y=320)
self.pic3_frame = ttk.Frame(width=32, height=24)
self.pic3 = ttk.Label(self.pic3_frame, justify="left")
self.pic3.place(x=0, y=0, width=32, height=24)
self.pic3_frame.place(x=128, y=216)
self.radio1_frame = ttk.Frame(width=56, height=16)
self.radio1 = ttk.Radiobutton(self.radio1_frame, text="正确", value=1)
self.radio1.place(x=0, y=0, width=56, height=16)
self.radio1_frame.place(x=168, y=96)
self.pic4_frame = ttk.Frame(width=30, height=24)
self.pic4 = ttk.Label(self.pic4_frame, justify="left")
self.pic4.place(x=0, y=0, width=30, height=24)
self.pic4_frame.place(x=216, y=216)
self.radio2_frame = ttk.Frame(width=56, height=16)
self.radio2 = ttk.Radiobutton(self.radio2_frame, text="错误", value=2)
self.radio2.place(x=0, y=0, width=56, height=16)
self.radio2_frame.place(x=248, y=216)
self.radio3_frame = ttk.Frame(width=56, height=16)
self.radio3 = ttk.Radiobutton(self.radio3_frame, text="正确", value=3)
self.radio3.place(x=0, y=0, width=56, height=16)
self.radio3_frame.place(x=168, y=152)
self.radio4_frame = ttk.Frame(width=56, height=16)
self.radio4 = ttk.Radiobutton(self.radio4_frame, text="错误", value=4)
self.radio4.place(x=0, y=0, width=56, height=16)
self.radio4_frame.place(x=248, y=152)
self.label2_frame = ttk.Frame(width=111, height=28)
self.label2 = ttk.Label(self.label2_frame, text="Static", justify="left")
self.label2.place(x=0, y=0, width=111, height=28)
self.label2_font = tkFont.Font(family="Segoe UI", size=18, weight="normal", slant="roman", underline=False)
self.label2.configure(font=self.label2_font)
self.label2_frame.place(x=16, y=152)
self.label3_frame = ttk.Frame(width=111, height=28)
self.label3 = ttk.Label(self.label3_frame, text="Static", justify="left")
self.label3.place(x=0, y=0, width=111, height=28)
self.label3_font = tkFont.Font(family="Segoe UI", size=18, weight="normal", slant="roman", underline=False)
self.label3.configure(font=self.label3_font)
self.label3_frame.place(x=16, y=216)
self.radio5_frame = ttk.Frame(width=56, height=16)
self.radio5 = ttk.Radiobutton(self.radio5_frame, text="错误", value=5)
self.radio5.place(x=0, y=0, width=56, height=16)
self.radio5_frame.place(x=248, y=96)
self.pic5_frame = ttk.Frame(width=32, height=24)
self.pic5 = ttk.Label(self.pic5_frame, justify="left")
self.pic5.place(x=0, y=0, width=32, height=24)
self.pic5_frame.place(x=128, y=152)
self.pic6_frame = ttk.Frame(width=32, height=24)
self.pic6 = ttk.Label(self.pic6_frame, justify="left")
self.pic6.place(x=0, y=0, width=32, height=24)
self.pic6_frame.place(x=216, y=96)
self.radio6_frame = ttk.Frame(width=56, height=16)
self.radio6 = ttk.Radiobutton(self.radio6_frame, text="正确", value=6)
self.radio6.place(x=0, y=0, width=56, height=16)
self.radio6_frame.place(x=168, y=216)
self.pic7_frame = ttk.Frame(width=32, height=24)
self.pic7 = ttk.Label(self.pic7_frame, justify="left")
self.pic7.place(x=0, y=0, width=32, height=24)
self.pic7_frame.place(x=128, y=96)
self.mainframe.pack()
### 功能逻辑部分 ###
aardio中的窗口为right=757,bottom=467
`
import win.ui;
/DSG{{/
mainForm = win.form(text="Hello";right=757;bottom=467;max=false)
mainForm.add(
button_Click={cls="button";text="点我";left=592;top=16;right=738;bottom=60;z=2};
edit_Click={cls="edit";left=19;top=13;right=575;bottom=452;edge=1;multiline=1;z=1}
)
/}}/
import GUI2Py
g2p = GUI2Py.GUI2Tk( mainForm );
g2p.transfer2place( "Hello" ); //这里的Hello就是py文件中的类名
//把上面的DSG代码复制到这里
g2p.translateName(button_Click={cls="button";text="点我";left=592;top=16;right=738;bottom=60;z=2}; edit_Click={cls="edit";left=19;top=13;right=575;bottom=452;edge=1;multiline=1;z=1}
)
string.save("/res/demo.py", g2p.pycode)
mainForm.show();
return win.loopMessage();
`
转化为py文件后,位置发生变化,编辑框控件原来四周贴边,现在下方空出一大段
`
import tkinter as tk
import tkinter.ttk as ttk
import tkinter.font as tkFont
class Hello():
### 界面设计部分 ###
def __init__(self, master):
self.mainframe = ttk.Frame(master, width=774, height=507)
self.editVar1 = tk.StringVar(value="")
self.edit_Click_frame = ttk.Frame(width=556, height=439)
self.edit_Click = tk.Text(self.edit_Click_frame)
self.edit_Click.insert("end", "")
self.edit_Click.place(x=0, y=0, width=556, height=439)
self.edit_Click_font = tkFont.Font(family="Segoe UI", size=9, weight="normal", slant="roman", underline=False)
self.edit_Click.configure(font=self.edit_Click_font)
self.edit_Click_frame.place(x=19, y=13)
self.button_Click_frame = ttk.Frame(width=146, height=44)
self.button_Click = ttk.Button(self.button_Click_frame, text="点我")
self.button_Click.place(x=0, y=0, width=146, height=44)
self.button_Click_frame.place(x=592, y=16)
self.mainframe.pack()
### 功能逻辑部分 ###
root = tk.Tk()
Hello(root)
root.mainloop()
`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.