最近发现了一个可以用aardio画Tkinter界面并生成Python代码的库GUI2Python,
项目地址:
https://github.com/jerryxjr1220/aardioGUI2Python
aardioGUI2Python库可以转换大部分的常用控件至Python的Tkinter中,界面可以直接运行。当然“功能逻辑部分”需要自行添加,可以实现预想的功能。
Quick Start
安装 直接把下载的GUI2Py.aardio文件复制到aardio项目文件夹的lib目录下(lib目录下存放着用户自制库,可以直接import到程序中)即可。
把界面组件化,这样可以像aardio一样把不同的界面拆成单独的组件,然后在Tabs高级选项卡(python中对应的就是Notebook)进行调用。也可以嵌入到其他Frame、Notebook、LabelFrame等容器中,当然也可以是主窗口Tk容器。
应用实例
aardio创建界面,用matplotlib画图,实时动态显示在Tkinter中
import tkinter as tk
import tkinter.ttk as ttk
import matplotlib.pyplot as plt
import numpy as np
from io import BytesIO
from PIL import Image, ImageTk
class SA():
### 界面设计部分 ###
def __init__(self, master):
self.mainframe = ttk.Frame(master, width=601, height=390)
self.label1_frame = ttk.Frame(self.mainframe, width=209, height=27)
self.label1 = ttk.Label(self.label1_frame, text="y = sin(x) / log(x)")
self.label1.place(x=0, y=0)