Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Tkinter GUI
#1
Hi. Im trying to make a quick game that should be very simple, but I'm currently struggling. The goal is to have 3 Spinbox's that can't go lower than zero. My challenge is that I need them to always equal lower than 12 when you add them all up. Its supposed to be a game where you assign people jobs, and you only have a certain amount of people. Any help is appreciated!

Thanks,
Bryan

PS. Everything is packed I just didn't add that code.
people = 12
available = 12
avail = 12

root = Tk()

def RemovePeople():
    s = int(stonePeople.get())
    w = int(woodPeople.get())
    f = int(farmPeople.get())

    available = s+w+f
    avail = 12-available

    stonePeople.config(to=avail)
    woodPeople.config(to=avail)
    farmPeople.config(to=avail)


stonePeople = Spinbox(root, from_=0, to=avail, command = RemovePeople)
woodPeople = Spinbox(root, from_=0, to=avail, command = RemovePeople)
farmPeople = Spinbox(root, from_=0, to=avail, command = RemovePeople)
Moderator nilamo: Indentation is important.  Please include it next time (along with code tags)
Quote

Top Page

Forum Jump:


Users browsing this thread: 1 Guest(s)