Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import tkinter as tk
- import tkinter.simpledialog as sdg
- import tkinter.messagebox as mbx
- import tkinter.font as tkf
- import tkinter.tix as tix
- import random as rnd
- import operator as op
- import os
- #Charlie Cook's Dungeons & Dragons Character Sheet Program
- #Begun early June 2017
- #Last updated late October 2017
- def updtSAVETHRW():
- savingThrows[0] = mainStats[2] + bonusStats[2]
- savingThrows[1] = mainStats[1] + bonusStats[1]
- savingThrows[2] = mainStats[4] + bonusStats[4]
- def levelUp():
- experience[0] += 1
- experience[1] -= experience[2]
- if LEVLVar.get():
- experience[2] = brackets5E[experience[0]]
- else:
- experience[2] = 100 + 10 * experience[0]
- mbx.showinfo("Level Up!","Congratulations!\nYou are now Level " + str(experience[0]))
- def refrSTAT():
- LEVLLbl.config(text = "Level: " + str(experience[0]))
- HPLbl.config(text = "HP:" + str(health[0]) + "/" + str(health[1]))
- XPLbl.config(text = "XP:" + str(experience[1]) + "/" + str(experience[2]))
- STRLbl.config(text = "STR: " + str(mainStats[0]))
- DEXLbl.config(text = "DEX: " + str(mainStats[1]))
- CONLbl.config(text = "CON: " + str(mainStats[2]))
- INTLbl.config(text = "INT: " + str(mainStats[3]))
- WISLbl.config(text = "WIS: " + str(mainStats[4]))
- CHALbl.config(text = "CHA: " + str(mainStats[5]))
- if bonusStats[0] > 0:
- STRBLbl.config(text = "+" + str(bonusStats[0]))
- else:
- STRBLbl.config(text = str(bonusStats[0]))
- if bonusStats[1] > 0:
- DEXBLbl.config(text = "+" + str(bonusStats[1]))
- else:
- DEXBLbl.config(text = str(bonusStats[1]))
- if bonusStats[2] > 0:
- CONBLbl.config(text = "+" + str(bonusStats[2]))
- else:
- CONBLbl.config(text = str(bonusStats[2]))
- if bonusStats[3] > 0:
- INTBLbl.config(text = "+" + str(bonusStats[3]))
- else:
- INTBLbl.config(text = str(bonusStats[3]))
- if bonusStats[4] > 0:
- WISBLbl.config(text = "+" + str(bonusStats[4]))
- else:
- WISBLbl.config(text = str(bonusStats[4]))
- if bonusStats[5] > 0:
- CHABLbl.config(text = "+" + str(bonusStats[5]))
- else:
- CHABLbl.config(text = str(bonusStats[5]))
- updtSAVETHRW()
- FORTLbl.config(text = "Fortitude: " + str(savingThrows[0]))
- REFLLbl.config(text = "Reflex: " + str(savingThrows[1]))
- WILLLbl.config(text = "Will: " + str(savingThrows[2]))
- def HPUp():
- if health[0] < health[1]:
- health[0] += 1
- refrSTAT()
- def HPDown():
- if health[0] > 0:
- health[0] -= 1
- refrSTAT()
- def XPUp():
- temp = sdg.askinteger("Add XP", "Enter how many experience points you've earned:")
- if type(temp) == int:
- experience[1] += temp
- while experience[1] > experience[2]:
- levelUp()
- refrSTAT()
- refrSTAT()
- def ChangeXP():
- if mbx.askokcancel("Warning!", "Changing the level up brackets may make things weird. Is it okay to continue?"):
- if LEVLVar.get():
- tempLvl = experience[0] - 1
- tempXP = experience[1]
- tempMXP = tempLvl * 10 + 100
- while tempLvl > 0:
- tempXP += tempMXP
- tempLvl -= 1
- tempMXP = tempLvl * 10 + 100
- print(tempXP)
- experience[1] = tempXP
- experience[0] = 1
- experience[2] = brackets5E[1]
- while experience[1] > experience[2]:
- levelUp()
- refrSTAT()
- else:
- tempLvl = experience[0] - 1
- tempXP = experience[1]
- tempMXP = brackets5E[tempLvl]
- while tempLvl > 0:
- tempXP += tempMXP
- tempLvl -= 1
- tempMXP = brackets5E[tempLvl]
- print(tempXP)
- experience[1] = tempXP
- experience[0] = 1
- experience[2] = 110
- while experience[1] > experience[2]:
- levelUp()
- refrSTAT()
- refrSTAT()
- else:
- LEVLVar.set(not LEVLVar.get())
- class editStatRoot(sdg.Dialog):
- def body(self, master):
- self.title("Edit Stats")
- self.resizable(False, False)
- self.choice = tk.IntVar()
- self.choice.set(1)
- tk.Label(master, text = "Choose a stat item to edit:", font = ftSmall).grid(row = 0)
- STR = tk.Radiobutton(master, text = "Strength", value = 1, variable = self.choice, cursor = "hand2", font = ftSmall)
- DEX = tk.Radiobutton(master, text = "Dexterity", value = 2, variable = self.choice, cursor = "hand2", font = ftSmall)
- CON = tk.Radiobutton(master, text = "Constitution", value = 3, variable = self.choice, cursor = "hand2", font = ftSmall)
- INT = tk.Radiobutton(master, text = "Intelligence", value = 4, variable = self.choice, cursor = "hand2", font = ftSmall)
- WIS = tk.Radiobutton(master, text = "Wisdom", value = 5, variable = self.choice, cursor = "hand2", font = ftSmall)
- CHA = tk.Radiobutton(master, text = "Charisma", value = 6, variable = self.choice, cursor = "hand2", font = ftSmall)
- LEV = tk.Radiobutton(master, text = "Level", value = 7, variable = self.choice, cursor = "hand2", font = ftSmall)
- XP = tk.Radiobutton(master, text = "Experience", value = 8, variable = self.choice, cursor = "hand2", font = ftSmall)
- HPC = tk.Radiobutton(master, text = "Current Health", value = 9, variable = self.choice, cursor = "hand2", font = ftSmall)
- HPM = tk.Radiobutton(master, text = "Maximum Health", value = 10, variable = self.choice, cursor = "hand2", font = ftSmall)
- STR.grid(row = 5, sticky = "w")
- DEX.grid(row = 6, sticky = "w")
- CON.grid(row = 7, sticky = "w")
- INT.grid(row = 8, sticky = "w")
- WIS.grid(row = 9, sticky = "w")
- CHA.grid(row = 10, sticky = "w")
- LEV.grid(row = 1, sticky = "w")
- XP.grid(row = 2, sticky = "w")
- HPC.grid(row = 3, sticky = "w")
- HPM.grid(row = 4, sticky = "w")
- def apply(self):
- self.result = self.choice.get()
- class editStatLeaf(sdg.Dialog):
- def __init__(self, master = None, m = 0):
- self.mode = m - 1
- super().__init__(master)
- def body(self, master):
- choices = ["Strength", "Dexterity", "Constitution", "Intelligence", "Wisdom", "Charisma"]
- self.title("Edit " + choices[self.mode])
- self.resizable(False, False)
- tk.Label(master, text = "Enter your new " + choices[self.mode].lower() + ":", font = ftSmall).grid(row = 0)
- tk.Label(master, text = "Enter your new " + choices[self.mode].lower() + " bonus:", font = ftSmall).grid(row = 2)
- tk.Label(master, text = "Note: Blank/Unchanged fields\nwill result in no change", font = ftSmall).grid(row = 4)
- self.Value = tk.Entry(master, font = ftSmall)
- self.Bonus = tk.Entry(master, font = ftSmall)
- self.Value.insert(0, mainStats[self.mode])
- self.Bonus.insert(0, bonusStats[self.mode])
- self.Value.grid(row = 1)
- self.Bonus.grid(row = 3)
- def apply(self):
- try:
- temp = []
- if len(self.Value.get()) > 0:
- temp.append(int(self.Value.get()))
- else:
- temp.append("")
- if len(self.Bonus.get()) > 0:
- temp.append(int(self.Bonus.get()))
- else:
- temp.append("")
- self.result = temp
- except:
- mbx.showerror("Error","Invalid Input")
- self.result = []
- def editStat():
- choice = editStatRoot(base).result
- if type(choice) == int:
- if choice < 7:
- temp = editStatLeaf(base, choice).result
- elif choice == 7:
- temp = sdg.askinteger("Edit Level", "Enter your new level:", initialvalue = experience[0])
- if type(temp) == int:
- experience[0] = temp
- experience[2] = 100 + 10 * experience[0]
- elif choice == 8:
- temp = sdg.askinteger("Edit Experience", "Enter your new current experience points:", initialvalue = experience[1])
- if type(temp) == int:
- experience[1] = temp
- while experience[1] > experience[2]:
- levelUp()
- elif choice == 9:
- temp = health[1] + 1
- while temp > health[1]:
- temp = sdg.askinteger("Edit Health", "Enter your new current health:", initialvalue = health[0])
- if type(temp) != int:
- return
- elif temp > health[1]:
- mbx.showerror("Error", "You can't overcharge your health!")
- if type(temp) == int:
- health[0] = temp
- elif choice == 10:
- temp = sdg.askinteger("Edit Health", "Enter your new maximum health:", initialvalue = health[1])
- if type(temp) == int:
- health[1] = temp
- if health[0] > health[1]:
- health[0] = health[1]
- if type(temp) == list:
- if type(temp[0]) == int:
- mainStats[choice - 1] = temp[0]
- if type(temp[1]) == int:
- bonusStats[choice - 1] = temp[1]
- refrSTAT()
- elif type(temp) == int:
- refrSTAT()
- def refrINFO():
- NAMELbl.config(text = info[0])
- CLSSLbl.config(text = info[1])
- DETYLbl.config(text = info[2])
- RACELbl.config(text = info[3])
- GNDRLbl.config(text = info[4])
- AYGELbl.config(text = "Age: " + str(info[5]))
- HGHTLbl.config(text = str(info[6]) + " " + info[7])
- WGHTLbl.config(text = str(info[8]) + " " + info[9])
- HAIRLbl.config(text = "Hair: " + info[10])
- EYESLbl.config(text = "Eyes: " + info[11])
- MONYLbl.config(text = str(info[13]) + " " + info[12])
- def changeMoney():
- debit = sdg.askinteger("Change Money", "How much money to add/remove?")
- if type(debit) == int:
- info[13] += debit
- refrINFO()
- class editInfoRoot(sdg.Dialog):
- def body(self, master):
- self.title("Edit Info")
- self.resizable(False, False)
- self.choice = tk.IntVar()
- self.choice.set(1)
- tk.Label(master, text = "Choose an info item to edit:", font = ftSmall).grid(row = 0)
- Name = tk.Radiobutton(master, text = "Name", value = 1, variable = self.choice, cursor = "hand2", font = ftSmall)
- Class = tk.Radiobutton(master, text = "Class", value = 2, variable = self.choice, cursor = "hand2", font = ftSmall)
- Deity = tk.Radiobutton(master, text = "Deity", value = 3, variable = self.choice, cursor = "hand2", font = ftSmall)
- Race = tk.Radiobutton(master, text = "Race", value = 4, variable = self.choice, cursor = "hand2", font = ftSmall)
- Gender = tk.Radiobutton(master, text = "Gender", value = 5, variable = self.choice, cursor = "hand2", font = ftSmall)
- Age = tk.Radiobutton(master, text = "Age", value = 6, variable = self.choice, cursor = "hand2", font = ftSmall)
- Height = tk.Radiobutton(master, text = "Height", value = 7, variable = self.choice, cursor = "hand2", font = ftSmall)
- Weight = tk.Radiobutton(master, text = "Weight", value = 8, variable = self.choice, cursor = "hand2", font = ftSmall)
- HairColor = tk.Radiobutton(master, text = "Hair Color", value = 9, variable = self.choice, cursor = "hand2", font = ftSmall)
- EyeColor = tk.Radiobutton(master, text = "Eye Color", value = 10, variable = self.choice, cursor = "hand2", font = ftSmall)
- Currency = tk.Radiobutton(master, text = "Currency", value = 11, variable = self.choice, cursor = "hand2", font = ftSmall)
- Name.grid(row = 1, sticky = "w")
- Class.grid(row = 2, sticky = "w")
- Deity.grid(row = 3, sticky = "w")
- Race.grid(row = 4, sticky = "w")
- Gender.grid(row = 5, sticky = "w")
- Age.grid(row = 6, sticky = "w")
- Height.grid(row = 7, sticky = "w")
- Weight.grid(row = 8, sticky = "w")
- HairColor.grid(row = 9, sticky = "w")
- EyeColor.grid(row = 10, sticky = "w")
- Currency.grid(row = 11, sticky = "w")
- def apply(self):
- self.result = self.choice.get()
- class editWH(sdg.Dialog):
- def __init__(self, master = None, m = 9):
- self.mode = m - 7
- super().__init__(master)
- def toggleUnit(self):
- if self.ChangeUnit.get() == 1:
- self.Unit.config(state = "normal")
- else:
- self.Unit.config(state = "disabled")
- def body(self, master):
- choices = ["height", "weight"]
- self.title("Edit " + choices[self.mode].title())
- self.resizable(False, False)
- self.ChangeUnit = tk.IntVar()
- self.ChangeUnit.set(0)
- tk.Label(master, text = "Enter your new " + choices[self.mode] + ":", font = ftSmall).grid(row = 0)
- self.Value = tk.Entry(master, font = ftSmall)
- self.Unit = tk.Entry(master, font = ftSmall)
- if self.mode == 0:
- self.Value.insert(0, info[6])
- self.Unit.insert(0, info[7])
- elif self.mode == 1:
- self.Value.insert(0, info[8])
- self.Unit.insert(0, info[9])
- self.Unit.config(state = "disabled")
- ChangeUnitChk = tk.Checkbutton(master, text = "Check to change unit", variable = self.ChangeUnit, command = self.toggleUnit, font = ftSmall)
- self.Value.grid(row = 1)
- self.Unit.grid(row = 3)
- ChangeUnitChk.grid(row = 2)
- def apply(self):
- try:
- self.result = [int(self.Value.get()), self.Unit.get(), self.ChangeUnit.get()]
- except:
- mbx.showerror("Error","Invalid Measurement")
- self.result = []
- def editInfo():
- editInfoSelect(editInfoRoot(base).result)
- refrINFO()
- def editInfoSelect(choice):
- if choice in range(1, 7) or choice in range(9, 12):
- if choice < 8:
- index = choice - 1
- else:
- index = choice + 1
- choices = ["", "name", "class", "deity", "race", "gender", "age", "", "", "hair color", "eye color", "currency"]
- if choice == 6:
- temp = sdg.askinteger("Edit " + choices[choice].title(), "Enter your new " + choices[choice], initialvalue = info[index])
- if type(temp) == int:
- info[index] = temp
- elif choice != 6:
- temp = sdg.askstring("Edit " + choices[choice].title(), "Enter your new " + choices[choice], initialvalue = info[index])
- if type(temp) == str:
- info[index] = temp
- elif choice in range(7, 9):
- n = choice
- if n < 8:
- n -= 1
- temp = editWH(base, choice).result
- if type(temp) == list and len(temp) > 0:
- info[n] = temp[0]
- if temp[2] == 1:
- info[n + 1] = temp[1]
- def refrINVT():
- INVTTxt.delete(0, INVTTxt.size())
- tempWGHT = 0.0
- for item in inventory:
- tempWGHT += round(item[2] * item[3], 4)
- tempStr = ""
- tempStr += item[0][:36]
- if len(item[0]) > 36:
- tempStr += "... "
- else:
- tempStr += (40 - len(item[0])) * " "
- tempStr += str(item[2])
- tempStr += (8 - len(str(item[2]))) * " "
- tempStr += str(item[3])
- tempStr += (8 - len(str(item[3]))) * " "
- if item[4] != 0 and item[5]:
- tempStr += "d" + str(item[4]) + " x" + str(item[5])
- tempStr += (8 - len("d" + str(item[4]) + " x" + str(item[5]))) * " "
- else:
- tempStr += 8 * " "
- if item[7] != 0:
- tempStr += str(item[6]) + "/" + str(item[7])
- tempStr += (8 - len(str(item[6]) + "/" + str(item[7]))) * " "
- else:
- tempStr += 8 * " "
- if item[8]:
- tempStr += "Yes"
- else:
- tempStr += "No"
- INVTTxt.insert("end", tempStr)
- INVTENCMLbl.config(text = "Encumberance: " + str(tempWGHT))
- def newItem():
- tempItem = []
- tempStr = ""
- try:
- while len(tempStr) == 0:
- tempStr = sdg.askstring("New Item", "Enter the new item's name:")
- if len(tempStr) == 0:
- mbx.showerror("Error", "You must name your item!")
- tempItem.append(tempStr)
- tempStr = sdg.askstring("New Item", "[Optional] Enter the new item's bonus(es):")
- tempItem.append(tempStr)
- tempItem.append(sdg.askinteger("New Item", "Enter how many of the new item you have:"))
- tempItem.append(sdg.askfloat("New Item", "Enter the weight of the item:"))
- tempItem.append(sdg.askinteger("New Item", "[Optional] Enter the type of dice the item uses:"))
- tempItem.append(sdg.askinteger("New Item", "[Optional] Enter the amount of dice rolls for the item:"))
- tempItem.append(sdg.askinteger("New Item", "[Optional] Enter the maximum magical charges the item has:"))
- tempInt = tempItem[6] + 1
- while tempInt > tempItem[6]:
- tempInt = sdg.askinteger("New Item", "[Optional] Enter the current magical charges the item has:")
- if tempInt > tempItem[6]:
- mbx.showerror("Error", "You can't overcharge your item!")
- tempItem.insert(6, tempInt)
- tempItem.append(mbx.askyesno("New Item", "Is the item equipped?"))
- inventory.append(tempItem)
- refrINVT()
- except TypeError:
- pass
- class editItemRoot(sdg.Dialog):
- def __init__(self, master = None, i = ""):
- self.item = i
- super().__init__(master)
- def body(self, master):
- self.title("Edit " + self.item)
- self.resizable(False, False)
- self.choice = tk.IntVar()
- self.choice.set(0)
- tk.Label(master, text = "Choose an item attribute to edit:", font = ftSmall).grid(row = 0)
- Name = tk.Radiobutton(master, text = "Name", value = 0, variable = self.choice, cursor = "hand2", font = ftSmall)
- Bonus = tk.Radiobutton(master, text = "Bonus(es)", value = 1, variable = self.choice, cursor = "hand2", font = ftSmall)
- Count = tk.Radiobutton(master, text = "Count", value = 2, variable = self.choice, cursor = "hand2", font = ftSmall)
- Weight = tk.Radiobutton(master, text = "Weight", value = 3, variable = self.choice, cursor = "hand2", font = ftSmall)
- dType = tk.Radiobutton(master, text = "Dice Type", value = 4, variable = self.choice, cursor = "hand2", font = ftSmall)
- dCount = tk.Radiobutton(master, text = "Dice Count", value = 5, variable = self.choice, cursor = "hand2", font = ftSmall)
- Charges = tk.Radiobutton(master, text = "Charges", value = 6, variable = self.choice, cursor = "hand2", font = ftSmall)
- MaxCharges = tk.Radiobutton(master, text = "Max Charges", value = 7, variable = self.choice, cursor = "hand2", font = ftSmall)
- Equipped = tk.Radiobutton(master, text = "Equipped", value = 8, variable = self.choice, cursor = "hand2", font = ftSmall)
- Name.grid(row = 1, sticky = "w")
- Bonus.grid(row = 2, sticky = "w")
- Count.grid(row = 3, sticky = "w")
- Weight.grid(row = 4, sticky = "w")
- dType.grid(row = 5, sticky = "w")
- dCount.grid(row = 6, sticky = "w")
- Charges.grid(row = 7, sticky = "w")
- MaxCharges.grid(row = 8, sticky = "w")
- Equipped.grid(row = 9, sticky = "w")
- def apply(self):
- self.result = self.choice.get()
- def editItem():
- try:
- index = INVTTxt.curselection()[0]
- item = inventory[index]
- attr = editItemRoot(base, item[0]).result
- if type(attr) == int:
- choices = ["Name", "Bonus(es)", "Count", "Weight", "Dice Type", "Dice Count", "Charges", "Max Charges", ""]
- title = "Edit " + item[0]
- prompt = "Enter the item's new " + choices[attr] + ":"
- if attr < 2:
- temp = sdg.askstring(title, prompt, initialvalue = item[attr])
- if type(temp) == str and len(temp) > 0 and temp != item[attr]:
- inventory[index][attr] = temp
- elif attr < 6 and attr != 3:
- temp = sdg.askinteger(title, prompt, initialvalue = item[attr])
- if type(temp) == int and temp != item[attr]:
- inventory[index][attr] = temp
- elif attr == 3:
- temp = sdg.askfloat(title, prompt, initialvalue = item[attr])
- if type(temp) == float and temp != item[attr]:
- inventory[index][attr] = temp
- elif attr == 6:
- temp = item[7] + 1
- while type(temp) == int and temp > item[7]:
- temp = sdg.askinteger(title, prompt, initialvalue = item[attr])
- if type(temp) == int and temp > item[7]:
- mbx.showerror("Error", "You can't overcharge your item!")
- if type(temp) == int and temp != item[attr]:
- inventory[index][attr] = temp
- elif attr == 7:
- temp = sdg.askinteger(title, prompt, initialvalue = item[attr])
- if type(temp) == int and temp != item[attr]:
- if temp < item[6]:
- inventory[index][6] = temp
- inventory[index][attr] = temp
- else:
- inventory[index][attr] = not inventory[index][attr]
- refrINVT()
- except IndexError:
- mbx.showerror("Error", "No item selected!")
- def inspectItem():
- try:
- if len(inventory[INVTTxt.curselection()[0]][1]) > 0:
- mbx.showinfo("Item: " + inventory[INVTTxt.curselection()[0]][0], "Bonus:\n" + inventory[INVTTxt.curselection()[0]][1])
- else:
- mbx.showinfo("Item: " + inventory[INVTTxt.curselection()[0]][0], "Bonus:\n[None]")
- except IndexError:
- mbx.showerror("Error", "No item selected!")
- def deleteItem():
- try:
- if mbx.askyesno("Delete Item: " + inventory[INVTTxt.curselection()[0]][0], "Are you sure you want to delete this item?"):
- del inventory[INVTTxt.curselection()[0]]
- refrINVT()
- except IndexError:
- mbx.showerror("Error", "No item selected!")
- class sortItemsRoot(sdg.Dialog):
- def body(self, master):
- self.title("Sort Items")
- self.resizable(False, False)
- self.choice = tk.IntVar()
- self.order = tk.IntVar()
- self.choice.set(0)
- self.order.set(0)
- tk.Label(master, text = "Choose an attribute to sort by:", font = ftSmall).grid(row = 0)
- tk.Label(master, text = "Choose an order to sort by:", font = ftSmall).grid(row = 9)
- Name = tk.Radiobutton(master, text = "Name", value = 0, variable = self.choice, cursor = "hand2", font = ftSmall)
- Count = tk.Radiobutton(master, text = "Count", value = 2, variable = self.choice, cursor = "hand2", font = ftSmall)
- Weight = tk.Radiobutton(master, text = "Weight", value = 3, variable = self.choice, cursor = "hand2", font = ftSmall)
- dType = tk.Radiobutton(master, text = "Dice Type", value = 4, variable = self.choice, cursor = "hand2", font = ftSmall)
- dCount = tk.Radiobutton(master, text = "Dice Count", value = 5, variable = self.choice, cursor = "hand2", font = ftSmall)
- Charges = tk.Radiobutton(master, text = "Charges", value = 6, variable = self.choice, cursor = "hand2", font = ftSmall)
- MaxCharges = tk.Radiobutton(master, text = "Max Charges", value = 7, variable = self.choice, cursor = "hand2", font = ftSmall)
- Equipped = tk.Radiobutton(master, text = "Equipped", value = 8, variable = self.choice, cursor = "hand2", font = ftSmall)
- Ascending = tk.Radiobutton(master, text = "Ascending", value = 1, variable = self.order, cursor = "hand2", font = ftSmall)
- Descending = tk.Radiobutton(master, text = "Descending", value = 0, variable = self.order, cursor = "hand2", font = ftSmall)
- Name.grid(row = 1, sticky = "w")
- Count.grid(row = 2, sticky = "w")
- Weight.grid(row = 3, sticky = "w")
- dType.grid(row = 4, sticky = "w")
- dCount.grid(row = 5, sticky = "w")
- Charges.grid(row = 6, sticky = "w")
- MaxCharges.grid(row = 7, sticky = "w")
- Equipped.grid(row = 8, sticky = "w")
- Ascending.grid(row = 10, sticky = "w")
- Descending.grid(row = 11, sticky = "w")
- def apply(self):
- self.result = [self.choice.get(), self.order.get()]
- def sortItems():
- choice = sortItemsRoot(base).result
- if type(choice) == list:
- if choice[1] == 1:
- order = True
- else:
- order = False
- inventory.sort(key = op.itemgetter(choice[0]), reverse = order)
- refrINVT()
- def rollDice(d):
- def rollDiceWrap(dice = d):
- if dice < 100:
- DICELbl.config(text = str(rnd.randint(1, dice)) + " | d" + str(dice))
- else:
- DICELbl.config(text = str(rnd.randint(0, 100)) + " | d%")
- return rollDiceWrap
- def refrSKIL():
- SKILTxt.delete(0, SKILTxt.size())
- stats = ["STR", "DEX", "CON", "INT", "WIS", "CHA"]
- for sk in skills:
- SKILTxt.insert("end", stats[sk[0]] + "|" + sk[1])
- class skillStat(sdg.Dialog):
- def __init__(self, master = None, m = "", sa = "", i = 0):
- self.mode = m
- self.skab = sa
- self.index = i
- super().__init__(master)
- def body(self, master):
- self.resizable(False, False)
- self.stat = tk.IntVar()
- if self.skab == "skill":
- if self.mode == "edit":
- self.title("Edit " + skills[self.index][1])
- self.stat.set(skills[self.index][0])
- elif self.mode == "new":
- self.title("New Skill")
- self.stat.set(0)
- elif self.skab == "ability":
- if self.mode == "edit":
- self.title("Edit " + abilities[self.index][1])
- self.stat.set(abilities[self.index][0])
- elif self.mode == "new":
- self.title("New Ability")
- self.stat.set(0)
- PRMPLbl = tk.Label(master, font = ftSmall)
- PRMPLbl.grid(row = 0)
- if self.skab == "skill":
- if self.mode == "edit":
- PRMPLbl.config(text = "[Optional] Choose a new stat for the skill:")
- elif self.mode == "new":
- PRMPLbl.config(text = "Choose a stat for the skill:")
- elif self.skab == "ability":
- if self.mode == "edit":
- PRMPLbl.config(text = "[Optional] Choose a new stat for the ability:")
- elif self.mode == "new":
- PRMPLbl.config(text = "Choose a stat for the ability:")
- STRBtn = tk.Radiobutton(master, text = "Strength", value = 0, variable = self.stat, font = ftSmall)
- DEXBtn = tk.Radiobutton(master, text = "Dexterity", value = 1, variable = self.stat, font = ftSmall)
- CONBtn = tk.Radiobutton(master, text = "Constitution", value = 2, variable = self.stat, font = ftSmall)
- INTBtn = tk.Radiobutton(master, text = "Intelligence", value = 3, variable = self.stat, font = ftSmall)
- WISBtn = tk.Radiobutton(master, text = "Wisdom", value = 4, variable = self.stat, font = ftSmall)
- CHABtn = tk.Radiobutton(master, text = "Charisma", value = 5, variable = self.stat, font = ftSmall)
- STRBtn.grid(row = 1, sticky = "w")
- DEXBtn.grid(row = 2, sticky = "w")
- CONBtn.grid(row = 3, sticky = "w")
- INTBtn.grid(row = 4, sticky = "w")
- WISBtn.grid(row = 5, sticky = "w")
- CHABtn.grid(row = 6, sticky = "w")
- def apply(self):
- self.result = self.stat.get()
- def newSkill():
- tempStr = ""
- while type(tempStr) == str and len(tempStr) < 1:
- tempStr = sdg.askstring("New Skill", "Enter the new skill's name:")
- if type(tempStr) == str and len(tempStr) < 1:
- mbx.showerror("Error", "You must name this skill!")
- if type(tempStr) == str:
- tempInt = skillStat(base, "new", "skill").result
- if type(tempInt) == int:
- skills.append([tempInt, tempStr])
- refrSKIL()
- def editSkill():
- try:
- index = SKILTxt.curselection()[0]
- sk = skills[index]
- tempStr = sdg.askstring("Edit " + sk[1], "[Optional] Enter the skill's new name:", initialvalue = sk[1])
- if type(tempStr) == str:
- if len(tempStr) > 0 and tempStr != sk[1]:
- skills[index][1] = tempStr
- tempInt = skillStat(base, "edit", "skill", index).result
- if type(tempInt) == int and tempInt != sk[0]:
- skills[index][0] = tempInt
- refrSKIL()
- except IndexError:
- mbx.showerror("Error", "No skill selected!")
- def deleteSkill():
- try:
- if mbx.askyesno("Delete " + skills[SKILTxt.curselection()[0]][1], "Are you sure you want to delete this skill?"):
- del skills[SKILTxt.curselection()[0]]
- refrSKIL()
- except IndexError:
- mbx.showerror("Error", "No skill selected!")
- class sortSkillsAbils(sdg.Dialog):
- def __init__(self, master = None, sa = ""):
- self.skab = sa
- super().__init__(master)
- def body(self, master):
- if self.skab == "skill":
- self.title("Sort Skills")
- elif self.skab == "ability":
- self.title("Sort Abilities")
- self.resizable(False, False)
- self.choice = tk.IntVar()
- self.order = tk.IntVar()
- self.choice.set(0)
- self.order.set(0)
- tk.Label(master, text = "Choose an attribute to sort by:", font = ftSmall).grid(row = 0)
- tk.Label(master, text = "Choose an order to sort by:", font = ftSmall).grid(row = 3)
- Name = tk.Radiobutton(master, text = "Name", value = 1, variable = self.choice, cursor = "hand2", font = ftSmall)
- Stat = tk.Radiobutton(master, text = "Stat", value = 0, variable = self.choice, cursor = "hand2", font = ftSmall)
- Ascending = tk.Radiobutton(master, text = "Ascending", value = 1, variable = self.order, cursor = "hand2", font = ftSmall)
- Descending = tk.Radiobutton(master, text = "Descending", value = 0, variable = self.order, cursor = "hand2", font = ftSmall)
- Name.grid(row = 1, sticky = "w")
- Stat.grid(row = 2, sticky = "w")
- Ascending.grid(row = 4, sticky = "w")
- Descending.grid(row = 5, sticky = "w")
- def apply(self):
- self.result = [self.choice.get(), self.order.get()]
- def sortSkills():
- choice = sortSkillsAbils(base, "skill").result
- if type(choice) == list:
- if choice[1] == 1:
- order = True
- else:
- order = False
- skills.sort(key = op.itemgetter(choice[0]), reverse = order)
- refrSKIL()
- def refrABIL():
- ABILTxt.delete(0, ABILTxt.size())
- stats = ["STR", "DEX", "CON", "INT", "WIS", "CHA"]
- for ab in abilities:
- ABILTxt.insert("end", stats[ab[0]] + "|" + ab[1])
- def newAbility():
- tempStrA = ""
- while type(tempStrA) == str and len(tempStrA) < 1:
- tempStrA = sdg.askstring("New Ability", "Enter the new ability's name:")
- if type(tempStrA) == str and len(tempStrA) < 1:
- mbx.showerror("Error", "You must name this ability!")
- if type(tempStrA) == str:
- tempInt = skillStat(base, "new", "ability").result
- if type(tempInt) == int:
- tempStrB = sdg.askstring("New Ability", "Describe the new ability:")
- if type(tempStrB) == str:
- abilities.append([tempInt, tempStrA, tempStrB])
- refrABIL()
- def editAbility():
- try:
- index = ABILTxt.curselection()[0]
- ab = abilities[index]
- tempStr = sdg.askstring("Edit " + ab[1], "[Optional] Enter the ability's new name:", initialvalue = ab[1])
- if type(tempStr) == str:
- if len(tempStr) > 0 and tempStr != ab[1]:
- abilities[index][1] = tempStr
- tempInt = skillStat(base, "edit", "ability", index).result
- if type(tempInt) == int:
- if tempInt != ab[0]:
- abilities[index][0] = tempInt
- tempStr = sdg.askstring("Edit " + ab[1], "[Optional] Describe the ability again:", initialvalue = ab[2])
- if type(tempStr) == str and len(tempStr) > 0 and tempStr != ab[2]:
- abilities[index][2] = tempStr
- refrABIL()
- except IndexError:
- mbx.showerror("Error", "No ability selected!")
- def deleteAbility():
- try:
- if mbx.askyesno("Delete " + abilities[ABILTxt.curselection()[0]][1], "Are you sure you want to delete this ability?"):
- del abilities[ABILTxt.curselection()[0]]
- refrABIL()
- except IndexError:
- mbx.showerror("Error", "No ability selected!")
- def inspectAbility():
- try:
- if len(abilities[ABILTxt.curselection()[0]][2]) > 0:
- mbx.showinfo("Ability: " + abilities[ABILTxt.curselection()[0]][1], "Description:\n" + abilities[ABILTxt.curselection()[0]][2])
- else:
- mbx.showinfo("Ability: " + abilities[ABILTxt.curselection()[0]][1], "Description:\n[None]")
- except IndexError:
- mbx.showerror("Error", "No ability selected!")
- def sortAbilities():
- choice = sortSkillsAbils(base, "ability").result
- if type(choice) == list:
- if choice[1] == 1:
- order = True
- else:
- order = False
- abilities.sort(key = op.itemgetter(choice[0]), reverse = order)
- refrABIL()
- def exitOverride():
- if mbx.askyesno("Warning! Data Loss Possibility Detected!", "Unsaved data will be lost if you quit.\nAre you sure you want to quit?"):
- base.destroy()
- def newCharacter():
- if not mbx.askyesno("Warning! Data Loss Possibility Detected!", "Making a new character will erase all current data\nAre you sure you want to continue?"):
- return
- tempInfo = []
- tempHealth = []
- tempExp = []
- tempMStats = []
- tempBStats = []
- tempInt = 0
- tempIntB = 0
- tempStr = ""
- tempCount = 0
- infoChoices = ["name", "class", "deity", "race", "gender", "age", "height", "unit", "weight", "unit", "hair color", "eye color", "currency"]
- statChoices = ["Strength", "Dexterity", "Constitution", "Intelligence", "Wisdom", "Charisma"]
- while len(tempInfo) < 14:
- if tempCount < 5 or tempCount > 9:
- tempStr = sdg.askstring("New Character: Info", "Enter your " + infoChoices[tempCount] + ":")
- if type(tempStr) == str:
- tempInfo.append(tempStr)
- else:
- return
- if tempCount == 12:
- tempInt = sdg.askinteger("New Character: Info", "Enter how much currency you have:")
- if type(tempInt) == int:
- tempInfo.append(tempInt)
- else:
- return
- else:
- tempCount += 1
- elif tempCount > 5 and tempCount < 10:
- tempStr = sdg.askstring("New Character: Info", "Enter your unit of " + infoChoices[tempCount] + ":")
- if type(tempStr) != str:
- return
- tempInt = sdg.askinteger("New Character: Info", "Enter your " + infoChoices[tempCount] + ":")
- if type(tempInt) == int:
- tempInfo.append(tempInt)
- tempInfo.append(tempStr)
- tempCount += 2
- else:
- return
- elif tempCount == 5:
- tempInt = sdg.askinteger("New Character: Info", "Enter your " + infoChoices[tempCount] + ":")
- if type(tempInt) == int:
- tempInfo.append(tempInt)
- tempCount += 1
- else:
- return
- tempInt = sdg.askinteger("New Character: Health", "Enter your maximum health points:")
- if type(tempInt) != int:
- return
- tempIntB = tempInt + 1
- while tempIntB > tempInt or tempIntB < 0:
- tempIntB = sdg.askinteger("New Character: Health", "Enter your current health points:")
- if type(tempIntB) != int:
- return
- elif tempIntB > tempInt:
- mbx.showerror("Error", "You can't overcharge your health points!")
- elif tempIntB < 0:
- mbx.showerror("Error", "You can't undercharge your health points!")
- tempHealth.append(tempIntB)
- tempHealth.append(tempInt)
- tempInt = sdg.askinteger("New Character: Experience", "Enter your level:")
- if type(tempInt) != int:
- return
- tempExp.append(tempInt)
- tempInt = 100 + tempExp[0] * 10
- tempIntB = abs(sdg.askinteger("New Character: Experience", "Enter your current experience points:"))
- if type(tempIntB) != int:
- return
- tempExp.append(tempIntB)
- tempExp.append(tempInt)
- tempCount = 0
- while len(tempMStats) < 6 and len(tempBStats) < 6:
- tempInt = sdg.askinteger("New Character: Stats", "Enter your " + statChoices[tempCount] + ":")
- if type(tempInt) != int:
- return
- tempIntB = sdg.askinteger("New Character: Stats", "Enter your " + statChoices[tempCount] + " Bonus:")
- if type(tempIntB) == int:
- tempMStats.append(tempInt)
- tempBStats.append(tempIntB)
- tempCount += 1
- else:
- return
- tempCount = 0
- for bit in tempInfo:
- info[tempCount] = bit
- tempCount += 1
- tempCount = 0
- for bit in tempHealth:
- health[tempCount] = bit
- tempCount += 1
- tempCount = 0
- for bit in tempExp:
- experience[tempCount] = bit
- tempCount += 1
- tempCount = 0
- for bit in tempMStats:
- mainStats[tempCount] = bit
- tempCount += 1
- tempCount = 0
- for bit in tempBStats:
- bonusStats[tempCount] = bit
- tempCount += 1
- while len(skills) > 0:
- del skills[0]
- while len(abilities) > 0:
- del abilities[0]
- while len(inventory) > 0:
- del inventory[0]
- refrSTAT()
- refrINFO()
- refrSKIL()
- refrABIL()
- refrINVT()
- def saveCharacter():
- fileName = sdg.askstring("Save Character", "Enter the name of the file to save to:")
- if type(fileName) != str:
- return
- fileName += ".dat"
- if os.path.isfile(fileName):
- if not mbx.askyesno("Warning! File Already Exists!", "Do you want to overwrite " + fileName + "?"):
- return
- saveFile = open(fileName, "w")
- dlm = " || "
- adlm = " |\n"
- nl = "\n\n"
- temp = 0
- for bit in info:
- saveFile.write(str(bit))
- if temp == 13:
- saveFile.write(nl)
- else:
- saveFile.write(dlm)
- temp += 1
- temp = 0
- for bit in health:
- saveFile.write(str(bit))
- if temp == 1:
- saveFile.write(nl)
- else:
- saveFile.write(dlm)
- temp += 1
- temp = 0
- for bit in experience:
- saveFile.write(str(bit))
- if temp == 2:
- saveFile.write(nl)
- else:
- saveFile.write(dlm)
- temp += 1
- temp = 0
- for bit in mainStats:
- saveFile.write(str(bit))
- if temp == 5:
- saveFile.write(nl)
- else:
- saveFile.write(dlm)
- temp += 1
- temp = 0
- for bit in bonusStats:
- saveFile.write(str(bit))
- if temp == 5:
- saveFile.write(nl)
- else:
- saveFile.write(dlm)
- temp += 1
- temp = 1
- for sk in skills:
- saveFile.write(str(sk[0]) + dlm + sk[1])
- if temp != len(skills):
- saveFile.write(adlm)
- temp += 1
- saveFile.write(nl)
- temp = 1
- for ab in abilities:
- saveFile.write(str(ab[0]) + dlm + ab[1] + dlm + ab[2])
- if temp != len(abilities):
- saveFile.write(adlm)
- temp += 1
- saveFile.write(nl)
- temp = 1
- for item in inventory:
- tempAux = 1
- for bit in item:
- saveFile.write(str(bit))
- if tempAux < 9:
- saveFile.write(dlm)
- tempAux += 1
- if temp != len(inventory):
- saveFile.write(adlm)
- temp += 1
- saveFile.close()
- mbx.showinfo("Save Character", "Saved!\nCheck the working directory of this program for the file.")
- def loadCharacter():
- loaded = False
- while not loaded:
- try:
- fileName = sdg.askstring("Load Character", "Enter the name of the file to load from:")
- if type(fileName) != str:
- return
- fileName += ".dat"
- loadFile = open(fileName, "r")
- loaded = True
- except FileNotFoundError:
- mbx.showerror("Error", "File not found!")
- dlm = " || "
- adlm = " |\n"
- nl = "\n\n"
- contents = loadFile.read().split(nl)
- tempCountA = 0
- try:
- for bit in contents:
- tempList = []
- if adlm in bit:
- tempList = bit.split(adlm)
- tempCountB = 0
- for item in tempList:
- tempList[tempCountB] = item.split(dlm)
- tempCountC = 0
- for el in tempList[tempCountB]:
- if el == "True":
- tempList[tempCountB][tempCountC] = True
- elif el == "False":
- tempList[tempCountB][tempCountC] = False
- else:
- try:
- tempList[tempCountB][tempCountC] = int(el)
- except ValueError:
- try:
- tempList[tempCountB][tempCountC] = float(el)
- except ValueError:
- pass
- tempCountC += 1
- tempCountB += 1
- elif dlm in bit:
- tempList = bit.split(dlm)
- tempCountB = 0
- for el in tempList:
- try:
- tempList[tempCountB] = int(el)
- except ValueError:
- try:
- tempList[tempCountB] = float(el)
- except ValueError:
- pass
- tempCountB += 1
- contents[tempCountA] = tempList
- tempCountA += 1
- except:
- mbx.showerror("Error", "Unable to Load File!")
- return
- tempCount = 0
- for bit in contents[0]:
- info[tempCount] = bit
- tempCount += 1
- tempCount = 0
- for bit in contents[1]:
- health[tempCount] = bit
- tempCount += 1
- tempCount = 0
- for bit in contents[2]:
- experience[tempCount] = bit
- tempCount += 1
- tempCount = 0
- for bit in contents[3]:
- mainStats[tempCount] = bit
- tempCount += 1
- tempCount = 0
- for bit in contents[4]:
- bonusStats[tempCount] = bit
- tempCount += 1
- while len(skills) > 0:
- del skills[0]
- for bit in contents[5]:
- skills.append(bit)
- while len(abilities) > 0:
- del abilities[0]
- for bit in contents[6]:
- abilities.append(bit)
- while len(inventory) > 0:
- del inventory[0]
- for bit in contents[7]:
- inventory.append(bit)
- mbx.showinfo("Load Character", "Loaded!\nYour journey continues...")
- refrSTAT()
- refrINFO()
- refrINVT()
- refrSKIL()
- refrABIL()
- mainStats = [0, 0, 0, 0, 0, 0]
- bonusStats = [0, 0, 0, 0, 0, 0]
- savingThrows = [0, 0, 0]
- health = [0, 10]
- experience = [1, 0, 110]
- info = ["name", "class", "deity", "race", "gender", 18, 170, "cm", 70, "kg", "brown", "black", "currency", 0]
- skills = []
- abilities = []
- inventory = []
- brackets5E = [0, 300, 900, 2700, 6500, 14000, 23000, 34000, 48000, 64000, 85000, 100000, 120000, 140000, 165000, 195000, 225000, 265000, 305000, 355000]
- base = tk.Tk()
- base.protocol("WM_DELETE_WINDOW", exitOverride)
- ftSmall = tkf.Font(family = "Consolas", size = 8)
- ftNormal = tkf.Font(family = "Consolas", size = 10)
- ftNormUnd = tkf.Font(family = "Consolas", size = 10, underline = 1)
- ftLarge = tkf.Font(family = "Consolas", size = 12)
- ftTitle = tkf.Font(family = "Consolas", size = 12, weight = "bold", slant = "italic")
- ftBigTitle = tkf.Font(family = "Consolas", size = 16, weight = "bold", slant = "italic")
- ftSubtitle = tkf.Font(family = "Consolas", size = 12, slant = "italic")
- ftDice = tkf.Font(family = "Consolas", size = 12, weight = "bold")
- STATPnl = tk.Frame(base, bd = 4, relief = "groove")
- STATPnl.grid(row = 1, column = 0, rowspan = 2, padx = 4, pady = 4, sticky = "n")
- STATTitl = tk.Label(STATPnl, text = "Stats", width = 8, bd = 4, relief = "raised", font = ftTitle)
- LEVLLbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
- LEVLVar = tk.BooleanVar()
- LEVLVar.set(False)
- LEVLChk = tk.Checkbutton(STATPnl, text = "5E", command = ChangeXP, variable = LEVLVar, font = ftNormal)
- XPLbl = tk.Label(STATPnl, width = 16, relief = "ridge", font = ftNormal)
- XPPlusBtn = tk.Button(STATPnl, text = "+", command = XPUp, cursor = "hand2", font = ftSmall)
- HPLbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
- HPPLUSBtn = tk.Button(STATPnl, text = "+", command = HPUp, cursor = "hand2", font = ftSmall)
- HPMINSBtn = tk.Button(STATPnl, text = "-", command = HPDown, cursor = "hand2", font = ftSmall)
- STRLbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
- DEXLbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
- CONLbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
- INTLbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
- WISLbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
- CHALbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
- STRBLbl = tk.Label(STATPnl, width = 4, relief = "ridge", font = ftNormal)
- DEXBLbl = tk.Label(STATPnl, width = 4, relief = "ridge", font = ftNormal)
- CONBLbl = tk.Label(STATPnl, width = 4, relief = "ridge", font = ftNormal)
- INTBLbl = tk.Label(STATPnl, width = 4, relief = "ridge", font = ftNormal)
- WISBLbl = tk.Label(STATPnl, width = 4, relief = "ridge", font = ftNormal)
- CHABLbl = tk.Label(STATPnl, width = 4, relief = "ridge", font = ftNormal)
- FORTLbl = tk.Label(STATPnl, width = 16, anchor = "e", relief = "ridge", font = ftNormal)
- REFLLbl = tk.Label(STATPnl, width = 16, anchor = "e", relief = "ridge", font = ftNormal)
- WILLLbl = tk.Label(STATPnl, width = 16, anchor = "e", relief = "ridge", font = ftNormal)
- STATEDITBtn = tk.Button(STATPnl, text = "Edit Stats", width = 10, command = editStat, cursor = "hand2", font = ftSmall)
- STATTitl.grid(row = 0, columnspan = 3, pady = 2)
- LEVLLbl.grid(row = 1, column = 0, columnspan = 3, pady = 2)
- XPLbl.grid(row = 2, column = 0, columnspan = 2, pady = 2)
- XPPlusBtn.grid(row = 2, column = 2)
- HPLbl.grid(row = 3, column = 0, pady = 2)
- HPPLUSBtn.grid(row = 3, column = 1)
- HPMINSBtn.grid(row = 3, column = 2, padx = 4)
- STRLbl.grid(row = 4, column = 0, padx = 4, pady = 2)
- DEXLbl.grid(row = 5, column = 0, padx = 4, pady = 2)
- CONLbl.grid(row = 6, column = 0, padx = 4, pady = 2)
- INTLbl.grid(row = 7, column = 0, padx = 4, pady = 2)
- WISLbl.grid(row = 8, column = 0, padx = 4, pady = 2)
- CHALbl.grid(row = 9, column = 0, padx = 4, pady = 2)
- STRBLbl.grid(row = 4, column = 1, columnspan = 2, padx = 4, pady = 2)
- DEXBLbl.grid(row = 5, column = 1, columnspan = 2, padx = 4, pady = 2)
- CONBLbl.grid(row = 6, column = 1, columnspan = 2, padx = 4, pady = 2)
- INTBLbl.grid(row = 7, column = 1, columnspan = 2, padx = 4, pady = 2)
- WISBLbl.grid(row = 8, column = 1, columnspan = 2, padx = 4, pady = 2)
- CHABLbl.grid(row = 9, column = 1, columnspan = 2, padx = 4, pady = 2)
- FORTLbl.grid(row = 10, columnspan = 3, padx = 4, pady = 2)
- REFLLbl.grid(row = 11, columnspan = 3, padx = 4, pady = 2)
- WILLLbl.grid(row = 12, columnspan = 3, padx = 4, pady = 2)
- STATEDITBtn.grid(row = 13, column = 0, padx = 4, pady = 2)
- LEVLChk.grid(row = 13, column = 1, columnspan = 2)
- refrSTAT()
- INFOPnl = tk.Frame(base, bd = 4, relief = "groove")
- INFOPnl.grid(row = 1, column = 1, padx = 4, pady = 4, sticky = "nw")
- INFOTitl = tk.Label(INFOPnl, text ="Information", width = 32, bd = 4, relief = "raised", font = ftTitle)
- INFOTitl.grid(row = 0, columnspan = 4, pady = 2)
- NAMELbl = tk.Label(INFOPnl, width = 48, bd = 4, relief = "ridge", font = ftLarge)
- CLSSLbl = tk.Label(INFOPnl, width = 24, relief = "ridge", font = ftLarge)
- DETYLbl = tk.Label(INFOPnl, width = 24, relief = "ridge", font = ftLarge)
- RACELbl = tk.Label(INFOPnl, width = 24, relief = "ridge", font = ftLarge)
- GNDRLbl = tk.Label(INFOPnl, width = 24, relief = "ridge", font = ftLarge)
- AYGELbl = tk.Label(INFOPnl, width = 8, relief = "ridge", font = ftLarge)
- HGHTLbl = tk.Label(INFOPnl, width = 8, relief = "ridge", font = ftLarge)
- WGHTLbl = tk.Label(INFOPnl, width = 8, relief = "ridge", font = ftLarge)
- INFOEDITBtn = tk.Button(INFOPnl, text = "Edit Info", width = 8, command = editInfo, cursor = "hand2", font = ftSmall)
- HAIRLbl = tk.Label(INFOPnl, width = 24, relief = "ridge", font = ftLarge)
- EYESLbl = tk.Label(INFOPnl, width = 24, relief = "ridge", font = ftLarge)
- MONYLbl = tk.Label(INFOPnl, width = 32, relief = "ridge", font = ftLarge)
- MONYCHNGBtn = tk.Button(INFOPnl, text = "Credit/Debit", width = 12, command = changeMoney, cursor = "hand2", font = ftSmall)
- NAMELbl.grid(row = 1, columnspan = 4, pady = 4)
- CLSSLbl.grid(row = 2, column = 0, columnspan = 2, pady = 4)
- DETYLbl.grid(row = 3, column = 0, columnspan = 2, pady = 4)
- RACELbl.grid(row = 2, column = 2, columnspan = 2, padx = 2)
- GNDRLbl.grid(row = 3, column = 2, columnspan = 2, padx = 2)
- AYGELbl.grid(row = 5, column = 0, pady = 4)
- HGHTLbl.grid(row = 5, column = 1)
- WGHTLbl.grid(row = 5, column = 2)
- INFOEDITBtn.grid(row = 5, column = 3)
- HAIRLbl.grid(row = 4, column = 0, columnspan = 2, pady = 4)
- EYESLbl.grid(row = 4, column = 2, columnspan = 2)
- MONYLbl.grid(row = 6, column = 0, columnspan = 3)
- MONYCHNGBtn.grid(row = 6, column = 3, pady = 11)
- refrINFO()
- INVTPnl = tk.Frame(base, bd = 4, relief = "groove")
- INVTPnl.grid(row = 2, column = 1, rowspan = 2, columnspan = 2, padx = 4, pady = 4, sticky = "w")
- INVTTitl = tk.Label(INVTPnl, text = "Inventory", width = 24, bd = 4, relief = "raised", font = ftTitle)
- INVTNEWWBtn = tk.Button(INVTPnl, text = "Create Item", width = 12, command = newItem, cursor = "hand2", font = ftSmall)
- INVTEDITBtn = tk.Button(INVTPnl, text = "Edit Item", width = 12, command = editItem, cursor = "hand2", font = ftSmall)
- INVTDELTBtn = tk.Button(INVTPnl, text = "Delete Item", width = 12, command = deleteItem, cursor = "hand2", font = ftSmall)
- INVTINSPBtn = tk.Button(INVTPnl, text = "Inspect Item", width = 12, command = inspectItem, cursor = "hand2", font = ftSmall)
- INVTSORTBtn = tk.Button(INVTPnl, text = "Sort Items", width = 12, command = sortItems, cursor = "hand2", font = ftSmall)
- INVTLbl = tk.Label(INVTPnl, text = "Name\t\t\t\t\tCount\tWeight\tDice\tCharges\tEquipped", font = ftNormUnd)
- INVTTxt = tk.Listbox(INVTPnl, height = 10, width = 80, cursor = "cross", font = ftNormal)
- IVNTScr = tk.Scrollbar(INVTPnl, orient = "vertical", command = INVTTxt.yview)
- INVTTxt.config(yscrollcommand = IVNTScr.set)
- INVTENCMLbl = tk.Label(INVTPnl, text = "Encumberance:", width = 24, anchor = "w", relief = "ridge", font = ftNormal)
- INVTTitl.grid(row = 0, column = 0, pady = 2)
- INVTNEWWBtn.grid(row = 0, column = 1)
- INVTEDITBtn.grid(row = 0, column = 2)
- INVTDELTBtn.grid(row = 1, column = 2, columnspan = 2)
- INVTINSPBtn.grid(row = 1, column = 1, columnspan = 2)
- INVTSORTBtn.grid(row = 0, column = 3)
- INVTLbl.grid(row = 2, columnspan = 4, sticky = "w")
- INVTTxt.grid(row = 3, column = 0, columnspan = 4)
- IVNTScr.grid(row = 2, column = 4, rowspan = 2, sticky = "ns")
- INVTENCMLbl.grid(row = 4, columnspan = 5, pady = 4, sticky = "e")
- refrINVT()
- DICEPnl = tk.Frame(base, bd = 4, relief = "groove")
- DICEPnl.grid(row = 3, column = 0, padx = 4, pady = 4, sticky = "s")
- DICETitl = tk.Label(DICEPnl, text = "Dice", width = 8, bd = 4, relief = "raised", font = ftTitle)
- DICELbl = tk.Label(DICEPnl, text = "0 | d?", width = 8, relief = "groove", font = ftDice)
- DICEd4Btn = tk.Button(DICEPnl, text = "d4", command = rollDice(4), cursor = "hand2", font = ftSmall)
- DICEd6Btn = tk.Button(DICEPnl, text = "d6", command = rollDice(6), cursor = "hand2", font = ftSmall)
- DICEd8Btn = tk.Button(DICEPnl, text = "d8", command = rollDice(8), cursor = "hand2", font = ftSmall)
- DICEd10Btn = tk.Button(DICEPnl, text = "d10", command = rollDice(10), cursor = "hand2", font = ftSmall)
- DICEd12Btn = tk.Button(DICEPnl, text = "d12", command = rollDice(12), cursor = "hand2", font = ftSmall)
- DICEd20Btn = tk.Button(DICEPnl, text = "d20", command = rollDice(20), cursor = "hand2", font = ftSmall)
- DICEd100Btn = tk.Button(DICEPnl, text = "d100", command = rollDice(100), cursor = "hand2", font = ftSmall)
- DICETitl.grid(row = 0, column = 0, columnspan = 3, pady = 2)
- DICELbl.grid(row = 1, column = 0, columnspan = 3, padx = 36, pady = 2)
- DICEd4Btn.grid(row = 2, column = 0, pady = 2)
- DICEd6Btn.grid(row = 2, column = 1, pady = 2)
- DICEd8Btn.grid(row = 2, column = 2, pady = 2)
- DICEd10Btn.grid(row = 3, column = 0, pady = 2)
- DICEd12Btn.grid(row = 3, column = 1, pady = 2)
- DICEd20Btn.grid(row = 3, column = 2, pady = 2)
- DICEd100Btn.grid(row = 4, column = 1, pady = 2)
- SKILPnl = tk.Frame(base, bd = 4, relief = "groove")
- SKILPnl.grid(row = 2, column = 3, rowspan = 2, padx = 4, pady = 4, sticky = "n")
- SKILTitl = tk.Label(SKILPnl, text = "Skills", width = 8, bd = 4, relief = "raised", font = ftTitle)
- SKILTxt = tk.Listbox(SKILPnl, height = 10, width = 32, cursor = "cross", font = ftNormal)
- SKILScrV = tk.Scrollbar(SKILPnl, orient = "vertical", command = SKILTxt.yview)
- SKILScrH = tk.Scrollbar(SKILPnl, orient = "horizontal", command = SKILTxt.xview)
- SKILTxt.config(yscrollcommand = SKILScrV.set, xscrollcommand = SKILScrH.set)
- SKILNEWWBtn = tk.Button(SKILPnl, text = "Create Skill", width = 12, command = newSkill, cursor = "hand2", font = ftSmall)
- SKILEDITBtn = tk.Button(SKILPnl, text = "Edit Skill", width = 12, command = editSkill, cursor = "hand2", font = ftSmall)
- SKILDELTBtn = tk.Button(SKILPnl, text = "Delete Skill", width = 12, command = deleteSkill, cursor = "hand2", font = ftSmall)
- SKILSORTBtn = tk.Button(SKILPnl, text = "Sort Skills", width = 12, command = sortSkills, cursor = "hand2", font = ftSmall)
- SKILTitl.grid(row = 0, columnspan = 3, pady = 2)
- SKILTxt.grid(row = 3, column = 0, columnspan = 2)
- SKILScrV.grid(row = 3, column = 2, rowspan = 2, sticky = "ns")
- SKILScrH.grid(row = 4, column = 0, columnspan = 2, sticky = "we")
- SKILNEWWBtn.grid(row = 1, column = 0, pady = 2)
- SKILEDITBtn.grid(row = 1, column = 1)
- SKILDELTBtn.grid(row = 2, column = 0, pady = 2)
- SKILSORTBtn.grid(row = 2, column = 1)
- refrSKIL()
- ABILPnl = tk.Frame(base, bd = 4, relief = "groove")
- ABILPnl.grid(row = 1, column = 2, columnspan = 2, padx = 4, pady = 4, sticky = "n")
- ABILTitl = tk.Label(ABILPnl, text = "Abilities", width = 16, bd = 4, relief = "raised", font = ftTitle)
- ABILTxt = tk.Listbox(ABILPnl, height = 10, width = 48, cursor = "cross", font = ftNormal)
- ABILScrV = tk.Scrollbar(ABILPnl, orient = "vertical", command = ABILTxt.yview)
- ABILScrH = tk.Scrollbar(ABILPnl, orient = "horizontal", command = ABILTxt.xview)
- ABILTxt.config(yscrollcommand = ABILScrV.set, xscrollcommand = ABILScrH.set)
- ABILNEWWBtn = tk.Button(ABILPnl, text = "Create Ability", width = 16, command = newAbility, cursor = "hand2", font = ftSmall)
- ABILEDITBtn = tk.Button(ABILPnl, text = "Edit Ability", width = 16, command = editAbility, cursor = "hand2", font = ftSmall)
- ABILDELTBtn = tk.Button(ABILPnl, text = "Delete Ability", width = 16, command = deleteAbility, cursor = "hand2", font = ftSmall)
- ABILINSPBtn = tk.Button(ABILPnl, text = "Inspect Ability", width = 16, command = inspectAbility, cursor = "hand2", font = ftSmall)
- ABILSORTBtn = tk.Button(ABILPnl, text = "Sort Abilities", width = 16, command = sortAbilities, cursor = "hand2", font = ftSmall)
- ABILTitl.grid(row = 0, columnspan = 4)
- ABILTxt.grid(row = 3, column = 0, columnspan = 3)
- ABILScrV.grid(row = 3, column = 3, rowspan = 2, sticky = "ns")
- ABILScrH.grid(row = 4, columnspan = 3, sticky = "we")
- ABILNEWWBtn.grid(row = 1, column = 0, pady = 2)
- ABILEDITBtn.grid(row = 1, column = 1)
- ABILDELTBtn.grid(row = 2, column = 1, columnspan = 2, pady = 2)
- ABILINSPBtn.grid(row = 2, column = 0, columnspan = 2)
- ABILSORTBtn.grid(row = 1, column = 2, columnspan = 2, padx = 8)
- MENUPnl = tk.Frame(base, bd = 4, relief = "groove")
- MENUPnl.grid(row = 0, columnspan = 4, pady = 4)
- MENUTitl = tk.Label(MENUPnl, text = "C²'s D&D Character Sheet", width = 64, bd = 4, relief = "raised", font = ftBigTitle)
- MENUNEWWBtn = tk.Button(MENUPnl, text = "New Character", width = 16, command = newCharacter, cursor = "hand2", font = ftLarge)
- MENUSAVEBtn = tk.Button(MENUPnl, text = "Save Character", width = 16, command = saveCharacter, cursor = "hand2", font = ftLarge)
- MENULOADBtn = tk.Button(MENUPnl, text = "Load Character", width = 16, command = loadCharacter, cursor = "hand2", font = ftLarge)
- MENUVERS = tk.Label(MENUPnl, text = "Version 1.1", width = 16, bd = 4, relief = "ridge", font = ftSubtitle)
- MENUTitl.grid(row = 0, columnspan = 4, padx = 16, pady = 4)
- MENUNEWWBtn.grid(row = 1, column = 0, pady = 4)
- MENUSAVEBtn.grid(row = 1, column = 1)
- MENULOADBtn.grid(row = 1, column = 2)
- MENUVERS.grid(row = 1, column = 3)
- base.title("DnD Character Sheet")
- base.resizable(False, False)
- base.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment