-1

So I have looked and tried several different solutions to this method however I have found none that have worked. So far I have the following:

#Variables
countmin = IntVar()


#Functions

#Used to Determine the customisable counter as well as general time management
#Should be noted 59 seconds is used because function begins counting every second at 00 instead of 01
def timecount(minutes):
    start = time.time()
    time.clock()    
    sec_elapsed = 0
    min_elapsed = 0
    while min_elapsed < minutes:
        sec_elapsed = time.time() - start
        print("minutes count:",min_elapsed,"loop cycle time: %f, seconds count: %02d" % (time.clock() , sec_elapsed)) 
        time.sleep(1)
        if sec_elapsed > 59:
            min_elapsed = +1
            start = time.time()

def startquiz():
    timecount(int(sbcount.get()))

And later I reference it here:

sbcount = Spinbox(tab1, from_ = 1, to = 20, textvariable = countmin).pack()
countmin.get()



btquiz = ttk.Button(tab1, text = "Error")
btquiz.config(text = "Begin Quiz", compound = CENTER, command = startquiz)
btquiz.pack()

And now Im running into the following issues

 File "C:\Users\BugZ\AppData\Local\Programs\Python\Python36-32\lib\tkinter\__init__.py", line 1699, in __call__
    return self.func(*args)
  File "C:\SDD\TKinter Project\Quiz Application.py", line 38, in startquiz
    timecount(int(sbcount.get()))
AttributeError: 'NoneType' object has no attribute 'get'

If someone can demonstrate on how I would go about getting the value of the spinbox and referencing its value into the function It would be very much appreciated :) Very, very new at coding so sorry if my terminology is a bit off.

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
Bugsy
  • 1

1 Answers1

0

pack generates a side-effect and returns None, maybe try:

sbcount = Spinbox(tab1, from_ = 1, to = 20, textvariable = countmin)
sbcount.pack()
Reut Sharabani
  • 30,449
  • 6
  • 70
  • 88