所以我在appJar中创建了一个滚动条,一次显示10个数字(1-10,11-20等),我想知道最好的方法是什么。
我是否应该创建一个函数来隐藏接下来的10个数字,直到滚动条(这是一个缩放,尽管这可能是错误的方法),然后它们出现?
我现在真的迷路了,因为我两天前才开始学习如何在一个项目中使用appJar。任何想法都会有很大帮助。是的,这只是gui部分,Python (3.6)还没有添加,但是将会添加。
from appJar import gui
def press(btn):
if btn == "1":
app.setLabel("answer", "1!")
elif btn == "2":
app.setLabel("answer", "2!")
elif btn == "3":
app.setLabel("answer", "3!")
elif btn == "4":
app.setLabel("answer", "4!")
elif btn == "5":
app.setLabel("answer", "5!")
elif btn == "6":
app.setLabel("answer", "6!")
elif btn == "7":
app.setLabel("answer", "7!")
elif btn == "8":
app.setLabel("answer", "8!")
elif btn == "9":
app.setLabel("answer", "9!")
elif btn == "10":
app.setLabel("answer", "10!")
app.startScrollPane("scroller")
elif btn == "11":
app.setLabel("answer", "11!")
elif btn == "12":
app.setLabel("answer", "12!")
app.stopScrollPane("scroller")
app=gui()
app.setFont(20)
app.addButtons(["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"], press)
app.addScale("scroller")
app.setScaleChangeFunction("scroller", press)
app.setButton ("1", "1")
app.setButton ("2", "2")
app.setButton ("3", "3")
app.setButton ("4", "4")
app.setButton ("5", "5")
app.setButton ("6", "6")
app.setButton ("7", "7")
app.setButton ("8", "8")
app.setButton ("9", "9")
app.setButton ("10", "10")
app.setButton ("11", "11")
app.setButton ("12", "12")
app.addLabel ("answer", "Pick a Number!")
app.go()发布于 2017-05-25 21:33:12
我在这里看到两种选择:
这取决于你想让GUI看起来怎样..。
对于选项1,请尝试以下方法,而不是比例:
app.startScrollPane("p1")
for i in range(1,101):
app.addButton(str(i), press, 0, i)
app.stopScrollPane()对于选项2,去掉setButton()调用的列表,并将它们替换为调用一个新函数:updateButtons()。
然后,在这个函数中,有如下内容:
def updateButtons(btn=None):
m = app.getScale("scroller") * 10
for i in range(1, 13):
app.setButton (str(i), str(m+i))您还可能希望在比例上设置范围:app.setScaleRange("scroller", 0, 9)
并且,注册标度来调用updateButtons()函数,而不是press
您还需要对按下的按钮进行等效的计算,因为它们返回的是ID,而不是值。
https://stackoverflow.com/questions/43918169
复制相似问题