Scale function not outputting number to variable?

后端 未结 1 939
遥遥无期
遥遥无期 2020-12-12 07:20

So for some reason the scale function in tkinter doesn\'t want to output the number on the scale. All i receive is either 0.0 or nothing. It seems to be to do with the GUI a

相关标签:
1条回答
  • 2020-12-12 08:10

    Minimal fix: change this

    itervar = DoubleVar()
    

    to this:

    itervar = DoubleVar(sGui)
    

    Because you have two root applications (root and sGui are both instances of Tk) the implied parent widget for itervar is the first one created, being root so tkinter gets confused when you specify it as the variable for a completely different application.

    But I would highly recommend using a Toplevel instance to keep the windows a part of the same program:

    sGui = Toplevel(root)
    ...
    #sGui.mainloop() #no longer need this
    

    although if you want to be able to run the setting window without the main one you might consider making all your visible windows Toplevels and make the actual root hidden:

                    # I'm not sure if you want to call it this
    abs_root = Tk() # but you are already using root
    abs_root.withdraw() #hide the window
    

    Then make root = Toplevel(abs_root)


    You coud phase out the variable all together by using .geting the scale directly:

    iterations = iterscale.get()
    
    0 讨论(0)
提交回复
热议问题