Ugh, I think I did it

This commit is contained in:
Mike A. Trethewey
2020-03-10 17:23:23 -07:00
parent 58bb9fffba
commit e901f0f1f5
12 changed files with 339 additions and 254 deletions

9
Gui.py
View File

@@ -22,6 +22,7 @@ from GuiUtils import set_icon
from Main import __version__ as ESVersion from Main import __version__ as ESVersion
from source.classes.BabelFish import BabelFish from source.classes.BabelFish import BabelFish
from source.classes.Empty import Empty
def guiMain(args=None): def guiMain(args=None):
@@ -152,13 +153,15 @@ def guiMain(args=None):
self.fish = BabelFish(lang=lang) self.fish = BabelFish(lang=lang)
# bottom of window: Open Output Directory, Open Documentation (if exists) # bottom of window: Open Output Directory, Open Documentation (if exists)
self.frames["bottom"] = bottom_frame(self, self, None) self.pages["bottom"] = Empty()
self.pages["bottom"].pages = {}
self.pages["bottom"].pages["content"] = bottom_frame(self, self, None)
## Save Settings Button ## Save Settings Button
savesettingsButton = Button(self.frames["bottom"], text='Save Settings to File', command=lambda: save_settings_from_gui(True)) savesettingsButton = Button(self.pages["bottom"].pages["content"], text='Save Settings to File', command=lambda: save_settings_from_gui(True))
savesettingsButton.pack(side=RIGHT) savesettingsButton.pack(side=RIGHT)
# set bottom frame to main window # set bottom frame to main window
self.frames["bottom"].pack(side=BOTTOM, fill=X, padx=5, pady=5) self.pages["bottom"].pages["content"].pack(side=BOTTOM, fill=X, padx=5, pady=5)
self.outputPath = StringVar() self.outputPath = StringVar()
self.randomSprite = BooleanVar() self.randomSprite = BooleanVar()

View File

@@ -83,7 +83,7 @@
"randomizer.enemizer.enemydamage": "Enemy Damage", "randomizer.enemizer.enemydamage": "Enemy Damage",
"randomizer.enemizer.enemydamage.default": "Vanilla", "randomizer.enemizer.enemydamage.default": "Vanilla",
"randomizer.enemizer.enemydamage.shuffled": "Shuffled", "randomizer.enemizer.enemydamage.shuffled": "Shuffled",
"randomizer.enemizer.enemydamage.choas": "Chaos", "randomizer.enemizer.enemydamage.chaos": "Chaos",
"randomizer.enemizer.enemyhealth": "Enemy Health", "randomizer.enemizer.enemyhealth": "Enemy Health",
"randomizer.enemizer.enemyhealth.default": "Vanilla", "randomizer.enemizer.enemyhealth.default": "Vanilla",
@@ -260,13 +260,13 @@
"randomizer.multiworld.names": "Player names", "randomizer.multiworld.names": "Player names",
"bottom.seed": "Seed #", "bottom.content.seed": "Seed #",
"bottom.generationcount": "Count", "bottom.content.generationcount": "Count",
"bottom.go": "Generate Patched Rom", "bottom.content.go": "Generate Patched Rom",
"bottom.dialog.error": "Error while creating seed", "bottom.content.dialog.error": "Error while creating seed",
"bottom.dialog.success": "Success", "bottom.content.dialog.success": "Success",
"bottom.dialog.success.message": "Rom created successfully.", "bottom.content.dialog.success.message": "Rom created successfully.",
"bottom.outputdir": "Open Output Directory", "bottom.content.outputdir": "Open Output Directory",
"bottom.docs": "Open Documentation" "bottom.content.docs": "Open Documentation"
} }
} }

View File

@@ -11,13 +11,13 @@
"selectbox": { "selectbox": {
"side": "right" "side": "right"
}, },
"default": "Basic" "default": "basic"
}, },
"options": { "options": [
"Vanilla": "vanilla", "vanilla",
"Basic": "basic", "basic",
"Crossed": "crossed" "crossed"
} ]
}, },
"experimental": { "experimental": {
"type": "checkbox", "type": "checkbox",
@@ -37,13 +37,13 @@
"selectbox": { "selectbox": {
"side": "right" "side": "right"
}, },
"default": "Auto" "default": "default"
}, },
"options": { "options": [
"Auto": "default", "default",
"Off": "off", "off",
"On": "on", "on",
"On Compass Pickup": "pickup" "pickup"
} ]
} }
} }

View File

@@ -21,11 +21,11 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"Vanilla": "none", "none",
"Shuffled": "shuffled", "shuffled",
"Chaos": "chaos" "chaos"
} ]
}, },
"bossshuffle": { "bossshuffle": {
"type": "selectbox", "type": "selectbox",
@@ -40,12 +40,12 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"Vanilla": "none", "none",
"Basic": "basic", "basic",
"Shuffled": "shuffled", "shuffled",
"Chaos": "chaos" "chaos"
} ]
} }
}, },
"rightEnemizerFrame": { "rightEnemizerFrame": {
@@ -62,11 +62,11 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"Vanilla": "default", "default",
"Shuffled": "shuffled", "shuffled",
"Chaos": "chaos" "chaos"
} ]
}, },
"enemyhealth": { "enemyhealth": {
"type": "selectbox", "type": "selectbox",
@@ -81,13 +81,13 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"Vanilla": "default", "default",
"Easy": "easy", "easy",
"Normal": "normal", "normal",
"Hard": "hard", "hard",
"Expert": "expert" "expert"
} ]
} }
} }
} }

View File

@@ -21,20 +21,20 @@
"label": { "side": "left" }, "label": { "side": "left" },
"selectbox": { "side": "right" } "selectbox": { "side": "right" }
}, },
"options": { "options": [
"Vanilla": "vanilla", "vanilla",
"Simple": "simple", "simple",
"Restricted": "restricted", "restricted",
"Full": "full", "full",
"Crossed": "crossed", "crossed",
"Insanity": "insanity", "insanity",
"Restricted (Legacy)": "restricted_legacy", "restricted_legacy",
"Full (Legacy)": "full_legacy", "full_legacy",
"Madness (Legacy)": "madness_legacy", "madness_legacy",
"Insanity (Legacy)": "insanity_legacy", "insanity_legacy",
"Dungeons + Full": "dungeonsfull", "dungeonsfull",
"Dungeons + Simple": "dungeonssimple" "dungeonssimple"
} ]
} }
} }
} }

View File

@@ -18,7 +18,7 @@
"label": { "label": {
"text": "L/R Quickswapping" "text": "L/R Quickswapping"
} }
} }
}, },
"leftRomOptionsFrame": { "leftRomOptionsFrame": {
"heartcolor": { "heartcolor": {
@@ -34,13 +34,13 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"Red": "red", "red",
"Blue": "blue", "blue",
"Green": "green", "green",
"Yellow": "yellow", "yellow",
"Random": "random" "random"
} ]
}, },
"heartbeep": { "heartbeep": {
"type": "selectbox", "type": "selectbox",
@@ -54,15 +54,15 @@
"selectbox": { "selectbox": {
"side": "right" "side": "right"
}, },
"default": "Normal" "default": "normal"
}, },
"options": { "options": [
"Double": "double", "double",
"Normal": "normal", "normal",
"Half": "half", "half",
"Quarter": "quarter", "quarter",
"Off": "off" "off"
} ]
} }
}, },
"rightRomOptionsFrame": { "rightRomOptionsFrame": {
@@ -78,16 +78,16 @@
"selectbox": { "selectbox": {
"side": "right" "side": "right"
}, },
"default": "Normal" "default": "normal"
}, },
"options": { "options": [
"Instant": "instant", "instant",
"Quadruple": "quadruple", "quadruple",
"Triple": "triple", "triple",
"Double": "double", "double",
"Normal": "normal", "normal",
"Half": "half" "half"
} ]
}, },
"owpalettes": { "owpalettes": {
"type": "selectbox", "type": "selectbox",
@@ -102,11 +102,11 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"Default": "default", "default",
"Random": "random", "random",
"Blackout": "blackout" "blackout"
} ]
}, },
"uwpalettes": { "uwpalettes": {
"type": "selectbox", "type": "selectbox",
@@ -121,11 +121,11 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"Default": "default", "default",
"Random": "random", "random",
"Blackout": "blackout" "blackout"
} ]
} }
} }
} }

View File

@@ -36,10 +36,10 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"Ask Me": "ask", "ask",
"Always": "always", "always",
"Never": "never" "never"
} ]
} }
} }

View File

@@ -20,14 +20,14 @@
"selectbox": { "selectbox": {
"side": "right" "side": "right"
}, },
"default": "Open" "default": "open"
}, },
"options": { "options": [
"Standard": "standard", "standard",
"Open": "open", "open",
"Inverted": "inverted", "inverted",
"Retro": "retro" "retro"
} ]
}, },
"logiclevel": { "logiclevel": {
"type": "selectbox", "type": "selectbox",
@@ -42,11 +42,11 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"No Glitches": "noglitches", "noglitches",
"Minor Glitches": "minorglitches", "minorglitches",
"No Logic": "nologic" "nologic"
} ]
}, },
"goal": { "goal": {
"type": "selectbox", "type": "selectbox",
@@ -61,13 +61,13 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"Defeat Ganon": "ganon", "ganon",
"Master Sword Pedestal": "pedestal", "pedestal",
"All Dungeons": "dungeons", "dungeons",
"Triforce Hunt": "triforcehunt", "triforcehunt",
"Crystals": "crystals" "crystals"
} ]
}, },
"crystals_gt": { "crystals_gt": {
"type": "selectbox", "type": "selectbox",
@@ -82,17 +82,17 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"0": "0", "0",
"1": "1", "1",
"2": "2", "2",
"3": "3", "3",
"4": "4", "4",
"5": "5", "5",
"6": "6", "6",
"7": "7", "7",
"Random": "random" "random"
} ]
}, },
"crystals_ganon": { "crystals_ganon": {
"type": "selectbox", "type": "selectbox",
@@ -107,17 +107,17 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"0": "0", "0",
"1": "1", "1",
"2": "2", "2",
"3": "3", "3",
"4": "4", "4",
"5": "5", "5",
"6": "6", "6",
"7": "7", "7",
"Random": "random" "random"
} ]
}, },
"weapons": { "weapons": {
"type": "selectbox", "type": "selectbox",
@@ -132,12 +132,12 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"Randomized": "random", "random",
"Assured": "assured", "assured",
"Swordless": "swordless", "swordless",
"Vanilla": "vanilla" "vanilla"
} ]
} }
}, },
"rightItemFrame": { "rightItemFrame": {
@@ -154,11 +154,11 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"Normal": "normal", "normal",
"Hard": "hard", "hard",
"Expert": "expert" "expert"
} ]
}, },
"itemfunction": { "itemfunction": {
"type": "selectbox", "type": "selectbox",
@@ -173,11 +173,11 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"Normal": "normal", "normal",
"Hard": "hard", "hard",
"Expert": "expert" "expert"
} ]
}, },
"timer": { "timer": {
"type": "selectbox", "type": "selectbox",
@@ -192,14 +192,14 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"No Timer": "none", "none",
"Stopwatch": "display", "display",
"Timed": "timed", "timed",
"Timed OHKO": "timed-ohko", "timed-ohko",
"OHKO": "ohko", "ohko",
"Timed Countdown": "timed-countdown" "timed-countdown"
} ]
}, },
"progressives": { "progressives": {
"type": "selectbox", "type": "selectbox",
@@ -214,11 +214,11 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"On": "on", "on",
"Off": "off", "off",
"Random": "random" "random"
} ]
}, },
"accessibility": { "accessibility": {
"type": "selectbox", "type": "selectbox",
@@ -233,11 +233,11 @@
"side": "right" "side": "right"
} }
}, },
"options": { "options": [
"100% Inventory": "items", "items",
"100% Locations": "locations", "locations",
"Beatable": "none" "none"
} ]
}, },
"sortingalgo": { "sortingalgo": {
"type": "selectbox", "type": "selectbox",
@@ -251,17 +251,17 @@
"selectbox": { "selectbox": {
"side": "right" "side": "right"
}, },
"default": "Balanced" "default": "balanced"
}, },
"options": { "options": [
"Freshness": "freshness", "freshness",
"Flood": "flood", "flood",
"VT8.21": "vt21", "vt21",
"VT8.22": "vt22", "vt22",
"VT8.25": "vt25", "vt25",
"VT8.26": "vt26", "vt26",
"Balanced": "balanced" "balanced"
} ]
} }
} }
} }

View File

@@ -110,5 +110,11 @@ SETTINGSTOPROCESS = {
"usecustompool": "custom", "usecustompool": "custom",
"saveonexit": "saveonexit" "saveonexit": "saveonexit"
} }
},
"bottom": {
"content": {
"seed": "seed",
"generationcount": "count"
}
} }
} }

View File

@@ -36,11 +36,12 @@ def bottom_frame(self, parent, args=None):
savedSeed = parent.settings["seed"] savedSeed = parent.settings["seed"]
self.widgets[widget].storageVar = StringVar(value=savedSeed) self.widgets[widget].storageVar = StringVar(value=savedSeed)
# textbox # textbox
self.widgets[widget].type = "textbox"
self.widgets[widget].pieces["textbox"] = Entry(self.widgets[widget].pieces["frame"], width=15, textvariable=self.widgets[widget].storageVar) self.widgets[widget].pieces["textbox"] = Entry(self.widgets[widget].pieces["frame"], width=15, textvariable=self.widgets[widget].storageVar)
self.widgets[widget].pieces["textbox"].pack(side=LEFT) self.widgets[widget].pieces["textbox"].pack(side=LEFT)
def saveSeed(caller,_,mode): def saveSeed(caller,_,mode):
savedSeed = self.seedVar.get() savedSeed = self.widgets["seed"].storageVar.get()
parent.settings["seed"] = int(savedSeed) if savedSeed.isdigit() else None parent.settings["seed"] = int(savedSeed) if savedSeed.isdigit() else None
self.widgets[widget].storageVar.trace_add("write",saveSeed) self.widgets[widget].storageVar.trace_add("write",saveSeed)
# frame: pack # frame: pack
@@ -91,6 +92,7 @@ def bottom_frame(self, parent, args=None):
self.widgets[widget].pieces = {} self.widgets[widget].pieces = {}
# button # button
self.widgets[widget].type = "button"
self.widgets[widget].pieces["button"] = Button(self, text='Generate Patched Rom', command=generateRom) self.widgets[widget].pieces["button"] = Button(self, text='Generate Patched Rom', command=generateRom)
# button: pack # button: pack
self.widgets[widget].pieces["button"].pack(side=LEFT) self.widgets[widget].pieces["button"].pack(side=LEFT)
@@ -114,22 +116,26 @@ def bottom_frame(self, parent, args=None):
self.widgets[widget].storageVar = StringVar(value=parent.settings["outputpath"]) self.widgets[widget].storageVar = StringVar(value=parent.settings["outputpath"])
# button # button
self.widgets[widget].type = "button"
self.widgets[widget].pieces["button"] = Button(self, text='Open Output Directory', command=open_output) self.widgets[widget].pieces["button"] = Button(self, text='Open Output Directory', command=open_output)
# button: pack # button: pack
self.widgets[widget].pieces["button"].pack(side=RIGHT) self.widgets[widget].pieces["button"].pack(side=RIGHT)
## Documentation Button ## Documentation Button
# widget ID
widget = "docs"
# Empty object
self.widgets[widget] = Empty()
# pieces
self.widgets[widget].pieces = {}
# button
self.widgets[widget].type = "button"
self.widgets[widget].selectbox = Empty()
self.widgets[widget].selectbox.storageVar = Empty()
if os.path.exists(local_path('README.html')): if os.path.exists(local_path('README.html')):
def open_readme(): def open_readme():
open_file(local_path('README.html')) open_file(local_path('README.html'))
# widget ID
widget = "docs"
# Empty object
self.widgets[widget] = Empty()
# pieces
self.widgets[widget].pieces = {}
# button
self.widgets[widget].pieces["button"] = Button(self, text='Open Documentation', command=open_readme) self.widgets[widget].pieces["button"] = Button(self, text='Open Documentation', command=open_readme)
# button: pack # button: pack
self.widgets[widget].pieces["button"].pack(side=RIGHT) self.widgets[widget].pieces["button"].pack(side=RIGHT)

View File

@@ -24,36 +24,46 @@ def loadcliargs(gui, args, settings=None):
for subpage in options[mainpage]: for subpage in options[mainpage]:
# Cycle through each widget # Cycle through each widget
for widget in options[mainpage][subpage]: for widget in options[mainpage][subpage]:
# Get the value and set it if widget in gui.pages[mainpage].pages[subpage].widgets:
arg = options[mainpage][subpage][widget] thisType = ""
label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget) # Get the value and set it
if hasattr(gui.pages[mainpage].pages[subpage].widgets[widget],"type"): arg = options[mainpage][subpage][widget]
type = gui.pages[mainpage].pages[subpage].widgets[widget].type label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
if type == "checkbox": if hasattr(gui.pages[mainpage].pages[subpage].widgets[widget],"type"):
gui.pages[mainpage].pages[subpage].widgets[widget].checkbox.configure(text=label) thisType = gui.pages[mainpage].pages[subpage].widgets[widget].type
elif type == "selectbox": if thisType == "checkbox":
gui.pages[mainpage].pages[subpage].widgets[widget].label.configure(text=label) gui.pages[mainpage].pages[subpage].widgets[widget].checkbox.configure(text=label)
elif type == "spinbox": elif thisType == "selectbox":
gui.pages[mainpage].pages[subpage].widgets[widget].label.configure(text=label) theseOptions = gui.pages[mainpage].pages[subpage].widgets[widget].selectbox.options
gui.pages[mainpage].pages[subpage].widgets[widget].storageVar.set(args[arg]) gui.pages[mainpage].pages[subpage].widgets[widget].label.configure(text=label)
# If we're on the Game Options page and it's not about Hints i = 0
if subpage == "gameoptions" and not widget == "hints": for value in theseOptions["values"]:
# Check if we've got settings gui.pages[mainpage].pages[subpage].widgets[widget].selectbox.options["labels"][i] = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget + '.' + value)
# Check if we've got the widget in Adjust settings i += 1
hasSettings = settings is not None for i in range(0, len(theseOptions["values"])):
hasWidget = ("adjust." + widget) in settings if hasSettings else None gui.pages[mainpage].pages[subpage].widgets[widget].selectbox["menu"].entryconfigure(i, label=theseOptions["labels"][i])
label = fish.translate("gui","gui","adjust." + widget) gui.pages[mainpage].pages[subpage].widgets[widget].selectbox.options = theseOptions
if ("adjust." + widget) in label: elif thisType == "spinbox":
label = fish.translate("gui","gui","randomizer.gameoptions." + widget) gui.pages[mainpage].pages[subpage].widgets[widget].label.configure(text=label)
if hasattr(gui.pages["adjust"].content.widgets[widget],"type"): gui.pages[mainpage].pages[subpage].widgets[widget].storageVar.set(args[arg])
type = gui.pages["adjust"].content.widgets[widget].type # If we're on the Game Options page and it's not about Hints
if type == "checkbox": if subpage == "gameoptions" and not widget == "hints":
gui.pages["adjust"].content.widgets[widget].checkbox.configure(text=label) # Check if we've got settings
elif type == "selectbox": # Check if we've got the widget in Adjust settings
gui.pages["adjust"].content.widgets[widget].label.configure(text=label) hasSettings = settings is not None
if hasWidget is None: hasWidget = ("adjust." + widget) in settings if hasSettings else None
# If we've got a Game Options val and we don't have an Adjust val, use the Game Options val label = fish.translate("gui","gui","adjust." + widget)
gui.pages["adjust"].content.widgets[widget].storageVar.set(args[arg]) if ("adjust." + widget) in label:
label = fish.translate("gui","gui","randomizer.gameoptions." + widget)
if hasattr(gui.pages["adjust"].content.widgets[widget],"type"):
type = gui.pages["adjust"].content.widgets[widget].type
if type == "checkbox":
gui.pages["adjust"].content.widgets[widget].checkbox.configure(text=label)
elif type == "selectbox":
gui.pages["adjust"].content.widgets[widget].label.configure(text=label)
if hasWidget is None:
# If we've got a Game Options val and we don't have an Adjust val, use the Game Options val
gui.pages["adjust"].content.widgets[widget].storageVar.set(args[arg])
# Get EnemizerCLI setting # Get EnemizerCLI setting
mainpage = "randomizer" mainpage = "randomizer"
@@ -105,47 +115,53 @@ def loadcliargs(gui, args, settings=None):
# Get Seed ID # Get Seed ID
mainpage = "bottom" mainpage = "bottom"
subpage = "content"
widget = "seed" widget = "seed"
setting = "seed" setting = "seed"
if args[setting]: if args[setting]:
gui.frames[mainpage].widgets[widget].storageVar.set(str(args[setting])) gui.pages[mainpage].widgets[widget].storageVar.set(str(args[setting]))
# set textbox/frame label # set textbox/frame label
label = fish.translate("gui","gui",mainpage + '.' + widget) label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
gui.frames[mainpage].widgets[widget].pieces["frame"].label.configure(text=label) gui.pages[mainpage].pages[subpage].widgets[widget].pieces["frame"].label.configure(text=label)
# Get number of generations to run # Get number of generations to run
mainpage = "bottom" mainpage = "bottom"
subpage = "content"
widget = "generationcount" widget = "generationcount"
setting = "count" setting = "count"
if args[setting]: if args[setting]:
gui.frames[mainpage].widgets[widget].storageVar.set(str(args[setting])) gui.pages[mainpage].pages[subpage].widgets[widget].storageVar.set(str(args[setting]))
# set textbox/frame label # set textbox/frame label
label = fish.translate("gui","gui",mainpage + '.' + widget) label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
gui.frames[mainpage].widgets[widget].label.configure(text=label) gui.pages[mainpage].pages[subpage].widgets[widget].label.configure(text=label)
# Set Generate button # Set Generate button
mainpage = "bottom" mainpage = "bottom"
subpage = "content"
widget = "go" widget = "go"
# set textbox/frame label # set textbox/frame label
label = fish.translate("gui","gui",mainpage + '.' + widget) label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
gui.frames[mainpage].widgets[widget].pieces["button"].configure(text=label) gui.pages[mainpage].pages[subpage].widgets[widget].pieces["button"].configure(text=label)
# Set Output Directory button # Set Output Directory button
mainpage = "bottom" mainpage = "bottom"
subpage = "content"
widget = "outputdir" widget = "outputdir"
# set textbox/frame label # set textbox/frame label
label = fish.translate("gui","gui",mainpage + '.' + widget) label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
gui.frames[mainpage].widgets[widget].pieces["button"].configure(text=label) gui.pages[mainpage].pages[subpage].widgets[widget].pieces["button"].configure(text=label)
# Get output path # Get output path
gui.frames[mainpage].widgets[widget].storageVar.set(args["outputpath"]) gui.pages[mainpage].pages[subpage].widgets[widget].storageVar.set(args["outputpath"])
# Set Output Directory button # Set Documentation button
mainpage = "bottom" mainpage = "bottom"
subpage = "content"
widget = "docs" widget = "docs"
# set textbox/frame label if widget in gui.pages[mainpage].pages[subpage].widgets:
label = fish.translate("gui","gui",mainpage + '.' + widget) if "button" in gui.pages[mainpage].pages[subpage].widgets[widget].pieces:
if widget in gui.frames[mainpage].widgets: # set textbox/frame label
gui.frames[mainpage].widgets[widget].pieces["button"].configure(text=label) label = fish.translate("gui","gui",mainpage + '.' + subpage + '.' + widget)
gui.pages[mainpage].pages[subpage].widgets[widget].pieces["button"].configure(text=label)
# Figure out Sprite Selection # Figure out Sprite Selection
def sprite_setter(spriteObject): def sprite_setter(spriteObject):

View File

@@ -28,27 +28,81 @@ def make_checkbox(self, parent, label, storageVar, manager, managerAttrs):
# Make an OptionMenu with a label and pretty option labels # Make an OptionMenu with a label and pretty option labels
def make_selectbox(self, parent, label, options, storageVar, manager, managerAttrs): def make_selectbox(self, parent, label, options, storageVar, manager, managerAttrs):
def change_storage(*args):
self.storageVar.set(options[self.labelVar.get()])
def change_selected(*args):
keys = options.keys()
vals = options.values()
keysList = list(keys)
valsList = list(vals)
self.labelVar.set(keysList[valsList.index(str(self.storageVar.get()))])
self = Frame(parent, name="selectframe-" + label.lower()) self = Frame(parent, name="selectframe-" + label.lower())
self.storageVar = storageVar
self.storageVar.trace_add("write",change_selected) labels = options
if isinstance(options,dict):
labels = options.keys()
self.labelVar = StringVar() self.labelVar = StringVar()
self.storageVar = storageVar
self.selectbox = OptionMenu(self, self.labelVar, *labels)
self.selectbox.options = {}
if isinstance(options,dict):
self.selectbox.options["labels"] = list(options.keys())
self.selectbox.options["values"] = list(options.values())
else:
self.selectbox.options["labels"] = ["" for i in range(0,len(options))]
self.selectbox.options["values"] = options
def change_thing(thing, *args):
labels = self.selectbox.options["labels"]
values = self.selectbox.options["values"]
check = ""
lbl = ""
val = ""
idx = 0
if thing == "storage":
check = self.labelVar.get()
elif thing == "label":
check = self.storageVar.get()
if check in labels:
idx = labels.index(check)
if check in values:
idx = values.index(check)
lbl = labels[idx]
val = values[idx]
if thing == "storage":
self.storageVar.set(val)
elif thing == "label":
self.labelVar.set(lbl)
self.selectbox["menu"].entryconfigure(idx,label=lbl)
self.selectbox.configure(state="active")
def change_storage(*args):
change_thing("storage", *args)
def change_selected(*args):
change_thing("label", *args)
self.storageVar.trace_add("write",change_selected)
self.labelVar.trace_add("write",change_storage) self.labelVar.trace_add("write",change_storage)
self.label = Label(self, text=label) self.label = Label(self, text=label)
if managerAttrs is not None and "label" in managerAttrs: if managerAttrs is not None and "label" in managerAttrs:
self.label.pack(managerAttrs["label"]) self.label.pack(managerAttrs["label"])
else: else:
self.label.pack() self.label.pack()
self.selectbox = OptionMenu(self, self.labelVar, *options.keys())
self.selectbox.config(width=20) self.selectbox.config(width=20)
self.labelVar.set(managerAttrs["default"] if "default" in managerAttrs else list(options.keys())[0]) idx = 0
default = self.selectbox.options["values"][idx]
if "default" in managerAttrs:
default = managerAttrs["default"]
labels = self.selectbox.options["labels"]
values = self.selectbox.options["values"]
if default in values:
idx = values.index(default)
default = labels[idx]
self.labelVar.set(default)
self.selectbox["menu"].entryconfigure(idx,label=default)
if managerAttrs is not None and "selectbox" in managerAttrs: if managerAttrs is not None and "selectbox" in managerAttrs:
self.selectbox.pack(managerAttrs["selectbox"]) self.selectbox.pack(managerAttrs["selectbox"])
else: else: