移远EC600U-CN开发板 11.15

制作一个简单UI:

1."端口设置"模块

*效果图

*代码

复制代码
def backEvent(evt):            #返回主界面
    code = evt.get_code()    
    if code == lv.EVENT.CLICKED:
            lv.scr_load(mainInterface)

def popUpEvent(evt):        #弹窗提醒
    code = evt.get_code()

    if code == lv.EVENT.CLICKED:
            btns = []
            mbox1 = lv.msgbox(portSet, "提醒", "设置成功",btns, True)
            mbox1.center()

portSet = lv.obj() 

pReturnBtn = lv.btn(portSet)     #返回按钮
pReturnBtn.align(lv.ALIGN.TOP_LEFT,20,30) #按钮位置置于左上角
labelPReturnBtn = lv.label(pReturnBtn)   #按钮文本
labelPReturnBtn.set_text('<')
pReturnBtn.add_event_cb(event_handler1, lv.EVENT.ALL, None)    #回调函数

dataFrames = lv.table(portSet)  #数据设置框

# Fill the first column
dataFrames.set_cell_value(0, 0, "数据位")
dataFrames.set_cell_value(1, 0, "校验位")
dataFrames.set_cell_value(2, 0, "停止位")
dataFrames.set_cell_value(3, 0, "波特率")
portSet.set_style_text_font(self_myfont_cn, 0)

# Fill the second column
dataFrames.set_cell_value(0, 1, "")
dataFrames.set_cell_value(1, 1, "")
dataFrames.set_cell_value(2, 1, "")
dataFrames.set_cell_value(3, 1, "")

dataBits = lv.dropdown(dataFrames)  
dataBits.set_options("\n".join([
    "8",
    "7",
    "6",
    "5",]))
dataBits.align(lv.ALIGN.TOP_RIGHT,-20,7)

checkDigit = lv.dropdown(dataFrames)
checkDigit.set_options("\n".join([
    "无校验",
    "奇校验",
    "偶校验",]))
checkDigit.align(lv.ALIGN.TOP_RIGHT,-20,67)

stopBits = lv.dropdown(dataFrames)
stopBits.set_options("\n".join([
    "1",
    "1.5",
    "2",]))
stopBits.align(lv.ALIGN.TOP_RIGHT,-20,127)

baudRate = lv.dropdown(dataFrames)
baudRate.set_options("\n".join([
    "1200",
    "2400",
    "9600",
    "19200",
    "38400",]))
baudRate.align(lv.ALIGN.TOP_RIGHT,-20,187)
# Set a smaller height to the table. It'll make it scrollable
dataFrames.set_height(200)
dataFrames.center()

saveBtn = lv.btn(portSet)       #保存按钮
saveBtn.align(lv.ALIGN.BOTTOM_MID,0,-40)
labelbtn = lv.label(saveBtn)
labelbtn.set_text('保存设置')
saveBtn.add_event_cb(popUpEvent, lv.EVENT.ALL, None)
相关推荐
前端精髓9 小时前
结构化输出with_structured_output(抽卡)
python·langchain
尹人入圣10 小时前
目前热门的IP驱动产业新场景新工具
网络·python·网络协议·tcp/ip
Nuanyt10 小时前
Agent 学习笔记(下篇三):上线工程、进阶选择与操作界面(Stage 7 / 7.5 / 8 + 延伸路线)
笔记·python·学习·memory·aiagent·harness
吴卫斌10 小时前
定投ETF实战指南(四):行业/主题ETF——定投的“进攻端“
开发语言·python·股票·量化
2601_9679873711 小时前
Python——入门级(定义功能def函数)
python·函数·可变参数·默认参数·关键字参数
专注仿真13 小时前
梯度提升类(XFBoost)算法详解与代码实例
开发语言·人工智能·python·算法·大模型训练·控制算法
外收内放13 小时前
Python基础语法练习题(75)
开发语言·python·学习
黑十14 小时前
PyTorch 报 “no CUDA GPUs are available“ 怎么办?3 步排查
服务器·网络·人工智能·pytorch·python
threelab15 小时前
开源图片去水印代码
python
taller_200016 小时前
【012】数据类型入门: Excel 数据到 Python 值的转换
python·excel·pie·py