• Login
  • Register
Login
Username:
Password: Lost Password?
 
A sheep, a werewolf and a walrus walk into a bar.
  • Home
  • Search
  • Member List
  • Help
  • My Subs
    • Login
    • Register
    Login
    Username:
    Password: Lost Password?
     
A sheep, a werewolf and a walrus walk into a bar. › Game Sign Ups › Game Sign Ups v
1 2 3 4 5 … 8 Next »
› [Closed] Sheek, the sheep game with a knockout twist.

Linear Mode
[Closed] Sheek, the sheep game with a knockout twist.
Neowise Offline
Back in 6,800 years.
Posts: 2,578
Threads: 32
Joined: Jul 2021
#25
30-06-2023, 01:18 PM (This post was last modified: 30-06-2023, 05:46 PM by Neowise.)
main.pyShow Content

from tkinter import *
from tkinter import filedialog, messagebox, ttk
import xml.etree.ElementTree as ET

gt= {'Sheep':1,'PeehsDM':2, 'PeehsFB':3, 'PeehsHybrid':4, 'Heep':5, 'Heep15':6, 'Heep2':7, 'Kangaroo':8, 'Manual':9}
gtl=['filler','Sheep','PeehsDM','PeehsFB','PeehsHybrid','Heep','Heep15','Heep2','Kangaroo','Manual']

rt= {'None':0,'Up':1,'Down':2,'Nearest':3}
rtl=['None','Up','Down','Nearest']

def resetProgram():
global myTextbox1, myLabel2, myQuestions, myAnswers, myPlayers, curQ
myQuestions = []
myAnswers = []
myPlayers = []
curQ = 1
myTextbox1.delete(0, END)
myTextbox1.insert(INSERT, curQ)
myTextbox1.grid_forget()
myTextbox1.grid(row=0, column=2)
myLabel2.grid_forget()
myLabel2 = Label(window, text="Click Sheep > Edit Questions... to begin.")
myLabel2.grid(row=0, column=4)
return

def edQL(edQText):
edQL.filename = filedialog.askopenfilename(title="Load Questions from File", filetypes=[("txt files", "*.txt")] )
#print(edQL.filename) #debug code
file1 = open(edQL.filename, 'r')
strvar=file1.read()
edQText.delete(1.0,END)
edQText.insert(INSERT, strvar)
return(edQText)

def edSave(edQW,edQText):
global myQuestions
global myLabel2
global curQ
myQuestions = edQText.get("1.0",END).splitlines()
window.deiconify()
if curQ==0:curQ=1
if curQ>len(myQuestions): curQ=len(myQuestions)
myTextbox1.delete(0, END)
myTextbox1.insert(INSERT, curQ)
myTextbox1.grid_forget()
myTextbox1.grid(row=0, column=2)
if len(myQuestions) >= curQ:
myLabel2.grid_forget()
myLabel2 = Label(window, text=myQuestions[curQ - 1])
myLabel2.grid(row=0, column=4)
edQW.destroy()

def edPCancel(edAW,object):
edAW.deiconify()
object.destroy()

def newPlayer(edAW):
global myPlayers
edAW.withdraw()
newPW = Toplevel(edAW)
newPW.title("New Player")
newPLabel = Label(newPW, text="Enter new player name:").grid(row=0,column=0)
newPEntry = Entry(newPW).grid(row=1,column=0)
newPOK = Button(newPW, text='OK').grid(row=2,column=3)
newPCancel = Button(newPW,text='Cancel', command=lambda:edPCancel(edAW,newPW)).grid(row=2,column=4)

def edAnswers(window):
window.withdraw()
myfile="\n".join(item for item in myAnswers)
edAW = Toplevel(window)
edAW.title("Edit Entries")
edALabel = Label(edAW, text="Player:")
edALabel.grid(row=0,column=0)
combo = ttk.Combobox(edAW,state="readonly",values=["Python", "C", "C++", "Java"])
combo.grid(row=0,column=1)
spacer=Label(edAW).grid(row=0,column=2)
edALabel = Label(edAW, text="Starting Score:", padx=10)
edALabel.grid(row=1,column=0)
edAText = Text(edAW)
edAText.insert(INSERT, 'Click Load... to load players and answers\nfrom a PM text file, or click New Player\nto add players manually.')
edAText.grid(column=0,columnspan=3, rowspan=10, padx=5, pady=5)
edALoad = Button(edAW,text="Load", padx=20, command=lambda:edQL(edAText)).grid(row=0, column=3, padx=10,pady=5)
edANP = Button(edAW, text="New Player", padx=4,command=lambda:newPlayer(edAW)).grid(row=1, column=3, padx=10,pady=5)
edACN = Button(edAW, text="Change Name", padx=0).grid(row=2 ,column=3, padx=10,pady=5)
edADP = Button(edAW, text="Delete Player", padx=0).grid(row=3, column=3, padx=10,pady=5)
edASave = Button(edAW,text="Save Changes",command=lambda:edSave(edAW,edAText)).grid(row=9, column=3,padx=10, pady=5)
edACancel = Button(edAW,text="Cancel", padx=20,command=lambda:edCancel(edAW)).grid(row=10, column=3, padx=10, pady=5)
edAW.rowconfigure(4, weight=1)
edAW.columnconfigure(2, weight=1)
return

def edQuestions(window):
window.withdraw()
myfile="\n".join(item for item in myQuestions)
edQW = Toplevel(window)
edQW.title("Edit Questions")
edQLabel = Label(edQW, text="Click Load... to load the questions from a text file, or just type them in here one per line")
edQLabel.grid(row=0,columnspan=2)
edQText = Text(edQW)
edQText.insert(INSERT,myfile)
edQText.grid(column=0, rowspan=10, padx=5, pady=5)
edQLoad = Button(edQW,text="Load", padx=20, command=lambda:edQL(edQText)).grid(row=1, column=1)
edQSave = Button(edQW,text="Save Changes",command=lambda:edSave(edQW,edQText)).grid(row=9, column=1)
edQCancel = Button(edQW,text="Cancel", padx=20,command=lambda:edCancel(edQW)).grid(row=10, column=1)
return

def validate_entry(text):
return text.isdecimal()

myQuestions = []
myAnswers = []
myPlayers = []
curQ=1

window = Tk()

window.geometry("680x450")
window.title("Sheep Score Foggies Edition")
Outputtype = IntVar()
Outputtype.set(1)
Gametype = IntVar()
Gametype.set(1)
Roundtype = IntVar()
Roundtype.set(0)

menubar = Menu(window)

window.config(menu=menubar)

fileMenu=Menu(menubar,tearoff=0)
menubar.add_cascade(label="File",menu=fileMenu)

def dothis():
global myQuestions
print(myQuestions)
print(myAnswers)
print(myPlayers)
print(gtl[Gametype.get()])
print(rtl[Roundtype.get()])

def loadReveal():
global myQuestions, myLabel2, myPlayers, Gametype, Roundtype

filename = filedialog.askopenfilename(title="Load Sheep Scoring File", filetypes=[("Sheep Score 2017 File", "*.sheep17")])
tree = ET.parse(filename)
root = tree.getroot()
print(root.tag)
if root.tag == "SheepScore2012Game":
myQuestions = []
for child in root:
if child.tag == "Question":
myQuestions.append(child.text)
elif child.tag == "Player":
myPlayers.append([child.text,child.attrib['StartScore']])
elif child.tag == "ScoringMethod":
Gametype.set(gt[child.text])
elif child.tag == "Rounding":
Roundtype.set(rt[child.text])
elif child.tag == "Group":
pass # To do


if len(myQuestions) >= curQ:
myLabel2.grid_forget()
myLabel2 = Label(window, text=myQuestions[curQ - 1])
myLabel2.grid(row=0, column=4)
else:
qdown()
else:
messagebox.showinfo(title="Greetings", message="This is not a recognized sheep file!")

fileMenu.add_command(label="New Reveal", command=resetProgram)
fileMenu.add_command(label="Load Reveal...", command=loadReveal)
fileMenu.add_command(label="Save Reveal...")
fileMenu.add_command(label="Debug", command=dothis)
fileMenu.add_separator()
fileMenu.add_command(label="Exit",command=quit)

sheepMenu = Menu(menubar,tearoff=0)
menubar.add_cascade(label="Sheep",menu=sheepMenu)
sheepMenu.add_command(label="Edit Questions...", command=lambda:edQuestions(window))
sheepMenu.add_command(label="Edit Entries...", command=lambda:edAnswers(window))

scoringMenu=Menu(menubar,tearoff=0)
sheepMenu.add_cascade(label="Scoring",menu=scoringMenu)
scoringMenu.add_radiobutton(label="Sheep",value=1, variable=Gametype)
peehsMenu=Menu(menubar,tearoff=0)
scoringMenu.add_cascade(label="Peehs",menu=peehsMenu)
peehsMenu.add_radiobutton(label="DM Scoring",value=2, variable=Gametype)
peehsMenu.add_radiobutton(label="FB Scoring",value=3, variable=Gametype)
peehsMenu.add_radiobutton(label="Hybrid",value=4, variable=Gametype)
heepsMenu=Menu(menubar,tearoff=0)
scoringMenu.add_cascade(label="Heeps",menu=heepsMenu)
heepsMenu.add_radiobutton(label="2x Heep Bonus",value=7, variable=Gametype)
heepsMenu.add_radiobutton(label="1.5x Heep Bonus",value=6, variable=Gametype)
heepsMenu.add_radiobutton(label="No Heep Bonus",value=5, variable=Gametype)
scoringMenu.add_radiobutton(label="Kangaroo",value=8, variable=Gametype)
scoringMenu.add_radiobutton(label="Manual",value=9, variable=Gametype)
scoringMenu.add_separator()

roundingMenu=Menu(menubar,tearoff=0)
scoringMenu.add_cascade(label="Rounding",menu=roundingMenu)
roundingMenu.add_radiobutton(label="No Rounding",value=0, variable=Roundtype)
roundingMenu.add_radiobutton(label="Round Up",value=1, variable=Roundtype)
roundingMenu.add_radiobutton(label="Round Down",value=2, variable=Roundtype)
roundingMenu.add_radiobutton(label="Round Nearest",value=3, variable=Roundtype)

outputMenu=Menu(menubar,tearoff=0)
menubar.add_cascade(label="Output",menu=outputMenu)
outputMenu.add_command(label="Copy answers for this question")
outputMenu.add_command(label="Copy total scores up to this question")
outputMenu.add_command(label="Copy score table up to this question")
outputMenu.add_command(label="Copy Player list")
outputMenu.add_separator()
styleMenu=Menu(menubar,tearoff=0)
outputMenu.add_cascade(label="Output Style",menu=styleMenu)
styleMenu.add_radiobutton(label="Forum Table",value=1, variable=Outputtype)
styleMenu.add_radiobutton(label="Forum Formatted Text",value=2, variable=Outputtype)
styleMenu.add_radiobutton(label="Unformatted Text",value=3, variable=Outputtype)

def qdown():
global curQ
global myLabel2
if curQ>len(myQuestions): curQ = len(myQuestions)

if curQ>1:
curQ=curQ-1
myTextbox1.delete(0, END)
myTextbox1.insert(INSERT, curQ)
myTextbox1.grid_forget()
myTextbox1.grid(row=0, column=2)
if curQ == 0: return
if len(myQuestions) >= curQ:
myLabel2.grid_forget()
myLabel2 = Label(window, text=myQuestions[curQ-1])
myLabel2.grid(row=0, column=4)
def qup():
global curQ
global myLabel2
if curQ > len(myQuestions): curQ = len(myQuestions)
if curQ < len(myQuestions):
curQ = curQ + 1
else:
curQ == 1
myTextbox1.delete(0,END)
myTextbox1.insert(INSERT, curQ)
myTextbox1.grid_forget()
myTextbox1.grid(row=0, column=2)
if curQ == 0: return
if len(myQuestions) >= curQ:
myLabel2.grid_forget()
myLabel2 = Label(window, text=myQuestions[curQ-1])
myLabel2.grid(row=0, column=4)


qButton1 = Button(window, text="<",command=qdown).grid(row=0,column=1)
qButton2 = Button(window, text=">",command=qup).grid(row=0,column=3)
myLabel1 = Label(window, text="Q #", padx=5).grid(row=0,column=0)
myLabel2 = Label(window, text="Click Sheep > Edit Questions... to begin.")
myLabel2.grid(row=0,column=4)




myTextbox1 = Entry(window,width=4 ,validate="key",
validatecommand=(window.register(validate_entry), "%S"))

myTextbox1.insert(INSERT,curQ)
myTextbox1.grid(row=0,column=2)


myTextbox2 = Text(window,state=DISABLED,padx=10,pady=5)
myTextbox2.grid(row=1,column=0,columnspan=5)
window.columnconfigure(4, weight=1)
window.mainloop()





The following 1 user thanked this post:
• Sephiroth_Dude  
Find
Reply
A sheep, a werewolf and a walrus walk into a bar. › Game Sign Ups › Game Sign Ups v
1 2 3 4 5 … 8 Next »
› [Closed] Sheek, the sheep game with a knockout twist.


Messages In This Thread
Sheek, the sheep game with a knockout twist. - by Neowise - 24-06-2023, 05:19 PM
RE: Sheek, the sheep game with a knockout twist. - by jp liz v1 - 25-06-2023, 12:08 AM
RE: Sheek, the sheep game with a knockout twist. - by Leg End Reject - 25-06-2023, 02:02 AM
RE: Sheek, the sheep game with a knockout twist. - by Neowise - 25-06-2023, 08:41 PM
RE: Sheek, the sheep game with a knockout twist. - by Leg End Reject - 25-06-2023, 10:49 PM
RE: Sheek, the sheep game with a knockout twist. - by lorcand1990 - 27-06-2023, 03:33 PM
RE: Sheek, the sheep game with a knockout twist. - by jp liz v1 - 25-06-2023, 11:54 PM
RE: Sheek, the sheep game with a knockout twist. - by Declan A Walsh - 26-06-2023, 10:28 AM
RE: Sheek, the sheep game with a knockout twist. - by lorcand1990 - 26-06-2023, 12:14 PM
RE: Sheek, the sheep game with a knockout twist. - by BuileBeag - 26-06-2023, 06:51 PM
RE: Sheek, the sheep game with a knockout twist. - by nothing - 26-06-2023, 09:21 PM
RE: Sheek, the sheep game with a knockout twist. - by Mam of 4 - 26-06-2023, 09:21 PM
RE: Sheek, the sheep game with a knockout twist. - by Spears - 26-06-2023, 10:33 PM
RE: Sheek, the sheep game with a knockout twist. - by Leg End Reject - 27-06-2023, 02:05 PM
RE: Sheek, the sheep game with a knockout twist. - by Spears - 27-06-2023, 08:54 PM
RE: Sheek, the sheep game with a knockout twist. - by davetherave - 29-06-2023, 03:39 PM
RE: Sheek, the sheep game with a knockout twist. - by Neowise - 29-06-2023, 06:46 PM
RE: Sheek, the sheep game with a knockout twist. - by Sephiroth_Dude - 30-06-2023, 12:04 AM
RE: Sheek, the sheep game with a knockout twist. - by Neowise - 30-06-2023, 12:31 AM
RE: Sheek, the sheep game with a knockout twist. - by Sephiroth_Dude - 30-06-2023, 01:00 PM
RE: Sheek, the sheep game with a knockout twist. - by Neowise - 30-06-2023, 01:13 PM
RE: Sheek, the sheep game with a knockout twist. - by Sephiroth_Dude - 30-06-2023, 01:14 PM
RE: Sheek, the sheep game with a knockout twist. - by E.N. - 29-06-2023, 11:56 PM
RE: Sheek, the sheep game with a knockout twist. - by Neowise - 30-06-2023, 12:38 AM
RE: Sheek, the sheep game with a knockout twist. - by Neowise - 30-06-2023, 01:18 PM
RE: Sheek, the sheep game with a knockout twist. - by Sephiroth_Dude - 30-06-2023, 08:49 PM
RE: Sheek, the sheep game with a knockout twist. - by Neowise - 06-07-2023, 05:10 PM
RE: Sheek, the sheep game with a knockout twist. - by Neowise - 06-07-2023, 05:22 PM
RE: Sheek, the sheep game with a knockout twist. - by Neowise - 06-07-2023, 05:22 PM
RE: Sheek, the sheep game with a knockout twist. - by Neowise - 08-07-2023, 12:38 AM
RE: Sheek, the sheep game with a knockout twist. - by Neowise - 08-07-2023, 04:14 PM

  • View a Printable Version
Forum Jump:


Users browsing this thread: 1 Guest(s)
  • Contact Us
  • Return to Top
  • Lite (Archive) Mode
  • Privacy Policy
Community Forum Software by MyBB
Theme based on design by Rooloo,
But severely customized by Fogies.
Top
All opinions expressed are those of the individual and do not reflect those of the site or it's mods & administrators.