From 30d08f0036a093442e4f6f29328b5bd8204379bd Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 10 May 2015 13:43:48 +0100 Subject: [PATCH] Added difficulty slider to options --- GUI.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/GUI.py b/GUI.py index fb5b65c..b3c791b 100644 --- a/GUI.py +++ b/GUI.py @@ -55,7 +55,7 @@ class Main_Window: class Options_Window: def __init__(self): self.options = { - "":"" + "Difficulty": 120 } def display(self, master): @@ -64,11 +64,35 @@ class Options_Window: self.title = Label(self.master) self.title.config(text="OPTIONS",font=("Courier New", 37)) - self.title.pack(side="top", padx=PADDING_BUTTON, pady=PADDING_TITLE/2) + self.title.pack(side="top", padx=PADDING_TITLE, pady=PADDING_TITLE/2) + self.difficulty_title = Label(self.master) + self.difficulty_title.config(text="Current Difficulty: {}".format(self.options["Difficulty"]), font=("Courier New", 19)) + self.difficulty_title.pack(ipadx=PADDING_BUTTON/3, padx=PADDING_BUTTON) + + self.difficulty_scale = Scale(self.master, from_=30, to=300, orient="horizontal", command=self.update_difficulty, length=400) + self.difficulty_scale.pack(ipadx=PADDING_BUTTON/3, padx=PADDING_BUTTON/3) + + self.exit_button = Button(self.master, style="Minor.TButton") + self.exit_button.config(text="Reset") + self.exit_button.pack(ipadx=PADDING_BUTTON/3, padx=PADDING_BUTTON/3) + self.exit_button.bind('', self.reset_difficulty) + + Style().configure("Minor.TButton", font=("Lucida", 10)) + logging.info("Options menu created.") + def close(self): self.master.destroy() + def update_difficulty(self, event): + self.options["Difficulty"] = int(self.difficulty_scale.get()) + self.difficulty_title["text"] = "Current Difficulty: {}".format(self.options["Difficulty"]) + + def reset_difficulty(self, event): + self.options["Difficulty"] = 120 + self.difficulty_title["text"] = "Current Difficulty: {}".format(self.options["Difficulty"]) + self.difficulty_scale["value"] = 120 + def display(): root=Tk()