Python Forum
Thread Rating:
  • 1 Vote(s) - 5 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)
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020