从标签条目中存储值

2024-03-28 21:37:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用appJar来显示我的答案。我使用getLabel来获取我的输入值,但是我想使用这些值(np)进行操作。那么,如何使用输入值进行操作

import numpy as np
from appJar import gui 

def launch(win):
    app.showSubWindow(win)

app=gui("JM-UofA2018","600x100")

#Title
app.addLabel("title", "Welcome to Open Pit Design-Angles Tool")
app.setLabelBg("title", "red")
app.setLabelFg("title", "blue")
#Label Instructions
app.addLabel("Select one Button:")
# these go in the main window
app.addButtons(["Catch Bench (CB)","Horizontal Distance (HD)","Bench Face Angle (BFA)"], launch)


def press(button):
    if button == "Cancel":
        app.stop() 
    else:
        app.getLabel("Height")
        app.getLabel("IRA")
        app.getLabel("BFA")

        CB = (Height*((1/(np.tan(IRA*np.pi/180))-(1/(np.tan(BFA*np.pi/180))))))
        print(CB)

app.startSubWindow("Catch Bench (CB)", modal=True)
app.addLabel("l1", "Input: Height,IRA and BFA")
app.addLabel("Height")
app.addNumericEntry("Height")
app.addLabel("IRA")
app.addNumericEntry("IRA")

app.addLabel("BFA")
app.addNumericEntry("BFA")

app.addButtons(["Accept", "Cancel"], press)
app.stopSubWindow()

app.go()

Tags: importapptitledefnpguicbheight
1条回答
网友
1楼 · 发布于 2024-03-28 21:37:12

getLabel()返回标签的字符串内容,但您需要用户输入数据的数字项的内容,因此使用getNumericEntry()

您还需要将这些返回的、用户输入的值分配给相应的变量(您当前正在尝试使用这些变量,但尚未定义)。例如:

IRA = app.getNumericEntry("IRA")

相关问题 更多 >