You may or may not be familiar with a popular party game called "Werewolves" - the specifics of the game aren't important here but I'm trying to make a program which will decide teams for it.
I have the following code which is fairly simple - it consists of 3 methods which I'm looking to attach to buttons and then display in a window when the program is run.
The code is shown here:
from Tkinter import *
from random import randint # import random integer generator
playerList = []
numberOfWolves = 0
def setWolfNumber(x):
numberOfWolves = x
def listAdd(string):
playerList.append(string)
def chooseTeams():
werewolves = [] # list of wolves, populated later for printing
villagers = [] # same as wolves but for villiagers
for x in range(0,len(playerList)): # loop for the number of players. Each iteration chooses a random player and decides whether they're a werewolf or not. After 2 werewolves it just adds villagers.
random = randint(0,len(playerList)-1)
player = playerList[random]
decide = randint(0,1)
if decide == 0 and len(werewolves) < numberOfWolves:
werewolves.append(player)
else:
villagers.append(player)
playerList.remove(player)
for wolf in werewolves: #prints wolf names
print wolf + " is a werewolf"
seer = villagers[randint(0,len(villagers))-1] #decide seer, print that, make sure they won't be reprinted with villagers
villagers.remove(seer)
print seer + " is the seer"
doctor = villagers[randint(0,len(villagers))-1] #same as seer but with the doctor
villagers.remove(doctor)
print doctor + " is the doctor"
for villager in villagers: # print villagers
print villager + " is a villager"
top = Tk()
top.wm_title("Werewolves Team Chooser")
w = Button(top)
top.mainloop()
As I'm sure you can see, the code for the GUI is very much incomplete. Could someone show me how to display fields in the GUI, and attach them to buttons? Effectively what I'm looking for is a field for adding players, and a field for setting the number of werewolves; then one button that takes that information and decides the team - using the methods provided.
Any help would be greatly appreciated.
Bonus: How hard would it be to turn the finished product into an executable file so my friends can use it too?
Thanks very much!