cookchar

DnD Character Sheet v1.2.2

Jan 15th, 2018
50
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import tkinter as tk
  2. import tkinter.simpledialog as sdg
  3. import tkinter.messagebox as mbx
  4. import tkinter.font as tkf
  5. import tkinter.tix as tix
  6. import random as rnd
  7. import operator as op
  8. import os
  9.  
  10. #Charlie Cook's Dungeons & Dragons Character Sheet Program
  11. #Begun early June 2017
  12. #Last updated mid January 2018
  13.  
  14. #Gets the DEX, STR, and INT scores to set the Reflex, Fortitude, and Will saving throw scores
  15. #Now accommodates for when Ability Scores are changed between base and racial/class bonus mode
  16. def updtSAVETHRW(regularMode = True, altMS = [], alsBS = []):
  17.     if regularMode:
  18.         savingThrows[0] = mainStats[2] + bonusStats[2]
  19.         savingThrows[1] = mainStats[1] + bonusStats[1]
  20.         savingThrows[2] = mainStats[4] + bonusStats[4]
  21.     else:
  22.         savingThrows[0] = altMS[2] + alsBS[2]
  23.         savingThrows[1] = altMS[1] + alsBS[1]
  24.         savingThrows[2] = altMS[4] + alsBS[4]
  25. #Increments the level of the player and checks to see if 5E players are overleveled
  26. #The level, current XP, and required XP are recorded in the experience list in the afore-noted order
  27. def levelUp():
  28.     showMessage = True
  29.     experience[0] += 1
  30.     if LEVLVar.get():
  31.         if experience[0] == 20:
  32.                 mbx.showinfo("Level Up!", "You have reached the maximum level allowed in 5E! Well played!")
  33.                 experience[2] = 999999
  34.         elif experience[0] > 20:
  35.                 mbx.showinfo("Level Up?", "You really should make a new character by now, 5E isn't meant to work with this much XP. To prevent errors, your current XP will be modulated to a six-digit number.")
  36.                 experience[1] = experience[1] % 999999
  37.                 experience[0] -= 1
  38.                 showMessage = False
  39.         else:
  40.             experience[2] = brackets5E[experience[0]]
  41.     else:
  42.         experience[2] += 100 + 10 * experience[0]
  43.  
  44.     if showMessage:
  45.         mbx.showinfo("Level Up!","Congratulations!\nYou are now Level " + str(experience[0]))
  46. #Refreshes the information in the Stats frame
  47. #Now accommodates for when Ability Scores are changed between base and racial/class bonus mode
  48. def refrSTAT(regularMode = True, altMS = [], altBS = []):
  49.     LEVLLbl.config(text = "Level: " + str(experience[0]))
  50.     HPLbl.config(text = "HP:" + str(health[0]) + "/" + str(health[1]))
  51.     XPLbl.config(text = "XP:" + str(experience[1]) + "/" + str(experience[2]))
  52.  
  53.     if regularMode:
  54.         STRLbl.config(text = "STR: " + str(mainStats[0]))
  55.         DEXLbl.config(text = "DEX: " + str(mainStats[1]))
  56.         CONLbl.config(text = "CON: " + str(mainStats[2]))
  57.         INTLbl.config(text = "INT: " + str(mainStats[3]))
  58.         WISLbl.config(text = "WIS: " + str(mainStats[4]))
  59.         CHALbl.config(text = "CHA: " + str(mainStats[5]))
  60.  
  61.         if bonusStats[0] > 0:
  62.             STRBLbl.config(text = "+" + str(bonusStats[0]))
  63.         else:
  64.             STRBLbl.config(text = str(bonusStats[0]))
  65.  
  66.         if bonusStats[1] > 0:
  67.             DEXBLbl.config(text = "+" + str(bonusStats[1]))
  68.         else:
  69.             DEXBLbl.config(text = str(bonusStats[1]))
  70.  
  71.         if bonusStats[2] > 0:
  72.             CONBLbl.config(text = "+" + str(bonusStats[2]))
  73.         else:
  74.             CONBLbl.config(text = str(bonusStats[2]))
  75.  
  76.         if bonusStats[3] > 0:
  77.             INTBLbl.config(text = "+" + str(bonusStats[3]))
  78.         else:
  79.             INTBLbl.config(text = str(bonusStats[3]))
  80.  
  81.         if bonusStats[4] > 0:
  82.             WISBLbl.config(text = "+" + str(bonusStats[4]))
  83.         else:
  84.             WISBLbl.config(text = str(bonusStats[4]))
  85.  
  86.         if bonusStats[5] > 0:
  87.             CHABLbl.config(text = "+" + str(bonusStats[5]))
  88.         else:
  89.             CHABLbl.config(text = str(bonusStats[5]))
  90.  
  91.         updtSAVETHRW()
  92.     else:
  93.         STRLbl.config(text = "STR: " + str(altMS[0]))
  94.         DEXLbl.config(text = "DEX: " + str(altMS[1]))
  95.         CONLbl.config(text = "CON: " + str(altMS[2]))
  96.         INTLbl.config(text = "INT: " + str(altMS[3]))
  97.         WISLbl.config(text = "WIS: " + str(altMS[4]))
  98.         CHALbl.config(text = "CHA: " + str(altMS[5]))
  99.  
  100.         if altBS[0] > 0:
  101.             STRBLbl.config(text = "+" + str(altBS[0]))
  102.         else:
  103.             STRBLbl.config(text = str(altBS[0]))
  104.  
  105.         if altBS[1] > 0:
  106.             DEXBLbl.config(text = "+" + str(altBS[1]))
  107.         else:
  108.             DEXBLbl.config(text = str(altBS[1]))
  109.  
  110.         if altBS[2] > 0:
  111.             CONBLbl.config(text = "+" + str(altBS[2]))
  112.         else:
  113.             CONBLbl.config(text = str(altBS[2]))
  114.  
  115.         if altBS[3] > 0:
  116.             INTBLbl.config(text = "+" + str(altBS[3]))
  117.         else:
  118.             INTBLbl.config(text = str(altBS[3]))
  119.  
  120.         if altBS[4] > 0:
  121.             WISBLbl.config(text = "+" + str(altBS[4]))
  122.         else:
  123.             WISBLbl.config(text = str(altBS[4]))
  124.  
  125.         if altBS[5] > 0:
  126.             CHABLbl.config(text = "+" + str(altBS[5]))
  127.         else:
  128.             CHABLbl.config(text = str(altBS[5]))
  129.  
  130.         updtSAVETHRW(False, altMS, altBS)
  131.  
  132.     FORTLbl.config(text = "Fortitude: " + str(savingThrows[0]))
  133.     REFLLbl.config(text = "Reflex: " + str(savingThrows[1]))
  134.     WILLLbl.config(text = "Will: " + str(savingThrows[2]))
  135. #Increments the current HP if possible
  136. def HPUp():
  137.     if health[0] < health[1]:
  138.         health[0] += 1
  139.         refrSTAT()
  140. #Decrements the current HP if possible
  141. def HPDown():
  142.     if health[0] > -10:
  143.         health[0] -= 1
  144.         refrSTAT()
  145. #Increments the current XP and levels up if necessary
  146. def XPUp():
  147.     temp = sdg.askinteger("Add XP", "Enter how many experience points you've earned:")
  148.     if type(temp) == int:
  149.         experience[1] += temp
  150.  
  151.     while experience[1] >= experience[2]:
  152.         levelUp()
  153.         refrSTAT()
  154.  
  155.     refrSTAT()
  156. #Changes the leveling requirements between 5E and the 100 + 10 * Current Level formula and re-levels the player
  157. def ChangeXP():
  158.     if mbx.askokcancel("Warning!", "Changing the level up brackets may make things weird. Is it okay to continue?"):
  159.         if LEVLVar.get():
  160.             experience[0] = 1
  161.             experience[2] = brackets5E[1]
  162.  
  163.         else:
  164.             experience[0] = 1
  165.             experience[2] = 110
  166.  
  167.         while experience[1] >= experience[2]:
  168.             levelUp()
  169.             refrSTAT()
  170.     #The below else condition is present because the checkbox that invokes this function
  171.     #will change regardless of the yes or no in the above message box, thus it must be reset if no is selected
  172.     else:
  173.         LEVLVar.set(not LEVLVar.get())
  174. #Root dialog for editing stats
  175. class editStatRoot(sdg.Dialog):
  176.     def body(self, master):
  177.         self.title("Edit Stats")
  178.         self.resizable(False, False)
  179.         self.choice = tk.IntVar()
  180.         self.choice.set(1)
  181.         tk.Label(master, text = "Choose a stat item to edit:", font = ftNormal).grid(row = 0)
  182.        
  183.         STR = tk.Radiobutton(master, text = "Strength", value = 1, variable = self.choice, cursor = "hand2", font = ftNormal)
  184.         DEX = tk.Radiobutton(master, text = "Dexterity", value = 2, variable = self.choice, cursor = "hand2", font = ftNormal)
  185.         CON = tk.Radiobutton(master, text = "Constitution", value = 3, variable = self.choice, cursor = "hand2", font = ftNormal)
  186.         INT = tk.Radiobutton(master, text = "Intelligence", value = 4, variable = self.choice, cursor = "hand2", font = ftNormal)
  187.         WIS = tk.Radiobutton(master, text = "Wisdom", value = 5, variable = self.choice, cursor = "hand2", font = ftNormal)
  188.         CHA = tk.Radiobutton(master, text = "Charisma", value = 6, variable = self.choice, cursor = "hand2", font = ftNormal)
  189.  
  190.         LEV = tk.Radiobutton(master, text = "Level", value = 7, variable = self.choice, cursor = "hand2", font = ftNormal)
  191.         XP = tk.Radiobutton(master, text = "Experience", value = 8, variable = self.choice, cursor = "hand2", font = ftNormal)
  192.         HPC = tk.Radiobutton(master, text = "Current Health", value = 9, variable = self.choice, cursor = "hand2", font = ftNormal)
  193.         HPM = tk.Radiobutton(master, text = "Maximum Health", value = 10, variable = self.choice, cursor = "hand2", font = ftNormal)
  194.  
  195.         STR.grid(row = 5, sticky = "w")
  196.         DEX.grid(row = 6, sticky = "w")
  197.         CON.grid(row = 7, sticky = "w")
  198.         INT.grid(row = 8, sticky = "w")
  199.         WIS.grid(row = 9, sticky = "w")
  200.         CHA.grid(row = 10, sticky = "w")
  201.  
  202.         LEV.grid(row = 1, sticky = "w")
  203.         XP.grid(row = 2, sticky = "w")
  204.         HPC.grid(row = 3, sticky = "w")
  205.         HPM.grid(row = 4, sticky = "w")
  206.  
  207.     def apply(self):
  208.         self.result = self.choice.get()
  209. #Leaf dialog for editing attribute stats
  210. class editStatLeaf(sdg.Dialog):
  211.     def __init__(self, master = None, m = 0):
  212.         self.mode = m - 1
  213.         super().__init__(master)
  214.  
  215.     def body(self, master):
  216.         choices = ["Strength", "Dexterity", "Constitution", "Intelligence", "Wisdom", "Charisma"]
  217.         self.title("Edit " + choices[self.mode])
  218.         self.resizable(False, False)
  219.         tk.Label(master, text = "Enter your new " + choices[self.mode] + ":", font = ftNormal).grid(row = 0)
  220.  
  221.         self.Value = tk.Entry(master, font = ftNormal)
  222.  
  223.         self.Value.insert(0, mainStats[self.mode])
  224.  
  225.         self.Value.grid(row = 1)
  226.  
  227.     def apply(self):
  228.         try:
  229.             temp = []
  230.  
  231.             if len(self.Value.get()) > 0:
  232.                 temp.append(int(self.Value.get()))
  233.             else:
  234.                 temp.append("")
  235.  
  236.             temp.append((int(self.Value.get()) - 10) // 2)
  237.  
  238.             self.result = temp
  239.  
  240.         except:
  241.             mbx.showerror("Error","Invalid Input")
  242.             self.result = []
  243. #Edits attributes, health, level, and XP
  244. def editStat():
  245.     choice = editStatRoot(base).result
  246.  
  247.     if type(choice) == int:
  248.         if choice < 7:
  249.             temp = editStatLeaf(base, choice).result
  250.  
  251.         elif choice == 7:
  252.             temp = sdg.askinteger("Edit Level", "[Warning! This will change your XP!]\nEnter your new level:", initialvalue = experience[0])
  253.             if type(temp) == int and temp > 0:
  254.                 experience[0] = temp
  255.                 if LEVLVar.get():
  256.                     if experience[0] > 20:
  257.                         mbx.showinfo("Warning!", "When using the 5E level up brackets, you cannot have a level greater than 20. To prevent errors, your entered level will now be modulated to a number from 1 to 20.")
  258.                         experience[0] = experience[0] % 20
  259.  
  260.                     if experience[0] == 20:
  261.                         experience[2] = 999999
  262.                     else:
  263.                         experience[2] = brackets5E[experience[0]]
  264.                     experience[1] = brackets5E[experience[0] - 1]
  265.                 else:
  266.                     experience[2] = 0
  267.                     for i in range(1, experience[0] + 1):
  268.                         experience[2] += 100 + 10 * i
  269.  
  270.                     experience[1] = experience[2] - (100 + 10 * experience[0])
  271.  
  272.             elif type(temp) == int and temp <= 0:
  273.                 mbx.showerror("Error", "You can't have a negative level!")
  274.  
  275.         elif choice == 8:
  276.             temp = sdg.askinteger("Edit Experience", "[Warning! This will change your level!]\nEnter your new current experience points:", initialvalue = experience[1])
  277.             if type(temp) == int and temp > 0:
  278.                 experience[1] = temp
  279.                 experience[0] = 1
  280.  
  281.                 if LEVLVar.get():
  282.                     experience[2] = 300
  283.                 else:
  284.                     experience[2] = 110
  285.  
  286.                 while experience[1] >= experience[2]:
  287.                     levelUp()
  288.                     refrSTAT()
  289.             elif type(temp) == int and temp < 0:
  290.                 mbx.showerror("Error", "You can't have negative experience points!")
  291.  
  292.         elif choice == 9:
  293.             temp = health[1] + 1
  294.  
  295.             while temp > health[1]:
  296.                 temp = sdg.askinteger("Edit Health", "Enter your new current health:", initialvalue = health[0])
  297.                 if type(temp) != int:
  298.                     return
  299.                 elif temp > health[1]:
  300.                     mbx.showerror("Error", "You can't overcharge your health!")
  301.  
  302.             if type(temp) == int and temp >= -10:
  303.                 health[0] = temp
  304.             elif type(temp) == int and temp < -10:
  305.                 mbx.showerror("Error", "You can't have your health drop below -10, you'd be dead then!")
  306.  
  307.         elif choice == 10:
  308.             temp = sdg.askinteger("Edit Health", "Enter your new maximum health:", initialvalue = health[1])
  309.             if type(temp) == int and temp > 0:
  310.                 health[1] = temp
  311.                 if health[0] > health[1]:
  312.                     health[0] = health[1]
  313.             elif type(temp) == int and temp <= 0:
  314.                 mbx.showerror("Error", "You can't have a negative maximum health!")
  315.  
  316.         if type(temp) == list:
  317.             if type(temp[0]) == int:
  318.                 mainStats[choice - 1] = temp[0]
  319.  
  320.             if type(temp[1]) == int:
  321.                 bonusStats[choice - 1] = temp[1]
  322.  
  323.             if SKILSCORVar.get():
  324.                 changeScores()
  325.             else:
  326.                 refrSTAT()
  327.  
  328.         elif type(temp) == int:
  329.             refrSTAT()
  330. #Refreshes the information frame
  331. def refrINFO():
  332.     NAMELbl.config(text = info[0])
  333.     CLSSLbl.config(text = "Class: " + info[1])
  334.     DETYLbl.config(text = "Deity: " + info[2])
  335.     RACELbl.config(text = "Race: " + info[3])
  336.     GNDRLbl.config(text = "Gender: " + info[4])
  337.     AYGELbl.config(text = "Age: " + str(info[5]))
  338.     HGHTLbl.config(text = str(info[6]) + " " + info[7])
  339.     WGHTLbl.config(text = str(info[8]) + " " + info[9])
  340.     HAIRLbl.config(text = "Hair: " + info[10])
  341.     EYESLbl.config(text = "Eyes: " + info[11])
  342.     MONYLbl.config(text = str(info[13]) + " " + info[12])
  343. #Changes the amount of money
  344. def changeMoney():
  345.     debit = sdg.askinteger("Change Money", "How much money to add/remove?")
  346.     if type(debit) == int:
  347.         info[13] += debit
  348.         refrINFO()
  349. #Root dialog for editing information
  350. class editInfoRoot(sdg.Dialog):
  351.     def body(self, master):
  352.         self.title("Edit Info")
  353.         self.resizable(False, False)
  354.         self.choice = tk.IntVar()
  355.         self.choice.set(1)
  356.         tk.Label(master, text = "Choose an info item to edit:", font = ftNormal).grid(row = 0)
  357.        
  358.         Name = tk.Radiobutton(master, text = "Name", value = 1, variable = self.choice, cursor = "hand2", font = ftNormal)
  359.         Class = tk.Radiobutton(master, text = "Class", value = 2, variable = self.choice, cursor = "hand2", font = ftNormal)
  360.         Deity = tk.Radiobutton(master, text = "Deity", value = 3, variable = self.choice, cursor = "hand2", font = ftNormal)
  361.         Race = tk.Radiobutton(master, text = "Race", value = 4, variable = self.choice, cursor = "hand2", font = ftNormal)
  362.         Gender = tk.Radiobutton(master, text = "Gender", value = 5, variable = self.choice, cursor = "hand2", font = ftNormal)
  363.         Age = tk.Radiobutton(master, text = "Age", value = 6, variable = self.choice, cursor = "hand2", font = ftNormal)
  364.         Height = tk.Radiobutton(master, text = "Height", value = 7, variable = self.choice, cursor = "hand2", font = ftNormal)
  365.         Weight = tk.Radiobutton(master, text = "Weight", value = 8, variable = self.choice, cursor = "hand2", font = ftNormal)
  366.         HairColor = tk.Radiobutton(master, text = "Hair Color", value = 9, variable = self.choice, cursor = "hand2", font = ftNormal)
  367.         EyeColor = tk.Radiobutton(master, text = "Eye Color", value = 10, variable = self.choice, cursor = "hand2", font = ftNormal)
  368.         Currency = tk.Radiobutton(master, text = "Currency", value = 11, variable = self.choice, cursor = "hand2", font = ftNormal)
  369.  
  370.         Name.grid(row = 1, sticky = "w")
  371.         Class.grid(row = 2, sticky = "w")
  372.         Deity.grid(row = 3, sticky = "w")
  373.         Race.grid(row = 4, sticky = "w")
  374.         Gender.grid(row = 5, sticky = "w")
  375.         Age.grid(row = 6, sticky = "w")
  376.         Height.grid(row = 7, sticky = "w")
  377.         Weight.grid(row = 8, sticky = "w")
  378.         HairColor.grid(row = 9, sticky = "w")
  379.         EyeColor.grid(row = 10, sticky = "w")
  380.         Currency.grid(row = 11, sticky = "w")
  381.  
  382.     def apply(self):
  383.         self.result = self.choice.get()
  384. #Dialog for editing height and/or weight
  385. class editWH(sdg.Dialog):
  386.     def __init__(self, master = None, m = 9):
  387.         self.mode = m - 7
  388.         super().__init__(master)
  389.  
  390.     def toggleUnit(self):
  391.         if self.ChangeUnit.get() == 1:
  392.             self.Unit.config(state = "normal")
  393.         else:
  394.             self.Unit.config(state = "disabled")
  395.  
  396.     def body(self, master):
  397.         choices = ["height", "weight"]
  398.         self.title("Edit " + choices[self.mode].title())
  399.         self.resizable(False, False)
  400.         self.ChangeUnit = tk.IntVar()
  401.         self.ChangeUnit.set(0)
  402.         tk.Label(master, text = "Enter your new " + choices[self.mode] + ":", font = ftNormal).grid(row = 0)
  403.  
  404.         self.Value = tk.Entry(master, font = ftNormal)
  405.         self.Unit = tk.Entry(master, font = ftNormal)
  406.  
  407.         if self.mode == 0:
  408.             self.Value.insert(0, info[6])
  409.             self.Unit.insert(0, info[7])
  410.         elif self.mode == 1:
  411.             self.Value.insert(0, info[8])
  412.             self.Unit.insert(0, info[9])
  413.  
  414.         self.Unit.config(state = "disabled")
  415.  
  416.         ChangeUnitChk = tk.Checkbutton(master, text = "Check to change unit", variable = self.ChangeUnit, command = self.toggleUnit, font = ftNormal)
  417.  
  418.         self.Value.grid(row = 1)
  419.         self.Unit.grid(row = 3)
  420.         ChangeUnitChk.grid(row = 2)
  421.  
  422.     def apply(self):
  423.         try:
  424.             self.result = [int(self.Value.get()), self.Unit.get(), self.ChangeUnit.get()]
  425.         except:
  426.             mbx.showerror("Error","Invalid Measurement")
  427.             self.result = []
  428. #Wrapper function (?) for editing information
  429. def editInfo():
  430.     editInfoSelect(editInfoRoot(base).result)
  431.     refrINFO()
  432. #Function for editing information
  433. def editInfoSelect(choice):
  434.     if choice in range(1, 7) or choice in range(9, 12):
  435.         if choice < 8:
  436.             index = choice - 1
  437.         else:
  438.             index = choice + 1
  439.  
  440.         choices = ["", "name", "class", "deity", "race", "gender", "age", "", "", "hair color", "eye color", "currency"]
  441.        
  442.         if choice == 6:
  443.             temp = sdg.askinteger("Edit " + choices[choice].title(), "Enter your new " + choices[choice], initialvalue = info[index])
  444.    
  445.             if type(temp) == int:
  446.                 info[index] = temp
  447.  
  448.         elif choice != 6:
  449.             temp = sdg.askstring("Edit " + choices[choice].title(), "Enter your new " + choices[choice], initialvalue = info[index])
  450.    
  451.             if type(temp) == str:
  452.                 info[index] = temp
  453.  
  454.     elif choice in range(7, 9):
  455.         n = choice
  456.         if n < 8:
  457.             n -= 1
  458.  
  459.         temp = editWH(base, choice).result
  460.  
  461.         if type(temp) == list and len(temp) > 0:
  462.             info[n] = temp[0]
  463.             if temp[2] == 1:
  464.                 info[n + 1] = temp[1]
  465. #Refreshes the inventory frame
  466. def refrINVT():
  467.     INVTTxt.delete(0, INVTTxt.size())
  468.  
  469.     tempWGHT = 0.0
  470.  
  471.     for item in inventory:
  472.  
  473.         tempWGHT += round(item[2] * item[3], 4)
  474.  
  475.         tempStr = ""
  476.         tempStr += item[0][:36]
  477.         if len(item[0]) > 36:
  478.             tempStr += "... "
  479.         else:
  480.             tempStr += (40 - len(item[0])) * " "
  481.  
  482.         tempStr += str(item[2])
  483.         tempStr += (8 - len(str(item[2]))) * " "
  484.         tempStr += str(item[3])
  485.         tempStr += (8 - len(str(item[3]))) * " "
  486.  
  487.         if item[4] != 0 and item[5]:
  488.             tempStr += "d" + str(item[4]) + " x" + str(item[5])
  489.             tempStr += (8 - len("d" + str(item[4]) + " x" + str(item[5]))) * " "
  490.         else:
  491.             tempStr += 8 * " "
  492.        
  493.         if item[7] != 0:
  494.             tempStr += str(item[6]) + "/" + str(item[7])
  495.             tempStr += (8 - len(str(item[6]) + "/" + str(item[7]))) * " "
  496.         else:
  497.             tempStr += 8 * " "
  498.  
  499.         if item[8]:
  500.             tempStr += "Yes"
  501.         else:
  502.             tempStr += "No"
  503.  
  504.         INVTTxt.insert("end", tempStr)
  505.  
  506.     INVTENCMLbl.config(text = "Encumberance: " + str(tempWGHT))
  507. #Creates a new item
  508. def newItem():
  509.     tempItem = []
  510.     tempStr = ""
  511.  
  512.     try:
  513.         while len(tempStr) == 0:
  514.             tempStr = sdg.askstring("New Item", "Enter the new item's name:")
  515.             if len(tempStr) == 0:
  516.                 mbx.showerror("Error", "You must name your item!")
  517.  
  518.         tempItem.append(tempStr)
  519.  
  520.         tempStr = sdg.askstring("New Item", "[Optional] Enter the new item's bonus(es) or description:")
  521.         tempItem.append(tempStr)
  522.  
  523.         tempItem.append(sdg.askinteger("New Item", "Enter how many of the new item you have:", initialvalue = 1))
  524.         tempItem.append(sdg.askfloat("New Item", "Enter the weight of the item:", initialvalue = 0.0))
  525.         tempItem.append(sdg.askinteger("New Item", "[Optional] Enter the type of dice the item uses:", initialvalue = 0))
  526.         tempItem.append(sdg.askinteger("New Item", "[Optional] Enter the amount of dice rolls for the item:", initialvalue = 0))
  527.        
  528.         tempItem.append(sdg.askinteger("New Item", "[Optional] Enter the maximum magical charges the item has:", initialvalue = 0))
  529.         tempInt = tempItem[6] + 1
  530.         while tempInt > tempItem[6]:
  531.             tempInt = sdg.askinteger("New Item", "[Optional] Enter the current magical charges the item has:", initialvalue = 0)
  532.             if tempInt > tempItem[6]:
  533.                 mbx.showerror("Error", "You can't overcharge your item!")
  534.         tempItem.insert(6, tempInt)
  535.                
  536.         tempItem.append(mbx.askyesno("New Item", "Is the item equipped?"))
  537.  
  538.         inventory.append(tempItem)
  539.         refrINVT()
  540.  
  541.     except TypeError:
  542.         pass
  543. #Root dialog for editing items
  544. class editItemRoot(sdg.Dialog):
  545.     def __init__(self, master = None, i = ""):
  546.         self.item = i
  547.         super().__init__(master)
  548.  
  549.     def body(self, master):
  550.         self.title("Edit " + self.item)
  551.         self.resizable(False, False)
  552.         self.choice = tk.IntVar()
  553.         self.choice.set(0)
  554.         tk.Label(master, text = "Choose an item attribute to edit:", font = ftNormal).grid(row = 0)
  555.  
  556.         Name = tk.Radiobutton(master, text = "Name", value = 0, variable = self.choice, cursor = "hand2", font = ftNormal)
  557.         Bonus = tk.Radiobutton(master, text = "Bonus(es)", value = 1, variable = self.choice, cursor = "hand2", font = ftNormal)
  558.         Count = tk.Radiobutton(master, text = "Count", value = 2, variable = self.choice, cursor = "hand2", font = ftNormal)
  559.         Weight = tk.Radiobutton(master, text = "Weight", value = 3, variable = self.choice, cursor = "hand2", font = ftNormal)
  560.         dType = tk.Radiobutton(master, text = "Dice Type", value = 4, variable = self.choice, cursor = "hand2", font = ftNormal)
  561.         dCount = tk.Radiobutton(master, text = "Dice Count", value = 5, variable = self.choice, cursor = "hand2", font = ftNormal)
  562.         Charges = tk.Radiobutton(master, text = "Charges", value = 6, variable = self.choice, cursor = "hand2", font = ftNormal)
  563.         MaxCharges = tk.Radiobutton(master, text = "Max Charges", value = 7, variable = self.choice, cursor = "hand2", font = ftNormal)
  564.         Equipped = tk.Radiobutton(master, text = "Equipped", value = 8, variable = self.choice, cursor = "hand2", font = ftNormal)
  565.  
  566.         Name.grid(row = 1, sticky = "w")
  567.         Bonus.grid(row = 2, sticky = "w")
  568.         Count.grid(row = 3, sticky = "w")
  569.         Weight.grid(row = 4, sticky = "w")
  570.         dType.grid(row = 5, sticky = "w")
  571.         dCount.grid(row = 6, sticky = "w")
  572.         Charges.grid(row = 7, sticky = "w")
  573.         MaxCharges.grid(row = 8, sticky = "w")
  574.         Equipped.grid(row = 9, sticky = "w")
  575.  
  576.     def apply(self):
  577.         self.result = self.choice.get()
  578. #Changes edited item attributes
  579. def editItem():
  580.     try:
  581.         index = INVTTxt.curselection()[0]
  582.         item = inventory[index]
  583.         attr = editItemRoot(base, item[0]).result
  584.  
  585.         if type(attr) == int:
  586.             choices = ["Name", "Bonus(es)", "Count", "Weight", "Dice Type", "Dice Count", "Charges", "Max Charges", ""]
  587.             title = "Edit " + item[0]
  588.             prompt = "Enter the item's new " + choices[attr] + ":"
  589.  
  590.             if attr < 2:
  591.                 temp = sdg.askstring(title, prompt, initialvalue = item[attr])
  592.  
  593.                 if type(temp) == str and len(temp) > 0 and temp != item[attr]:
  594.                     inventory[index][attr] = temp
  595.  
  596.             elif attr < 6 and attr != 3:
  597.                 temp = sdg.askinteger(title, prompt, initialvalue = item[attr])
  598.  
  599.                 if type(temp) == int and temp != item[attr]:
  600.                     inventory[index][attr] = temp
  601.  
  602.             elif attr == 3:
  603.                 temp = sdg.askfloat(title, prompt, initialvalue = item[attr])
  604.  
  605.                 if type(temp) == float and temp != item[attr]:
  606.                     inventory[index][attr] = temp
  607.  
  608.             elif attr == 6:
  609.                 temp = item[7] + 1
  610.                 while type(temp) == int and temp > item[7]:
  611.                     temp = sdg.askinteger(title, prompt, initialvalue = item[attr])
  612.                    
  613.                     if type(temp) == int and temp > item[7]:
  614.                         mbx.showerror("Error", "You can't overcharge your item!")
  615.  
  616.                 if type(temp) == int and temp != item[attr]:
  617.                     inventory[index][attr] = temp
  618.  
  619.             elif attr == 7:
  620.                 temp = sdg.askinteger(title, prompt, initialvalue = item[attr])
  621.  
  622.                 if type(temp) == int and temp != item[attr]:
  623.                     if temp < item[6]:
  624.                         inventory[index][6] = temp
  625.  
  626.                     inventory[index][attr] = temp
  627.  
  628.             else:
  629.                 inventory[index][attr] =  not inventory[index][attr]
  630.  
  631.             refrINVT()
  632.  
  633.     except IndexError:
  634.         mbx.showerror("Error", "No item selected!")
  635. #Shows an item's bonus(es) or description
  636. def inspectItem():
  637.     try:
  638.         if len(inventory[INVTTxt.curselection()[0]][1]) > 0:
  639.             mbx.showinfo("Item: " + inventory[INVTTxt.curselection()[0]][0], "Bonus:\n" + inventory[INVTTxt.curselection()[0]][1])
  640.         else:
  641.             mbx.showinfo("Item: " + inventory[INVTTxt.curselection()[0]][0], "Bonus:\n[None]")
  642.  
  643.     except IndexError:
  644.         mbx.showerror("Error", "No item selected!")
  645. #Deletes an item
  646. def deleteItem():
  647.     try:
  648.         if mbx.askyesno("Delete Item: " + inventory[INVTTxt.curselection()[0]][0], "Are you sure you want to delete this item?"):
  649.             del inventory[INVTTxt.curselection()[0]]
  650.             refrINVT()
  651.  
  652.     except IndexError:
  653.         mbx.showerror("Error", "No item selected!")
  654. #Root dialog for sorting items
  655. class sortItemsRoot(sdg.Dialog):
  656.     def body(self, master):
  657.         self.title("Sort Items")
  658.         self.resizable(False, False)
  659.         self.choice = tk.IntVar()
  660.         self.order = tk.IntVar()
  661.         self.choice.set(0)
  662.         self.order.set(0)
  663.         tk.Label(master, text = "Choose an attribute to sort by:", font = ftNormal).grid(row = 0)
  664.         tk.Label(master, text = "Choose an order to sort by:", font = ftNormal).grid(row = 9)
  665.  
  666.         Name = tk.Radiobutton(master, text = "Name", value = 0, variable = self.choice, cursor = "hand2", font = ftNormal)
  667.         Count = tk.Radiobutton(master, text = "Count", value = 2, variable = self.choice, cursor = "hand2", font = ftNormal)
  668.         Weight = tk.Radiobutton(master, text = "Weight", value = 3, variable = self.choice, cursor = "hand2", font = ftNormal)
  669.         dType = tk.Radiobutton(master, text = "Dice Type", value = 4, variable = self.choice, cursor = "hand2", font = ftNormal)
  670.         dCount = tk.Radiobutton(master, text = "Dice Count", value = 5, variable = self.choice, cursor = "hand2", font = ftNormal)
  671.         Charges = tk.Radiobutton(master, text = "Charges", value = 6, variable = self.choice, cursor = "hand2", font = ftNormal)
  672.         MaxCharges = tk.Radiobutton(master, text = "Max Charges", value = 7, variable = self.choice, cursor = "hand2", font = ftNormal)
  673.         Equipped = tk.Radiobutton(master, text = "Equipped", value = 8, variable = self.choice, cursor = "hand2", font = ftNormal)
  674.         Ascending = tk.Radiobutton(master, text = "Ascending", value = 1, variable = self.order, cursor = "hand2", font = ftNormal)
  675.         Descending = tk.Radiobutton(master, text = "Descending", value = 0, variable = self.order, cursor = "hand2", font = ftNormal)
  676.  
  677.         Name.grid(row = 1, sticky = "w")
  678.         Count.grid(row = 2, sticky = "w")
  679.         Weight.grid(row = 3, sticky = "w")
  680.         dType.grid(row = 4, sticky = "w")
  681.         dCount.grid(row = 5, sticky = "w")
  682.         Charges.grid(row = 6, sticky = "w")
  683.         MaxCharges.grid(row = 7, sticky = "w")
  684.         Equipped.grid(row = 8, sticky = "w")
  685.         Ascending.grid(row = 10, sticky = "w")
  686.         Descending.grid(row = 11, sticky = "w")
  687.  
  688.     def apply(self):
  689.         self.result = [self.choice.get(), self.order.get()]
  690. #Sorts inventory by various attributes
  691. def sortItems():
  692.     choice = sortItemsRoot(base).result
  693.    
  694.     if type(choice) == list:
  695.         if choice[1] == 1:
  696.             order = True
  697.         else:
  698.             order = False
  699.  
  700.         inventory.sort(key = op.itemgetter(choice[0]), reverse = order)
  701.         refrINVT()
  702. #Rolls virtual dice of various types0
  703. def rollDice(d):
  704.     def rollDiceWrap(dice = d):
  705.         if dice == 0:
  706.             DICELbl.config(text = "0 | d?")
  707.         elif dice == 2:
  708.             if rnd.randint(0,1):
  709.                 DICELbl.config(text = "Heads | Coin")
  710.             else:
  711.                 DICELbl.config(text = "Tails | Coin")
  712.         elif dice < 100:
  713.             DICELbl.config(text = str(rnd.randint(1, dice)) + " | d" + str(dice))
  714.         else:
  715.             DICELbl.config(text = str(rnd.randint(0, 100)) + " | d%")
  716.     return rollDiceWrap
  717. #Refreshes the skills frame
  718. def refrSKIL():
  719.     SKILTxt.delete(0, SKILTxt.size())
  720.     stats = ["STR", "DEX", "CON", "INT", "WIS", "CHA"]
  721.  
  722.     for sk in skills:
  723.         SKILTxt.insert("end", stats[sk[0]] + "|" + sk[1])
  724. #Dialog for selecting the attribute stat associated with a skill or ability
  725. class skillStat(sdg.Dialog):
  726.     def __init__(self, master = None, m = "", sa = "", i = 0):
  727.         self.mode = m
  728.         self.skab = sa
  729.         self.index = i
  730.         super().__init__(master)
  731.  
  732.     def body(self, master):
  733.         self.resizable(False, False)
  734.         self.stat = tk.IntVar()
  735.  
  736.         if self.skab == "skill":
  737.             if self.mode == "edit":
  738.                 self.title("Edit " + skills[self.index][1])
  739.                 self.stat.set(skills[self.index][0])
  740.  
  741.             elif self.mode == "new":
  742.                 self.title("New Skill")
  743.                 self.stat.set(0)
  744.  
  745.         elif self.skab == "ability":
  746.             if self.mode == "edit":
  747.                 self.title("Edit " + abilities[self.index][1])
  748.                 self.stat.set(abilities[self.index][0])
  749.  
  750.             elif self.mode == "new":
  751.                 self.title("New Ability")
  752.                 self.stat.set(0)
  753.  
  754.  
  755.         PRMPLbl = tk.Label(master, font = ftSmall)
  756.         PRMPLbl.grid(row = 0)
  757.         if self.skab == "skill":
  758.             if self.mode == "edit":
  759.                 PRMPLbl.config(text = "[Optional] Choose a new stat for the skill:")
  760.             elif self.mode == "new":
  761.                 PRMPLbl.config(text = "Choose a stat for the skill:")
  762.         elif self.skab == "ability":
  763.             if self.mode == "edit":
  764.                 PRMPLbl.config(text = "[Optional] Choose a new stat for the ability:")
  765.             elif self.mode == "new":
  766.                 PRMPLbl.config(text = "Choose a stat for the ability:")
  767.  
  768.         STRBtn = tk.Radiobutton(master, text = "Strength", value = 0, variable = self.stat, font = ftNormal)
  769.         DEXBtn = tk.Radiobutton(master, text = "Dexterity", value = 1, variable = self.stat, font = ftNormal)
  770.         CONBtn = tk.Radiobutton(master, text = "Constitution", value = 2, variable = self.stat, font = ftNormal)
  771.         INTBtn = tk.Radiobutton(master, text = "Intelligence", value = 3, variable = self.stat, font = ftNormal)
  772.         WISBtn = tk.Radiobutton(master, text = "Wisdom", value = 4, variable = self.stat, font = ftNormal)
  773.         CHABtn = tk.Radiobutton(master, text = "Charisma", value = 5, variable = self.stat, font = ftNormal)
  774.        
  775.         STRBtn.grid(row = 1, sticky = "w")
  776.         DEXBtn.grid(row = 2, sticky = "w")
  777.         CONBtn.grid(row = 3, sticky = "w")
  778.         INTBtn.grid(row = 4, sticky = "w")
  779.         WISBtn.grid(row = 5, sticky = "w")
  780.         CHABtn.grid(row = 6, sticky = "w")
  781.  
  782.     def apply(self):
  783.         self.result = self.stat.get()
  784. #Creates a new skill
  785. def newSkill():
  786.     tempStr = ""
  787.     while type(tempStr) == str and len(tempStr) < 1:
  788.         tempStr = sdg.askstring("New Skill", "Enter the new skill's name:")
  789.         if type(tempStr) == str and len(tempStr) < 1:
  790.             mbx.showerror("Error", "You must name this skill!")
  791.  
  792.     if type(tempStr) == str:
  793.         tempInt = skillStat(base, "new", "skill").result
  794.         if type(tempInt) == int:
  795.             skills.append([tempInt, tempStr])
  796.             refrSKIL()
  797.             if SKILSCORVar.get():
  798.                 changeScores()
  799. #Edits a skill
  800. def editSkill():
  801.     try:
  802.         index = SKILTxt.curselection()[0]
  803.         sk = skills[index]
  804.         tempStr = sdg.askstring("Edit " + sk[1], "[Optional] Enter the skill's new name:", initialvalue = sk[1])
  805.         if type(tempStr) == str:
  806.             if len(tempStr) > 0 and tempStr != sk[1]:
  807.                 skills[index][1] = tempStr
  808.            
  809.             tempInt = skillStat(base, "edit", "skill", index).result
  810.             if type(tempInt) == int and tempInt != sk[0]:
  811.                 skills[index][0] = tempInt
  812.  
  813.             refrSKIL()
  814.             if SKILSCORVar.get():
  815.                 changeScores()
  816.     except IndexError:
  817.         mbx.showerror("Error", "No skill selected!")
  818. #Deletes a skill
  819. def deleteSkill():
  820.     try:
  821.         if mbx.askyesno("Delete " + skills[SKILTxt.curselection()[0]][1], "Are you sure you want to delete this skill?"):
  822.             del skills[SKILTxt.curselection()[0]]
  823.             refrSKIL()
  824.             if SKILSCORVar.get():
  825.                 changeScores()
  826.  
  827.     except IndexError:
  828.         mbx.showerror("Error", "No skill selected!")
  829. #Dialog for skills and/or abilities
  830. class sortSkillsAbils(sdg.Dialog):
  831.     def __init__(self, master = None, sa = ""):
  832.         self.skab = sa
  833.         super().__init__(master)
  834.  
  835.     def body(self, master):
  836.         if self.skab == "skill":
  837.             self.title("Sort Skills")
  838.         elif self.skab == "ability":
  839.             self.title("Sort Abilities")
  840.         self.resizable(False, False)
  841.         self.choice = tk.IntVar()
  842.         self.order = tk.IntVar()
  843.         self.choice.set(0)
  844.         self.order.set(0)
  845.         tk.Label(master, text = "Choose an attribute to sort by:", font = ftNormal).grid(row = 0)
  846.         tk.Label(master, text = "Choose an order to sort by:", font = ftNormal).grid(row = 3)
  847.  
  848.         Name = tk.Radiobutton(master, text = "Name", value = 1, variable = self.choice, cursor = "hand2", font = ftNormal)
  849.         Stat = tk.Radiobutton(master, text = "Stat", value = 0, variable = self.choice, cursor = "hand2", font = ftNormal)
  850.         Ascending = tk.Radiobutton(master, text = "Ascending", value = 1, variable = self.order, cursor = "hand2", font = ftNormal)
  851.         Descending = tk.Radiobutton(master, text = "Descending", value = 0, variable = self.order, cursor = "hand2", font = ftNormal)
  852.  
  853.         Name.grid(row = 1, sticky = "w")
  854.         Stat.grid(row = 2, sticky = "w")
  855.         Ascending.grid(row = 4, sticky = "w")
  856.         Descending.grid(row = 5, sticky = "w")
  857.  
  858.     def apply(self):
  859.         self.result = [self.choice.get(), self.order.get()]
  860. #Sorts skills by name or attribute stat
  861. def sortSkills():
  862.     choice = sortSkillsAbils(base, "skill").result
  863.  
  864.     if type(choice) == list:
  865.         if choice[1] == 1:
  866.             order = True
  867.         else:
  868.             order = False
  869.  
  870.         skills.sort(key = op.itemgetter(choice[0]), reverse = order)
  871.         refrSKIL()
  872. #Toggles between including racial/class ability score bonuses into the Stats display
  873. def changeScores():
  874.     if SKILSCORVar.get():
  875.         newScores = []
  876.  
  877.         for i in range(len(mainStats)):
  878.             newScores.append(mainStats[i])
  879.        
  880.         for sk in skills:
  881.             if sk[1][0] in "+-":
  882.                 try:
  883.                     if sk[1][0] == '+':
  884.                         newScores[sk[0]] += int(sk[1][1:].split()[0])
  885.                     else:
  886.                         newScores[sk[0]] += int(sk[1][0:].split()[0])
  887.                 except ValueError:
  888.                     pass
  889.  
  890.         newMods = [0, 0, 0, 0, 0, 0]
  891.         for i in range(len(newScores)):
  892.             newMods[i] = (newScores[i] - 10) // 2
  893.  
  894.         refrSTAT(False, newScores, newMods)
  895.     else:
  896.         refrSTAT()
  897. #Shows the information box regarding the above functionality
  898. def showPrefixInfo():
  899.     mbx.showinfo("Skills: Apply Prefixes", "When checked, all skills whose name have a leading +/- character \
  900. followed by an integer then a space will be compiled and added to your base Ability Scores without changing said scores. \
  901. This is useful for adding temporary skill entries to act as buffs from equipment or spells.")
  902. #Refreshes the abilities frame
  903. def refrABIL():
  904.     ABILTxt.delete(0, ABILTxt.size())
  905.     stats = ["STR", "DEX", "CON", "INT", "WIS", "CHA"]
  906.  
  907.     for ab in abilities:
  908.         ABILTxt.insert("end", stats[ab[0]] + "|" + ab[1])
  909. #Creates a new ability
  910. def newAbility():
  911.     tempStrA = ""
  912.     while type(tempStrA) == str and len(tempStrA) < 1:
  913.         tempStrA = sdg.askstring("New Ability", "Enter the new ability's name:")
  914.        
  915.         if type(tempStrA) == str and len(tempStrA) < 1:
  916.             mbx.showerror("Error", "You must name this ability!")
  917.  
  918.     if type(tempStrA) == str:
  919.         tempInt = skillStat(base, "new", "ability").result
  920.        
  921.         if type(tempInt) == int:
  922.             tempStrB = sdg.askstring("New Ability", "Describe the new ability:")
  923.            
  924.             if type(tempStrB) == str:
  925.                 abilities.append([tempInt, tempStrA, tempStrB])
  926.                 refrABIL()
  927. #Edits an ability
  928. def editAbility():
  929.     try:
  930.         index = ABILTxt.curselection()[0]
  931.         ab = abilities[index]
  932.         tempStr = sdg.askstring("Edit " + ab[1], "[Optional] Enter the ability's new name:", initialvalue = ab[1])
  933.         if type(tempStr) == str:
  934.             if len(tempStr) > 0 and tempStr != ab[1]:
  935.                 abilities[index][1] = tempStr
  936.            
  937.             tempInt = skillStat(base, "edit", "ability", index).result
  938.             if type(tempInt) == int:
  939.                 if tempInt != ab[0]:
  940.                     abilities[index][0] = tempInt
  941.  
  942.                 tempStr = sdg.askstring("Edit " + ab[1], "[Optional] Describe the ability again:", initialvalue = ab[2])
  943.                 if type(tempStr) == str and len(tempStr) > 0 and tempStr != ab[2]:
  944.                     abilities[index][2] = tempStr
  945.  
  946.             refrABIL()
  947.     except IndexError:
  948.         mbx.showerror("Error", "No ability selected!")
  949. #Deletes an ability
  950. def deleteAbility():
  951.     try:
  952.         if mbx.askyesno("Delete " + abilities[ABILTxt.curselection()[0]][1], "Are you sure you want to delete this ability?"):
  953.             del abilities[ABILTxt.curselection()[0]]
  954.             refrABIL()
  955.  
  956.     except IndexError:
  957.         mbx.showerror("Error", "No ability selected!")
  958. #Shows an ability's description
  959. def inspectAbility():
  960.     try:
  961.         if len(abilities[ABILTxt.curselection()[0]][2]) > 0:
  962.             mbx.showinfo("Ability: " + abilities[ABILTxt.curselection()[0]][1], "Description:\n" + abilities[ABILTxt.curselection()[0]][2])
  963.         else:
  964.             mbx.showinfo("Ability: " + abilities[ABILTxt.curselection()[0]][1], "Description:\n[None]")
  965.  
  966.     except IndexError:
  967.         mbx.showerror("Error", "No ability selected!")
  968. #Sorts abilities by name or attribute stat
  969. def sortAbilities():
  970.     choice = sortSkillsAbils(base, "ability").result
  971.  
  972.     if type(choice) == list:
  973.         if choice[1] == 1:
  974.             order = True
  975.         else:
  976.             order = False
  977.  
  978.         abilities.sort(key = op.itemgetter(choice[0]), reverse = order)
  979.         refrABIL()
  980. #Prevents the program from exiting on one click
  981. def exitOverride():
  982.     if mbx.askyesno("Warning! Data Loss Possibility Detected!", "Unsaved data will be lost if you quit. Are you sure you want to quit?"):
  983.         base.destroy()
  984. #Dialog for choosing a method to set main stats
  985. class newCharacterStatRoot(sdg.Dialog):
  986.     def body(self, master):
  987.         self.title("New Character: Stats")
  988.         self.resizable(False, False)
  989.         self.choice = tk.IntVar()
  990.         self.choice.set(0)
  991.  
  992.         tk.Label(master, text = "It is now time to set your ability scores / main stats.\nChoose a method below:", font = ftNormal).grid(row = 0)
  993.         PB = tk.Radiobutton(master, text = "5E Point-Buy", value = 0, variable =  self.choice, cursor = "hand2", font = ftNormal)
  994.         DR = tk.Radiobutton(master, text = "Dice Rolls", value = 1, variable =  self.choice, cursor = "hand2", font = ftNormal)
  995.         MAN = tk.Radiobutton(master, text = "Manual Entry", value = 2, variable =  self.choice, cursor = "hand2", font = ftNormal)
  996.  
  997.         PB.grid(row = 1, sticky = "w")
  998.         DR.grid(row = 2, sticky = "w")
  999.         MAN.grid(row = 3, sticky = "w")
  1000.  
  1001.     def apply(self):
  1002.         self.result = self.choice.get()
  1003. #Dialog for a point-buy calculator
  1004. class pointBuyRoot(sdg.Dialog):
  1005.     def body(self, master):
  1006.         self.title("New Character: Point-Buy Stats")
  1007.         self.resizable(False, False)
  1008.  
  1009.         self.STR = tk.Scale(master, from_ = 8, to = 15, orient = "horizontal", command = self.calculatePoints, font = ftNormal)
  1010.         self.DEX = tk.Scale(master, from_ = 8, to = 15, orient = "horizontal", command = self.calculatePoints, font = ftNormal)
  1011.         self.CON = tk.Scale(master, from_ = 8, to = 15, orient = "horizontal", command = self.calculatePoints, font = ftNormal)
  1012.         self.INT = tk.Scale(master, from_ = 8, to = 15, orient = "horizontal", command = self.calculatePoints, font = ftNormal)
  1013.         self.WIS = tk.Scale(master, from_ = 8, to = 15, orient = "horizontal", command = self.calculatePoints, font = ftNormal)
  1014.         self.CHA = tk.Scale(master, from_ = 8, to = 15, orient = "horizontal", command = self.calculatePoints, font = ftNormal)
  1015.  
  1016.         self.bSTRVar = tk.IntVar()
  1017.         self.bDEXVar = tk.IntVar()
  1018.         self.bCONVar = tk.IntVar()
  1019.         self.bINTVar = tk.IntVar()
  1020.         self.bWISVar = tk.IntVar()
  1021.         self.bCHAVar = tk.IntVar()
  1022.  
  1023.         self.bSTRVar.set(-1)
  1024.         self.bDEXVar.set(-1)
  1025.         self.bCONVar.set(-1)
  1026.         self.bINTVar.set(-1)
  1027.         self.bWISVar.set(-1)
  1028.         self.bCHAVar.set(-1)
  1029.  
  1030.         bSTR = tk.Label(master, textvariable = self.bSTRVar, width = 2, relief = "ridge", font = ftNormal)
  1031.         bDEX = tk.Label(master, textvariable = self.bDEXVar, width = 2, relief = "ridge", font = ftNormal)
  1032.         bCON = tk.Label(master, textvariable = self.bCONVar, width = 2, relief = "ridge", font = ftNormal)
  1033.         bINT = tk.Label(master, textvariable = self.bINTVar, width = 2, relief = "ridge", font = ftNormal)
  1034.         bWIS = tk.Label(master, textvariable = self.bWISVar, width = 2, relief = "ridge", font = ftNormal)
  1035.         bCHA = tk.Label(master, textvariable = self.bCHAVar, width = 2, relief = "ridge", font = ftNormal)
  1036.  
  1037.         bSTR.grid(row = 2, column = 2, sticky = "s")
  1038.         bDEX.grid(row = 3, column = 2, sticky = "s")
  1039.         bCON.grid(row = 4, column = 2, sticky = "s")
  1040.         bINT.grid(row = 5, column = 2, sticky = "s")
  1041.         bWIS.grid(row = 6, column = 2, sticky = "s")
  1042.         bCHA.grid(row = 7, column = 2, sticky = "s")
  1043.  
  1044.         self.currentPoints = tk.IntVar()
  1045.         self.currentPoints.set(0)
  1046.  
  1047.         tk.Label(master, text = "Point Total:", font = ftLarge).grid(row = 0, column = 0, columnspan = 2)
  1048.         tk.Label(master, textvariable = self.currentPoints, relief = "ridge", width = 2, font = ftLarge).grid(row = 0, column = 1, sticky = "e")
  1049.         tk.Label(master, text = "/27", font = ftLarge).grid(row = 0, column = 2)
  1050.         tk.Label(master, text = "Attribute", font = ftSmall).grid(row = 1, column = 0)
  1051.         tk.Label(master, text = "Value", font = ftSmall).grid(row = 1, column = 1)
  1052.         tk.Label(master, text = "Modifier", font = ftSmall).grid(row = 1, column = 2)
  1053.         tk.Label(master, text = "Strength", width = 16, font = ftNormal).grid(row = 2, column = 0, sticky = "s")
  1054.         tk.Label(master, text = "Dexterity", width = 16, font = ftNormal).grid(row = 3, column = 0, sticky = "s")
  1055.         tk.Label(master, text = "Constitution", width = 16, font = ftNormal).grid(row = 4, column = 0, sticky = "s")
  1056.         tk.Label(master, text = "Intelligence", width = 16, font = ftNormal).grid(row = 5, column = 0, sticky = "s")
  1057.         tk.Label(master, text = "Wisdom", width = 16, font = ftNormal).grid(row = 6, column = 0, sticky = "s")
  1058.         tk.Label(master, text = "Charisma", width = 16, font = ftNormal).grid(row = 7, column = 0, sticky = "s")
  1059.  
  1060.         self.STR.grid(row = 2, column = 1)
  1061.         self.DEX.grid(row = 3, column = 1)
  1062.         self.CON.grid(row = 4, column = 1)
  1063.         self.INT.grid(row = 5, column = 1)
  1064.         self.WIS.grid(row = 6, column = 1)
  1065.         self.CHA.grid(row = 7, column = 1)
  1066.  
  1067.     def validate(self):
  1068.         if self.currentPoints.get() == 27 and mbx.askyesno("Confirmation", "Are you sure you want these values for your main stats?"):
  1069.             return 1
  1070.         elif self.currentPoints.get() != 27:
  1071.             mbx.showerror("Error", "You need to have a Point Total of 27 to have valid values!")
  1072.             return 0
  1073.         else:
  1074.             return 0
  1075.  
  1076.     def apply(self):
  1077.         resultString = ""
  1078.  
  1079.         resultString += str(self.STR.get()) + "|"
  1080.         resultString += str(self.DEX.get()) + "|"
  1081.         resultString += str(self.CON.get()) + "|"
  1082.         resultString += str(self.INT.get()) + "|"
  1083.         resultString += str(self.WIS.get()) + "|"
  1084.         resultString += str(self.CHA.get()) + "\n"
  1085.         resultString += str(self.bSTRVar.get()) + "|"
  1086.         resultString += str(self.bDEXVar.get()) + "|"
  1087.         resultString += str(self.bCONVar.get()) + "|"
  1088.         resultString += str(self.bINTVar.get()) + "|"
  1089.         resultString += str(self.bWISVar.get()) + "|"
  1090.         resultString += str(self.bCHAVar.get())
  1091.  
  1092.         self.result = resultString
  1093.  
  1094.     def calculatePoints(self, changedSlider):
  1095.         self.bSTRVar.set((self.STR.get() - 10) // 2)
  1096.         self.bDEXVar.set((self.DEX.get() - 10) // 2)
  1097.         self.bCONVar.set((self.CON.get() - 10) // 2)
  1098.         self.bINTVar.set((self.INT.get() - 10) // 2)
  1099.         self.bWISVar.set((self.WIS.get() - 10) // 2)
  1100.         self.bCHAVar.set((self.CHA.get() - 10) // 2)
  1101.  
  1102.         currentScores = []
  1103.  
  1104.         currentScores.append(self.STR.get())
  1105.         currentScores.append(self.DEX.get())
  1106.         currentScores.append(self.CON.get())
  1107.         currentScores.append(self.INT.get())
  1108.         currentScores.append(self.WIS.get())
  1109.         currentScores.append(self.CHA.get())
  1110.  
  1111.         pointsUsed = 0
  1112.  
  1113.         for score in currentScores:
  1114.             if score < 14:
  1115.                 pointsUsed += score - 8
  1116.             elif score == 14:
  1117.                 pointsUsed += 7
  1118.             elif score == 15:
  1119.                 pointsUsed += 9
  1120.  
  1121.         self.currentPoints.set(pointsUsed)
  1122. #Dialog for a dice-roll stat selector
  1123. class diceRollStatsRoot(sdg.Dialog):
  1124.     def body(self, master):
  1125.         self.title("New Character: Dice Roll Stats")
  1126.         self.resizable(False, False)
  1127.         self.letters = ('A', 'B', 'C', 'D', 'E', 'F')
  1128.         self.stats = ('STR', 'CHA', 'WIS', 'INT', 'CON', 'DEX')
  1129.         self.rolled = False
  1130.         self.rolls = [0, 0, 0, 0, 0, 0]
  1131.         #self.rollsVar = tk.StringVar()
  1132.         #self.rollsVar.set("Press \"Roll\" to begin!")
  1133.  
  1134.         tk.Label(master, text = "You can swap values between attributes below.\nIn the \"six 4d6\" roll mode,\nthe lowest roll of each batch is not counted.", font = ftSmall).grid(row = 0, columnspan = 3)
  1135.  
  1136.         #rollsLbl = tk.Label(master, textvariable = self.rollsVar, width = 36, relief = "ridge", font = ftNormal)
  1137.         #rollsLbl.grid(row = 1, column = 0, columnspan = 2)
  1138.         self.swapOne = tk.Spinbox(master, width = 4, values = self.stats, wrap = True, font = ftNormal)
  1139.         self.swapTwo = tk.Spinbox(master, width = 4, values = self.stats, wrap = True, font = ftNormal)
  1140.         self.rollMode = tk.Spinbox(master, width = 8, values = ("six 1d20", "six 4d6"), wrap = True, font = ftNormal)
  1141.  
  1142.         self.swapOne.grid(row = 1, column = 0)
  1143.         self.swapTwo.grid(row = 1, column = 1)
  1144.         self.rollMode.grid(row = 2, column = 1)
  1145.  
  1146.         tk.Button(master, text = "Swap", command = self.swap, cursor = "hand2", font = ftNormal).grid(row = 1, column = 2)
  1147.         tk.Label(master, text = "Roll Mode", font = ftNormal).grid(row = 2, column = 0)
  1148.         tk.Button(master, text = "Roll", command = self.rollStats, cursor = "hand2", font = ftNormal).grid(row = 2, column = 2)
  1149.  
  1150.         tk.Label(master, text = "Attribute", font = ftSmall).grid(row = 3, column = 0)
  1151.         tk.Label(master, text = "Value", font = ftSmall).grid(row = 3, column = 1)
  1152.         tk.Label(master, text = "Modifier", font = ftSmall).grid(row = 3, column = 2)
  1153.  
  1154.         tk.Label(master, text = "Strength", font = ftNormal).grid(row = 4, column = 0)
  1155.         tk.Label(master, text = "Dexterity", font = ftNormal).grid(row = 5, column = 0)
  1156.         tk.Label(master, text = "Constitution", font = ftNormal).grid(row = 6, column = 0)
  1157.         tk.Label(master, text = "Intelligence", font = ftNormal).grid(row = 7, column = 0)
  1158.         tk.Label(master, text = "Wisdom", font = ftNormal).grid(row = 8, column = 0)
  1159.         tk.Label(master, text = "Charisma", font = ftNormal).grid(row = 9, column = 0)
  1160.  
  1161.         self.STR = tk.Label(master, text = "?", width = 4, relief = "ridge", font = ftNormal)
  1162.         self.DEX = tk.Label(master, text = "?", width = 4, relief = "ridge", font = ftNormal)
  1163.         self.CON = tk.Label(master, text = "?", width = 4, relief = "ridge", font = ftNormal)
  1164.         self.INT = tk.Label(master, text = "?", width = 4, relief = "ridge", font = ftNormal)
  1165.         self.WIS = tk.Label(master, text = "?", width = 4, relief = "ridge", font = ftNormal)
  1166.         self.CHA = tk.Label(master, text = "?", width = 4, relief = "ridge", font = ftNormal)
  1167.  
  1168.         self.bSTR = tk.Label(master, text = "?", width = 4, relief = "ridge", font = ftNormal)
  1169.         self.bDEX = tk.Label(master, text = "?", width = 4, relief = "ridge", font = ftNormal)
  1170.         self.bCON = tk.Label(master, text = "?", width = 4, relief = "ridge", font = ftNormal)
  1171.         self.bINT = tk.Label(master, text = "?", width = 4, relief = "ridge", font = ftNormal)
  1172.         self.bWIS = tk.Label(master, text = "?", width = 4, relief = "ridge", font = ftNormal)
  1173.         self.bCHA = tk.Label(master, text = "?", width = 4, relief = "ridge", font = ftNormal)
  1174.  
  1175.         self.STR.grid(row = 4, column = 1)
  1176.         self.DEX.grid(row = 5, column = 1)
  1177.         self.CON.grid(row = 6, column = 1)
  1178.         self.INT.grid(row = 7, column = 1)
  1179.         self.WIS.grid(row = 8, column = 1)
  1180.         self.CHA.grid(row = 9, column = 1)
  1181.  
  1182.         self.bSTR.grid(row = 4, column = 2)
  1183.         self.bDEX.grid(row = 5, column = 2)
  1184.         self.bCON.grid(row = 6, column = 2)
  1185.         self.bINT.grid(row = 7, column = 2)
  1186.         self.bWIS.grid(row = 8, column = 2)
  1187.         self.bCHA.grid(row = 9, column = 2)
  1188.  
  1189.  
  1190.     def validate(self):
  1191.         if not self.rolled:
  1192.             mbx.showerror("Error", "You must roll at least once!")
  1193.             return 0
  1194.  
  1195.         elif not mbx.askyesno("Confirmation", "Are you sure you want these values for your main stats?"):
  1196.             return 0
  1197.  
  1198.         return 1
  1199.  
  1200.     def apply(self):
  1201.         resultString = ""
  1202.  
  1203.         resultString += self.STR["text"] + "|"
  1204.         resultString += self.DEX["text"] + "|"
  1205.         resultString += self.CON["text"] + "|"
  1206.         resultString += self.INT["text"] + "|"
  1207.         resultString += self.WIS["text"] + "|"
  1208.         resultString += self.CHA["text"] + "\n"
  1209.         resultString += self.bSTR["text"] + "|"
  1210.         resultString += self.bDEX["text"] + "|"
  1211.         resultString += self.bCON["text"] + "|"
  1212.         resultString += self.bINT["text"] + "|"
  1213.         resultString += self.bWIS["text"] + "|"
  1214.         resultString += self.bCHA["text"]
  1215.  
  1216.         self.result = resultString
  1217.  
  1218.     def setValues(self, master, tempStats):
  1219.         self.STR.config(text = str(tempStats[0]))
  1220.         self.DEX.config(text = str(tempStats[1]))
  1221.         self.CON.config(text = str(tempStats[2]))
  1222.         self.INT.config(text = str(tempStats[3]))
  1223.         self.WIS.config(text = str(tempStats[4]))
  1224.         self.CHA.config(text = str(tempStats[5]))
  1225.  
  1226.         self.bSTR.config(text = str((int(tempStats[0]) - 10) // 2))
  1227.         self.bDEX.config(text = str((int(tempStats[1]) - 10) // 2))
  1228.         self.bCON.config(text = str((int(tempStats[2]) - 10) // 2))
  1229.         self.bINT.config(text = str((int(tempStats[3]) - 10) // 2))
  1230.         self.bWIS.config(text = str((int(tempStats[4]) - 10) // 2))
  1231.         self.bCHA.config(text = str((int(tempStats[5]) - 10) // 2))
  1232.  
  1233.     def swap(self):
  1234.         if not self.rolled:
  1235.             mbx.showerror("Error", "You must roll at least once!")
  1236.             return
  1237.  
  1238.         tempStats = []
  1239.         localStats = ('STR', 'DEX', 'CON', 'INT', 'WIS', 'CHA')
  1240.  
  1241.         statA = localStats.index(self.swapOne.get())
  1242.         statB = localStats.index(self.swapTwo.get())
  1243.  
  1244.         if statA == statB:
  1245.             mbx.showerror("Error", "You can't swap a value with itself!")
  1246.             return
  1247.  
  1248.         tempStats.append(self.STR["text"])
  1249.         tempStats.append(self.DEX["text"])
  1250.         tempStats.append(self.CON["text"])
  1251.         tempStats.append(self.INT["text"])
  1252.         tempStats.append(self.WIS["text"])
  1253.         tempStats.append(self.CHA["text"])
  1254.  
  1255.         temp = tempStats[statA]
  1256.         tempStats[statA] = tempStats[statB]
  1257.         tempStats[statB] = temp
  1258.  
  1259.         self.setValues(self, tempStats)
  1260.  
  1261.     def rollStats(self):
  1262.         tempStats = [0, 0, 0, 0, 0, 0]
  1263.         tempRolls = []
  1264.         tempStr = ""
  1265.  
  1266.         if self.rollMode.get() == "six 1d20":
  1267.             for i in range(len(tempStats)):
  1268.                 tempStats[i] = rnd.randint(1, 20)
  1269.  
  1270.         else:
  1271.             for i in range(len(tempStats)):
  1272.                 for n in range(4):
  1273.                     tempRolls.append(rnd.randint(1,6))
  1274.  
  1275.                 tempRolls.remove(min(tempRolls))
  1276.  
  1277.                 tempStats[i] = sum(tempRolls)
  1278.  
  1279.                 tempRolls = []
  1280.  
  1281.         self.setValues(self, tempStats)
  1282.  
  1283.         self.rolled = True
  1284. #Guides the player through character creation
  1285. def newCharacter():
  1286.     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?"):
  1287.         return
  1288.  
  1289.     tempInfo = []
  1290.     tempHealth = []
  1291.     tempExp = []
  1292.     tempMStats = []
  1293.     tempBStats = []
  1294.     tempInt = 0
  1295.     tempIntB = 0
  1296.     tempStr = ""
  1297.     tempCount = 0
  1298.     infoChoices = ["name", "class", "deity", "race", "gender", "age", "height", "unit", "weight", "unit", "hair color", "eye color", "currency"]
  1299.     statChoices = ["Strength", "Dexterity", "Constitution", "Intelligence", "Wisdom", "Charisma"]
  1300.  
  1301.     while len(tempInfo) < 14:
  1302.         if tempCount < 5 or tempCount > 9:
  1303.             tempStr = sdg.askstring("New Character: Info", "Enter your " + infoChoices[tempCount] + ":")
  1304.             if type(tempStr) == str:
  1305.                 tempInfo.append(tempStr)
  1306.             else:
  1307.                 return
  1308.  
  1309.             if tempCount == 12:
  1310.                 tempInt = sdg.askinteger("New Character: Info", "Enter how much currency you have:")
  1311.                 if type(tempInt) == int:
  1312.                     tempInfo.append(tempInt)
  1313.                 else:
  1314.                     return
  1315.             else:
  1316.                 tempCount += 1
  1317.  
  1318.         elif tempCount > 5 and tempCount < 10:
  1319.             tempStr = sdg.askstring("New Character: Info", "Enter your unit of " + infoChoices[tempCount] + ":")
  1320.             if type(tempStr) != str:
  1321.                 return
  1322.  
  1323.             tempInt = sdg.askinteger("New Character: Info", "Enter your " + infoChoices[tempCount] + ":")
  1324.             if type(tempInt) == int:
  1325.                 tempInfo.append(tempInt)
  1326.                 tempInfo.append(tempStr)
  1327.                 tempCount += 2
  1328.             else:
  1329.                 return
  1330.  
  1331.         elif tempCount == 5:
  1332.             tempInt = sdg.askinteger("New Character: Info", "Enter your " + infoChoices[tempCount] + ":")
  1333.             if type(tempInt) == int:
  1334.                 tempInfo.append(tempInt)
  1335.                 tempCount += 1
  1336.             else:
  1337.                 return
  1338.  
  1339.     tempInt = sdg.askinteger("New Character: Health", "Enter your initial maximum health points:")
  1340.     if type(tempInt) != int:
  1341.         return
  1342.  
  1343.     tempHealth.append(tempInt)
  1344.     tempHealth.append(tempInt)
  1345.  
  1346.     tempExp.append(1)
  1347.     tempExp.append(0)
  1348.  
  1349.     if LEVLVar.get():
  1350.         tempExp.append(300)
  1351.     else:
  1352.         tempExp.append(110)
  1353.  
  1354.     tempInt = newCharacterStatRoot(base).result
  1355.     if type(tempInt) != int:
  1356.         return
  1357.  
  1358.     if tempInt == 0:
  1359.         tempStr = pointBuyRoot(base).result
  1360.     if tempInt == 1:
  1361.         tempStr = diceRollStatsRoot(base).result
  1362.  
  1363.     if type(tempStr) != str:
  1364.         return
  1365.  
  1366.     if tempInt in (0, 1):
  1367.         for s in tempStr.split()[0].split('|'):
  1368.             tempMStats.append(int(s))
  1369.  
  1370.         for s in tempStr.split()[1].split('|'):
  1371.             tempBStats.append(int(s))
  1372.  
  1373.     elif tempInt == 2:
  1374.         tempCount = 0
  1375.  
  1376.         while len(tempMStats) < 6 and len(tempBStats) < 6:
  1377.             tempInt = sdg.askinteger("New Character: Manual Stats", "Enter your " + statChoices[tempCount] + ":")
  1378.             if type(tempInt) != int:
  1379.                 return
  1380.  
  1381.             tempIntB = (tempInt - 10) // 2
  1382.  
  1383.             tempMStats.append(tempInt)
  1384.             tempBStats.append(tempIntB)
  1385.             tempCount += 1
  1386.  
  1387.     tempCount = 0
  1388.  
  1389.     for bit in tempInfo:
  1390.         info[tempCount] = bit
  1391.         tempCount += 1
  1392.  
  1393.     tempCount = 0
  1394.  
  1395.     for bit in tempHealth:
  1396.         health[tempCount] = bit
  1397.         tempCount += 1
  1398.  
  1399.     tempCount = 0
  1400.  
  1401.     for bit in tempExp:
  1402.         experience[tempCount] = bit
  1403.         tempCount += 1
  1404.  
  1405.     tempCount = 0
  1406.  
  1407.     for bit in tempMStats:
  1408.         mainStats[tempCount] = bit
  1409.         tempCount += 1
  1410.  
  1411.     tempCount = 0
  1412.  
  1413.     for bit in tempBStats:
  1414.         bonusStats[tempCount] = bit
  1415.         tempCount += 1
  1416.  
  1417.     while len(skills) > 0:
  1418.         del skills[0]
  1419.  
  1420.     while len(abilities) > 0:
  1421.         del abilities[0]
  1422.  
  1423.     while len(inventory) > 0:
  1424.         del inventory[0]
  1425.  
  1426.     refrSTAT()
  1427.     refrINFO()
  1428.     refrSKIL()
  1429.     refrABIL()
  1430.     refrINVT()
  1431.  
  1432.     mbx.showinfo("New Character: Complete", "Done! Your character's main information and stats are ready. You might want to add some abilities or skills for additional bits of information, such as racial bonuses, character backstory, or starting abilities. Good luck, adventurer!")
  1433. #Saves the current character to a .dat file
  1434. def saveCharacter():
  1435.     fileName = sdg.askstring("Save Character", "[Files are saved to the directory\nwhere this program is run]\nEnter the name of the file to save to:")
  1436.     if type(fileName) != str:
  1437.         return
  1438.  
  1439.     fileName += ".dat"
  1440.  
  1441.     if os.path.isfile(fileName):
  1442.         if not mbx.askyesno("Warning! File Already Exists!", "Do you want to overwrite " + fileName + "?"):
  1443.             return
  1444.  
  1445.     saveFile = open(fileName, "w")
  1446.  
  1447.     dlm = " || "
  1448.     adlm = " |\n"
  1449.     nl = "\n\n"
  1450.  
  1451.     temp = 0
  1452.  
  1453.     for bit in info:
  1454.         saveFile.write(str(bit))
  1455.  
  1456.         if temp == 13:
  1457.             saveFile.write(nl)
  1458.         else:
  1459.             saveFile.write(dlm)
  1460.  
  1461.         temp += 1
  1462.  
  1463.     temp = 0
  1464.  
  1465.     for bit in health:
  1466.         saveFile.write(str(bit))
  1467.  
  1468.         if temp == 1:
  1469.             saveFile.write(nl)
  1470.         else:
  1471.             saveFile.write(dlm)
  1472.  
  1473.         temp += 1
  1474.  
  1475.     temp = 0
  1476.  
  1477.     for bit in experience:
  1478.         saveFile.write(str(bit))
  1479.  
  1480.         if temp == 2:
  1481.             saveFile.write(nl)
  1482.         else:
  1483.             saveFile.write(dlm)
  1484.  
  1485.         temp += 1
  1486.  
  1487.     temp = 0
  1488.  
  1489.     for bit in mainStats:
  1490.         saveFile.write(str(bit))
  1491.  
  1492.         if temp == 5:
  1493.             saveFile.write(nl)
  1494.         else:
  1495.             saveFile.write(dlm)
  1496.  
  1497.         temp += 1
  1498.  
  1499.     temp = 0
  1500.  
  1501.     for bit in bonusStats:
  1502.         saveFile.write(str(bit))
  1503.  
  1504.         if temp == 5:
  1505.             saveFile.write(nl)
  1506.         else:
  1507.             saveFile.write(dlm)
  1508.  
  1509.         temp += 1
  1510.  
  1511.     temp = 1
  1512.  
  1513.     for sk in skills:
  1514.         saveFile.write(str(sk[0]) + dlm + sk[1])
  1515.  
  1516.         if temp != len(skills):
  1517.             saveFile.write(adlm)
  1518.  
  1519.         temp += 1
  1520.  
  1521.     saveFile.write(nl)
  1522.  
  1523.     temp = 1
  1524.  
  1525.     for ab in abilities:
  1526.         saveFile.write(str(ab[0]) + dlm + ab[1] + dlm + ab[2])
  1527.  
  1528.         if temp != len(abilities):
  1529.             saveFile.write(adlm)
  1530.  
  1531.         temp += 1
  1532.  
  1533.     saveFile.write(nl)
  1534.  
  1535.     temp = 1
  1536.  
  1537.     for item in inventory:
  1538.         tempAux = 1
  1539.  
  1540.         for bit in item:
  1541.             saveFile.write(str(bit))
  1542.             if tempAux < 9:
  1543.                 saveFile.write(dlm)
  1544.  
  1545.             tempAux += 1
  1546.  
  1547.         if temp != len(inventory):
  1548.             saveFile.write(adlm)
  1549.  
  1550.         temp += 1
  1551.  
  1552.     saveFile.close()
  1553.  
  1554.     mbx.showinfo("Save Character", "Saved!\nCheck the working directory of this program for the file.")
  1555. #Loads a character from a .dat file
  1556. def loadCharacter():
  1557.     loaded = False
  1558.  
  1559.     while not loaded:
  1560.         try:
  1561.             fileName = sdg.askstring("Load Character", "[Files are loaded from the directory\nwhere this program is run]\nEnter the name of the file to load from:")
  1562.             if type(fileName) != str:
  1563.                 return
  1564.  
  1565.             fileName += ".dat"
  1566.             loadFile = open(fileName, "r")
  1567.             loaded = True
  1568.  
  1569.         except FileNotFoundError:
  1570.             mbx.showerror("Error", "File not found!")
  1571.  
  1572.     if mbx.askyesno("Leveling Standard", "Do you want to use the 5E Experience Point brackets instead of C^2's Experience Formula?"):
  1573.         LEVLVar.set(True)
  1574.     else:
  1575.         LEVLVar.set(False)
  1576.  
  1577.     dlm = " || "
  1578.     adlm = " |\n"
  1579.     nl = "\n\n"
  1580.  
  1581.     contents = loadFile.read().split(nl)
  1582.  
  1583.     tempCountA = 0
  1584.  
  1585.     try:
  1586.         for bit in contents:
  1587.             tempList = []
  1588.  
  1589.             if adlm in bit:
  1590.                 tempList = bit.split(adlm)
  1591.                 tempCountB = 0
  1592.  
  1593.                 for item in tempList:
  1594.                     tempList[tempCountB] = item.split(dlm)
  1595.                     tempCountC = 0
  1596.  
  1597.                     for el in tempList[tempCountB]:
  1598.                         if el == "True":
  1599.                             tempList[tempCountB][tempCountC] = True
  1600.                         elif el == "False":
  1601.                             tempList[tempCountB][tempCountC] = False
  1602.                         else:
  1603.                             try:
  1604.                                 tempList[tempCountB][tempCountC] = int(el)
  1605.                
  1606.                             except ValueError:
  1607.                                 try:
  1608.                                     tempList[tempCountB][tempCountC] = float(el)
  1609.                                 except ValueError:
  1610.                                     pass
  1611.    
  1612.                         tempCountC += 1
  1613.    
  1614.                     tempCountB += 1
  1615.  
  1616.             elif dlm in bit:
  1617.                 tempList = bit.split(dlm)
  1618.                 tempCountB = 0
  1619.  
  1620.                 for el in tempList:
  1621.                     try:
  1622.                         tempList[tempCountB] = int(el)
  1623.                
  1624.                     except ValueError:
  1625.                         try:
  1626.                             tempList[tempCountB] = float(el)
  1627.                         except ValueError:
  1628.                             pass
  1629.        
  1630.                     tempCountB += 1
  1631.    
  1632.             contents[tempCountA] = tempList
  1633.  
  1634.             tempCountA += 1
  1635.  
  1636.     except:
  1637.         mbx.showerror("Error", "Unable to Load File!")
  1638.         return
  1639.  
  1640.     tempCount = 0
  1641.  
  1642.     for bit in contents[0]:
  1643.         info[tempCount] = bit
  1644.         tempCount += 1
  1645.  
  1646.     tempCount = 0
  1647.  
  1648.     for bit in contents[1]:
  1649.         health[tempCount] = bit
  1650.         tempCount += 1
  1651.  
  1652.     tempCount = 0
  1653.  
  1654.     for bit in contents[2]:
  1655.         experience[tempCount] = bit
  1656.         tempCount += 1
  1657.  
  1658.     tempCount = 0
  1659.  
  1660.     for bit in contents[3]:
  1661.         mainStats[tempCount] = bit
  1662.         tempCount += 1
  1663.  
  1664.     tempCount = 0
  1665.  
  1666.     for bit in contents[4]:
  1667.         bonusStats[tempCount] = bit
  1668.         tempCount += 1
  1669.  
  1670.     while len(skills) > 0:
  1671.         del skills[0]
  1672.  
  1673.     if len(contents[5]) > 0:
  1674.         if type(contents[5][0]) is list:
  1675.             for bit in contents[5]:
  1676.                 skills.append(bit)
  1677.         else:
  1678.             skills.append(contents[5])
  1679.  
  1680.     while len(abilities) > 0:
  1681.         del abilities[0]
  1682.  
  1683.     if len(contents[6]) > 0:
  1684.         if type(contents[6][0]) is list:
  1685.             for bit in contents[6]:
  1686.                 abilities.append(bit)
  1687.         else:
  1688.             abilities.append(contents[6])
  1689.  
  1690.     while len(inventory) > 0:
  1691.         del inventory[0]
  1692.  
  1693.     if len(contents[7]) > 0:
  1694.         if type(contents[7][0]) is list:
  1695.             for bit in contents[7]:
  1696.                 inventory.append(bit)
  1697.         else:
  1698.             inventory.append(contents[7])
  1699.  
  1700.     mbx.showinfo("Load Character", "Loaded!\nYour journey continues...")
  1701.     refrSTAT()
  1702.     refrINFO()
  1703.     refrINVT()
  1704.     refrSKIL()
  1705.     refrABIL()
  1706. #Lists for main program data
  1707. mainStats = [10, 10, 10, 10, 10, 10]
  1708. bonusStats = [0, 0, 0, 0, 0, 0]
  1709. savingThrows = [0, 0, 0]
  1710. health = [0, 10]
  1711. experience = [1, 0, 300]
  1712. info = ["name", "class", "deity", "race", "gender", 18, 170, "cm", 70, "kg", "brown", "black", "currency", 0]
  1713. skills = []
  1714. abilities = []
  1715. inventory = []
  1716. brackets5E = [0, 300, 900, 2700, 6500, 14000, 23000, 34000, 48000, 64000, 85000, 100000, 120000, 140000, 165000, 195000, 225000, 265000, 305000, 355000]
  1717. #Creation of base tk window
  1718. base = tk.Tk()
  1719. base.protocol("WM_DELETE_WINDOW", exitOverride)
  1720. #Declaration of fonts
  1721. ftSmall = tkf.Font(family = "Consolas", size = 8)
  1722. ftNormal = tkf.Font(family = "Consolas", size = 10)
  1723. ftNormUnd = tkf.Font(family = "Consolas", size = 10, underline = 1)
  1724. ftLarge = tkf.Font(family = "Consolas", size = 12)
  1725. ftTitle = tkf.Font(family = "Consolas", size = 12, weight = "bold", slant = "italic")
  1726. ftBigTitle = tkf.Font(family = "Consolas", size = 16, weight = "bold", slant = "italic")
  1727. ftName = tkf.Font(family = "Consolas", size = 16, weight = "bold")
  1728. ftSubtitle = tkf.Font(family = "Consolas", size = 12, slant = "italic")
  1729. ftDice = tkf.Font(family = "Consolas", size = 12, weight = "bold")
  1730. #Frame for stats
  1731. STATPnl = tk.Frame(base, bd = 4, relief = "groove")
  1732. STATPnl.grid(row = 1, column = 0, rowspan = 2, padx = 8, sticky = "n")
  1733. #Stats labels and buttons
  1734. STATTitl = tk.Label(STATPnl, text = "Stats", width = 8, bd = 4, relief = "raised", font = ftTitle)
  1735. LEVLLbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
  1736. LEVLVar = tk.BooleanVar()
  1737. LEVLVar.set(True)
  1738. LEVLChk = tk.Checkbutton(STATPnl, text = "5E XP", command = ChangeXP, variable = LEVLVar, font = ftNormal)
  1739. XPLbl = tk.Label(STATPnl, width = 16, relief = "ridge", font = ftLarge, anchor = "w")
  1740. XPPlusBtn = tk.Button(STATPnl, text = "+", command = XPUp, cursor = "hand2", font = ftNormal)
  1741.  
  1742. HPLbl = tk.Label(STATPnl, width = 12, relief = "ridge", font = ftLarge, anchor = "w")
  1743. HPPLUSBtn = tk.Button(STATPnl, text = "+", command = HPUp, cursor = "hand2", font = ftNormal)
  1744. HPMINSBtn = tk.Button(STATPnl, text = "-", command = HPDown, cursor = "hand2", font = ftNormal)
  1745.  
  1746. STRLbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
  1747. DEXLbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
  1748. CONLbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
  1749. INTLbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
  1750. WISLbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
  1751. CHALbl = tk.Label(STATPnl, width = 10, relief = "ridge", font = ftLarge)
  1752.  
  1753. STRBLbl = tk.Label(STATPnl, width = 4, relief = "ridge", font = ftLarge)
  1754. DEXBLbl = tk.Label(STATPnl, width = 4, relief = "ridge", font = ftLarge)
  1755. CONBLbl = tk.Label(STATPnl, width = 4, relief = "ridge", font = ftLarge)
  1756. INTBLbl = tk.Label(STATPnl, width = 4, relief = "ridge", font = ftLarge)
  1757. WISBLbl = tk.Label(STATPnl, width = 4, relief = "ridge", font = ftLarge)
  1758. CHABLbl = tk.Label(STATPnl, width = 4, relief = "ridge", font = ftLarge)
  1759.  
  1760. FORTLbl = tk.Label(STATPnl, width = 16, anchor = "e", relief = "ridge", font = ftNormal)
  1761. REFLLbl = tk.Label(STATPnl, width = 16, anchor = "e", relief = "ridge", font = ftNormal)
  1762. WILLLbl = tk.Label(STATPnl, width = 16, anchor = "e", relief = "ridge", font = ftNormal)
  1763. STATEDITBtn = tk.Button(STATPnl, text = "Edit Stats", width = 10, command = editStat, cursor = "hand2", font = ftSmall)
  1764. #Grid assignments of stats elements
  1765. STATTitl.grid(row = 0, columnspan = 3, pady = 4)
  1766. LEVLLbl.grid(row = 1, column = 0, columnspan = 3, pady = 2)
  1767. XPLbl.grid(row = 2, column = 0, columnspan = 2, padx = 4, pady = 2, sticky = "W")
  1768. XPPlusBtn.grid(row = 2, column = 2)
  1769.  
  1770. HPLbl.grid(row = 3, column = 0, padx = 4, pady = 2, sticky = "W")
  1771. HPPLUSBtn.grid(row = 3, column = 1, padx = 2)
  1772. HPMINSBtn.grid(row = 3, column = 2, padx = 2)
  1773.  
  1774. STRLbl.grid(row = 4, column = 0, padx = 4, pady = 2, sticky = "E")
  1775. DEXLbl.grid(row = 5, column = 0, padx = 4, pady = 2, sticky = "E")
  1776. CONLbl.grid(row = 6, column = 0, padx = 4, pady = 2, sticky = "E")
  1777. INTLbl.grid(row = 7, column = 0, padx = 4, pady = 2, sticky = "E")
  1778. WISLbl.grid(row = 8, column = 0, padx = 4, pady = 2, sticky = "E")
  1779. CHALbl.grid(row = 9, column = 0, padx = 4, pady = 2, sticky = "E")
  1780.  
  1781. STRBLbl.grid(row = 4, column = 1, columnspan = 2, padx = 4, pady = 2)
  1782. DEXBLbl.grid(row = 5, column = 1, columnspan = 2, padx = 4, pady = 2)
  1783. CONBLbl.grid(row = 6, column = 1, columnspan = 2, padx = 4, pady = 2)
  1784. INTBLbl.grid(row = 7, column = 1, columnspan = 2, padx = 4, pady = 2)
  1785. WISBLbl.grid(row = 8, column = 1, columnspan = 2, padx = 4, pady = 2)
  1786. CHABLbl.grid(row = 9, column = 1, columnspan = 2, padx = 4, pady = 2)
  1787.  
  1788. FORTLbl.grid(row = 10, columnspan = 3, padx = 4, pady = 2)
  1789. REFLLbl.grid(row = 11, columnspan = 3, padx = 4, pady = 2)
  1790. WILLLbl.grid(row = 12, columnspan = 3, padx = 4, pady = 2)
  1791. STATEDITBtn.grid(row = 13, column = 0, padx = 4, pady = 2)
  1792. LEVLChk.grid(row = 13, column = 1, columnspan = 2)
  1793.  
  1794. refrSTAT()
  1795. #Frame for information
  1796. INFOPnl = tk.Frame(base, bd = 4, relief = "groove")
  1797. INFOPnl.grid(row = 1, column = 1, sticky = "nw")
  1798. #Information labels and buttons
  1799. INFOTitl = tk.Label(INFOPnl, text ="Information", width = 32, bd = 4, relief = "raised", font = ftTitle)
  1800. INFOTitl.grid(row = 0, columnspan = 6, pady = 4)
  1801.  
  1802. NAMELbl = tk.Label(INFOPnl, width = 36, bd = 4, relief = "ridge", font = ftName)
  1803. CLSSLbl = tk.Label(INFOPnl, width = 24, relief = "ridge", font = ftLarge)
  1804. DETYLbl = tk.Label(INFOPnl, width = 24, relief = "ridge", font = ftLarge)
  1805. RACELbl = tk.Label(INFOPnl, width = 24, relief = "ridge", font = ftLarge)
  1806. GNDRLbl = tk.Label(INFOPnl, width = 24, relief = "ridge", font = ftLarge)
  1807. AYGELbl = tk.Label(INFOPnl, width = 8, relief = "ridge", font = ftLarge)
  1808. HGHTLbl = tk.Label(INFOPnl, width = 8, relief = "ridge", font = ftLarge)
  1809. WGHTLbl = tk.Label(INFOPnl, width = 8, relief = "ridge", font = ftLarge)
  1810. INFOEDITBtn = tk.Button(INFOPnl, text = "Edit Info", width = 8, command = editInfo, cursor = "hand2", font = ftSmall)
  1811. HAIRLbl = tk.Label(INFOPnl, width = 24, relief = "ridge", font = ftLarge)
  1812. EYESLbl = tk.Label(INFOPnl, width = 24, relief = "ridge", font = ftLarge)
  1813. MONYLbl = tk.Label(INFOPnl, width = 32, relief = "ridge", font = ftLarge)
  1814. MONYCHNGBtn = tk.Button(INFOPnl, text = "Credit/Debit", width = 12, command = changeMoney, cursor = "hand2", font = ftSmall)
  1815. #Grid assignments of information elements
  1816. NAMELbl.grid(row = 1, columnspan = 6, padx = 12, pady = 4)
  1817. CLSSLbl.grid(row = 2, column = 0, columnspan = 3, padx = 4)
  1818. DETYLbl.grid(row = 3, column = 0, columnspan = 3, padx = 4)
  1819. HAIRLbl.grid(row = 4, column = 0, columnspan = 3, padx = 4)
  1820. RACELbl.grid(row = 2, column = 3, columnspan = 3, pady = 4)
  1821. GNDRLbl.grid(row = 3, column = 3, columnspan = 3, pady = 4)
  1822. EYESLbl.grid(row = 4, column = 3, columnspan = 3, pady = 4)
  1823. AYGELbl.grid(row = 5, column = 1, pady = 4)
  1824. HGHTLbl.grid(row = 5, column = 2)
  1825. WGHTLbl.grid(row = 5, column = 3)
  1826. INFOEDITBtn.grid(row = 5, column = 4)
  1827. MONYLbl.grid(row = 6, column = 1, columnspan = 3)
  1828. MONYCHNGBtn.grid(row = 6, column = 4, pady = 11)
  1829.  
  1830. refrINFO()
  1831. #Frame for inventory
  1832. INVTPnl = tk.Frame(base, bd = 4, relief = "groove")
  1833. INVTPnl.grid(row = 2, column = 1, rowspan = 2, columnspan = 2, pady = 8, sticky = "w")
  1834. #Inventory elements
  1835. INVTTitl = tk.Label(INVTPnl, text = "Inventory", width = 24, bd = 4, relief = "raised", font = ftTitle)
  1836. INVTNEWWBtn = tk.Button(INVTPnl, text = "Create Item", width = 12, command = newItem, cursor = "hand2", font = ftSmall)
  1837. INVTEDITBtn = tk.Button(INVTPnl, text = "Edit Item", width = 12, command = editItem, cursor = "hand2", font = ftSmall)
  1838. INVTDELTBtn = tk.Button(INVTPnl, text = "Delete Item", width = 12, command = deleteItem, cursor = "hand2", font = ftSmall)
  1839. INVTINSPBtn = tk.Button(INVTPnl, text = "Inspect Item", width = 12, command = inspectItem, cursor = "hand2", font = ftSmall)
  1840. INVTSORTBtn = tk.Button(INVTPnl, text = "Sort Items", width = 12, command = sortItems, cursor = "hand2", font = ftSmall)
  1841. INVTLbl = tk.Label(INVTPnl, text = "Name\t\t\t\t\tCount\tWeight\tDice\tCharges\tEquipped", font = ftNormUnd)
  1842. INVTTxt = tk.Listbox(INVTPnl, height = 11, width = 80, cursor = "cross", font = ftNormal)
  1843. IVNTScr = tk.Scrollbar(INVTPnl, orient = "vertical", command = INVTTxt.yview)
  1844. INVTTxt.config(yscrollcommand = IVNTScr.set)
  1845. INVTENCMLbl = tk.Label(INVTPnl, text = "Encumberance:", width = 24, anchor = "w", relief = "ridge", font = ftNormal)
  1846. #Grid assignments of inventory elements
  1847. INVTTitl.grid(row = 0, column = 0, pady = 4)
  1848. INVTNEWWBtn.grid(row = 0, column = 1)
  1849. INVTEDITBtn.grid(row = 0, column = 2)
  1850. INVTDELTBtn.grid(row = 1, column = 2, columnspan = 2)
  1851. INVTINSPBtn.grid(row = 1, column = 1, columnspan = 2)
  1852. INVTSORTBtn.grid(row = 0, column = 3)
  1853. INVTLbl.grid(row = 2, columnspan = 4, sticky = "w")
  1854. INVTTxt.grid(row = 3, column = 0, columnspan = 4)
  1855. IVNTScr.grid(row = 2, column = 4, rowspan = 2, sticky = "ns")
  1856. INVTENCMLbl.grid(row = 4, columnspan = 5, pady = 2, sticky = "e")
  1857.  
  1858. refrINVT()
  1859. #Frame for dice
  1860. DICEPnl = tk.Frame(base, bd = 4, relief = "groove")
  1861. DICEPnl.grid(row = 3, column = 0)
  1862. #Dice labels and buttons
  1863. DICETitl = tk.Label(DICEPnl, text = "Dice", width = 8, bd = 4, relief = "raised", font = ftTitle)
  1864. DICELbl = tk.Label(DICEPnl, width = 13, text = "0 | d?", relief = "groove", font = ftDice)
  1865. DICEd2Btn = tk.Button(DICEPnl, width = 4, text = "Coin", command = rollDice(2), cursor = "hand2", font = ftNormal)
  1866. DICEd4Btn = tk.Button(DICEPnl, width = 4, text = "d4", command = rollDice(4), cursor = "hand2", font = ftNormal)
  1867. DICEd6Btn = tk.Button(DICEPnl, width = 4, text = "d6", command = rollDice(6), cursor = "hand2", font = ftNormal)
  1868. DICEd8Btn = tk.Button(DICEPnl, width = 4, text = "d8", command = rollDice(8), cursor = "hand2", font = ftNormal)
  1869. DICEd10Btn = tk.Button(DICEPnl, width = 4, text = "d10", command = rollDice(10), cursor = "hand2", font = ftNormal)
  1870. DICEd12Btn = tk.Button(DICEPnl, width = 4, text = "d12", command = rollDice(12), cursor = "hand2", font = ftNormal)
  1871. DICEd20Btn = tk.Button(DICEPnl, width = 4, text = "d20", command = rollDice(20), cursor = "hand2", font = ftNormal)
  1872. DICEd100Btn = tk.Button(DICEPnl, width = 4, text = "d100", command = rollDice(100), cursor = "hand2", font = ftNormal)
  1873. DICERstBtn = tk.Button(DICEPnl, width = 4, text = "Reset", command = rollDice(0), cursor = "hand2", font = ftNormal)
  1874. #Grid assignments of dice elements
  1875. DICETitl.grid(row = 0, column = 0, columnspan = 3, pady = 4)
  1876. DICELbl.grid(row = 1, column = 0, columnspan = 3, padx = 38, pady = 4)
  1877. DICEd2Btn.grid(row = 2, column = 0, pady = 2)
  1878. DICEd4Btn.grid(row = 2, column = 1)
  1879. DICEd6Btn.grid(row = 2, column = 2)
  1880. DICEd8Btn.grid(row = 3, column = 0, pady = 2)
  1881. DICEd10Btn.grid(row = 3, column = 1)
  1882. DICEd12Btn.grid(row = 3, column = 2)
  1883. DICERstBtn.grid(row = 4, column = 0, pady = 2)
  1884. DICEd20Btn.grid(row = 4, column = 1)
  1885. DICEd100Btn.grid(row = 4, column = 2)
  1886. #Panel for skills
  1887. SKILPnl = tk.Frame(base, bd = 4, relief = "groove")
  1888. SKILPnl.grid(row = 2, column = 3, rowspan = 2, padx = 8, pady = 8, sticky = "ne")
  1889. #Skill elements
  1890. SKILTitl = tk.Label(SKILPnl, text = "Skills", width = 8, bd = 4, relief = "raised", font = ftTitle)
  1891. SKILTxt = tk.Listbox(SKILPnl, height = 9, width = 32, cursor = "cross", font = ftNormal)
  1892. SKILScrV = tk.Scrollbar(SKILPnl, orient = "vertical", command = SKILTxt.yview)
  1893. SKILScrH = tk.Scrollbar(SKILPnl, orient = "horizontal", command = SKILTxt.xview)
  1894. SKILTxt.config(yscrollcommand = SKILScrV.set, xscrollcommand = SKILScrH.set)
  1895. SKILNEWWBtn = tk.Button(SKILPnl, text = "Create Skill", width = 12, command = newSkill, cursor = "hand2", font = ftSmall)
  1896. SKILEDITBtn = tk.Button(SKILPnl, text = "Edit Skill", width = 12, command = editSkill, cursor = "hand2", font = ftSmall)
  1897. SKILDELTBtn = tk.Button(SKILPnl, text = "Delete Skill", width = 12, command = deleteSkill, cursor = "hand2", font = ftSmall)
  1898. SKILSORTBtn = tk.Button(SKILPnl, text = "Sort Skills", width = 12, command = sortSkills, cursor = "hand2", font = ftSmall)
  1899. SKILSCORVar = tk.BooleanVar()
  1900. SKILSCORVar.set(False)
  1901. SKILSCORSwt = tk.Checkbutton(SKILPnl, text = "Apply +/- Skills To Stats", command = changeScores, variable = SKILSCORVar, font = ftSmall)
  1902. SKILSCORBtn = tk.Button(SKILPnl, text = "?", command = showPrefixInfo, cursor = "hand2", font = ftSmall)
  1903. #Grid assignments of skill elements
  1904. SKILTitl.grid(row = 0, columnspan = 3, pady = 4)
  1905. SKILTxt.grid(row = 4, column = 0, columnspan = 2)
  1906. SKILScrV.grid(row = 4, column = 2, rowspan = 2, sticky = "ns")
  1907. SKILScrH.grid(row = 5, column = 0, columnspan = 2, pady = 2, sticky = "we")
  1908. SKILNEWWBtn.grid(row = 1, column = 0)
  1909. SKILEDITBtn.grid(row = 1, column = 1)
  1910. SKILDELTBtn.grid(row = 2, column = 0)
  1911. SKILSORTBtn.grid(row = 2, column = 1)
  1912. SKILSCORSwt.grid(row = 3, column = 0, columnspan = 2, padx = 8, sticky = "w")
  1913. SKILSCORBtn.grid(row = 3, column = 1, padx = 8, sticky = "e")
  1914.  
  1915. refrSKIL()
  1916. #Frame for abilities
  1917. ABILPnl = tk.Frame(base, bd = 4, relief = "groove")
  1918. ABILPnl.grid(row = 1, column = 2, columnspan = 2, padx = 8, sticky = "n")
  1919. #Ability elements
  1920. ABILTitl = tk.Label(ABILPnl, text = "Abilities", width = 16, bd = 4, relief = "raised", font = ftTitle)
  1921. ABILTxt = tk.Listbox(ABILPnl, height = 10, width = 48, cursor = "cross", font = ftNormal)
  1922. ABILScrV = tk.Scrollbar(ABILPnl, orient = "vertical", command = ABILTxt.yview)
  1923. ABILScrH = tk.Scrollbar(ABILPnl, orient = "horizontal", command = ABILTxt.xview)
  1924. ABILTxt.config(yscrollcommand = ABILScrV.set, xscrollcommand = ABILScrH.set)
  1925. ABILNEWWBtn = tk.Button(ABILPnl, text = "Create Ability", width = 12, command = newAbility, cursor = "hand2", font = ftSmall)
  1926. ABILEDITBtn = tk.Button(ABILPnl, text = "Edit Ability", width = 12, command = editAbility, cursor = "hand2", font = ftSmall)
  1927. ABILDELTBtn = tk.Button(ABILPnl, text = "Delete Ability", width = 12, command = deleteAbility, cursor = "hand2", font = ftSmall)
  1928. ABILINSPBtn = tk.Button(ABILPnl, text = "Inspect Ability", width = 12, command = inspectAbility, cursor = "hand2", font = ftSmall)
  1929. ABILSORTBtn = tk.Button(ABILPnl, text = "Sort Abilities", width = 12, command = sortAbilities, cursor = "hand2", font = ftSmall)
  1930. #Grid assignments of ability elements
  1931. ABILTitl.grid(row = 0, columnspan = 4, pady = 4)
  1932. ABILTxt.grid(row = 3, column = 0, columnspan = 3)
  1933. ABILScrV.grid(row = 3, column = 3, rowspan = 2, sticky = "ns")
  1934. ABILScrH.grid(row = 4, columnspan = 3, sticky = "we")
  1935. ABILNEWWBtn.grid(row = 1, column = 0, sticky = "e")
  1936. ABILEDITBtn.grid(row = 1, column = 1, sticky = "e")
  1937. ABILSORTBtn.grid(row = 1, column = 2, sticky = "e")
  1938. ABILINSPBtn.grid(row = 2, column = 0, columnspan = 2)
  1939. ABILDELTBtn.grid(row = 2, column = 1, columnspan = 2)
  1940. #Frame for menu
  1941. MENUPnl = tk.Frame(base, bd = 4, relief = "groove")
  1942. MENUPnl.grid(row = 0, columnspan = 4, pady = 8)
  1943. #Menu labels and buttons
  1944. MENUTitl = tk.Label(MENUPnl, text = "C²'s D&D Character Sheet", width = 64, bd = 4, relief = "raised", font = ftBigTitle)
  1945. MENUNEWWBtn = tk.Button(MENUPnl, text = "New Character", width = 16, command = newCharacter, cursor = "hand2", font = ftLarge)
  1946. MENUSAVEBtn = tk.Button(MENUPnl, text = "Save Character", width = 16, command = saveCharacter, cursor = "hand2", font = ftLarge)
  1947. MENULOADBtn = tk.Button(MENUPnl, text = "Load Character", width = 16, command = loadCharacter, cursor = "hand2", font = ftLarge)
  1948. MENUVERS = tk.Label(MENUPnl, text = "Version 1.2.2", width = 16, bd = 4, relief = "ridge", font = ftSubtitle)
  1949. #Grid assignments of menu elements
  1950. MENUTitl.grid(row = 0, columnspan = 4, padx = 16, pady = 4)
  1951. MENUNEWWBtn.grid(row = 1, column = 0, pady = 4)
  1952. MENUSAVEBtn.grid(row = 1, column = 1)
  1953. MENULOADBtn.grid(row = 1, column = 2)
  1954. MENUVERS.grid(row = 1, column = 3)
  1955. #Initialization of main window and final settings
  1956. base.title("DnD Character Sheet")
  1957. base.resizable(False, False)
  1958. base.mainloop()
RAW Paste Data