Python Forum
Python Tkinter GUI - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: Code sharing (https://python-forum.io/forum-5.html)
+--- Thread: Python Tkinter GUI (/thread-4358.html)



Python Tkinter GUI - EvilTeliportist - Aug-10-2017

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)