From c848792c69a3fb1d223e3942504a7543d47bd733 Mon Sep 17 00:00:00 2001 From: "Mike A. Trethewey" Date: Wed, 19 Feb 2020 01:29:48 -0800 Subject: [PATCH] JSONify Multiworld options --- gui/randomize/multiworld.py | 25 ++++++------------- .../app/gui/randomize/multiworld/widgets.json | 16 ++++++++++++ 2 files changed, 24 insertions(+), 17 deletions(-) create mode 100644 resources/app/gui/randomize/multiworld/widgets.json diff --git a/gui/randomize/multiworld.py b/gui/randomize/multiworld.py index 4612b852..e7808e48 100644 --- a/gui/randomize/multiworld.py +++ b/gui/randomize/multiworld.py @@ -1,5 +1,7 @@ from tkinter import ttk, StringVar, Entry, Frame, Label, Spinbox, N, E, W, X, LEFT, RIGHT import gui.widgets as widgets +import json +import os def multiworld_page(parent,settings): # Multiworld @@ -8,23 +10,12 @@ def multiworld_page(parent,settings): # Multiworld options self.widgets = {} - myDict = { - ## Number of worlds - "worlds": { - "type": "spinbox", - "label": { - "text": "Worlds" - }, - "packAttrs": { - "label": { "side": LEFT }, - "spinbox": { "side": RIGHT } - } - } - } - dictWidgets = widgets.make_widgets_from_dict(self, myDict, self) - for key in dictWidgets: - self.widgets[key] = dictWidgets[key] - self.widgets[key].pack(side=LEFT, anchor=N) + with open(os.path.join("resources","app","gui","randomize","multiworld","widgets.json")) as multiworldItems: + myDict = json.load(multiworldItems) + dictWidgets = widgets.make_widgets_from_dict(self, myDict, self) + for key in dictWidgets: + self.widgets[key] = dictWidgets[key] + self.widgets[key].pack(side=LEFT, anchor=N) ## List of Player Names key = "names" diff --git a/resources/app/gui/randomize/multiworld/widgets.json b/resources/app/gui/randomize/multiworld/widgets.json new file mode 100644 index 00000000..958e7000 --- /dev/null +++ b/resources/app/gui/randomize/multiworld/widgets.json @@ -0,0 +1,16 @@ +{ + "worlds": { + "type": "spinbox", + "label": { + "text": "Worlds" + }, + "packAttrs": { + "label": { + "side": "left" + }, + "spinbox": { + "side": "right" + } + } + } +}