Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 创建一个滚动条(appJar)_Python 3.x_User Interface - Fatal编程技术网

Python 3.x 创建一个滚动条(appJar)

Python 3.x 创建一个滚动条(appJar),python-3.x,user-interface,Python 3.x,User Interface,所以我在appJar中创建了一个滚动条,一次显示10个数字(1-10、11-20等),我想知道最好的方法是什么 我是否应该创建一个函数来隐藏接下来的10个数字,直到滚动条(这是一个比例,尽管这可能是错误的方法)出现,然后它们才会出现 我现在真的迷路了,因为我大约两天前才开始学习如何在一个项目中使用appJar。任何想法都会大有帮助。是的,这只是gui部分,Python(3.6)尚未添加,但将添加 from appJar import gui def press(btn): if bt

所以我在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()

我在这里看到两种选择:

  • 创建滚动窗格,并使用滚动窗格的内置滚动条
  • 将缩放小部件链接到更新按钮标签的函数
  • 这实际上取决于您希望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(“滚动条”,0,9)

    并且,注册刻度以调用
    updateButtons()
    函数,而不是按

    您还需要对按钮按下进行等效的计算,因为它们返回的是ID,而不是值