From 9bbbef7e31a95691d8718329b0ee899a06903deb Mon Sep 17 00:00:00 2001 From: superdimensional Date: Mon, 3 May 2021 19:26:01 -0400 Subject: [PATCH] background color is now a var --- README.md | 6 +++++- ben10.py | 37 ++++++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c4c3fff..4ff5187 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # raspberry-pi-omnitrix -An app made to simulate the omnitrix from the ben 10 TV series. \ No newline at end of file +An app made to simulate the omnitrix from the ben 10 TV series. + +## planed features: +- color changing background +- keybinds \ No newline at end of file diff --git a/ben10.py b/ben10.py index 0c173b9..8e99f99 100644 --- a/ben10.py +++ b/ben10.py @@ -6,13 +6,15 @@ from PIL import ImageTk, Image start() # start up sound effect -background = "#70b607" root = Tk() +background = StringVar() +background.set("#70b607") +# creates var and assigns it to default color root.title("Omnitrix") # root.attributes('-fullscreen', True) root.geometry("640x480") -root.configure(bg=background) +root.configure(bg=background.get()) root.columnconfigure(1, weight=1) root.rowconfigure(1, weight=1) # root window parameters @@ -20,38 +22,51 @@ root.rowconfigure(1, weight=1) path = "res/Omnitrix.png" img = ImageTk.PhotoImage(Image.open(path)) -omnitrix_button = Button(root, bg=background, image=img, activebackground=background, +omnitrix_button = Button(root, bg=background.get(), image=img, activebackground=background.get(), highlightthickness=0, bd=0, command=button_press) omnitrix_button.image = img -omnitrix_button.grid(column=1, row=0, rowspan=3, columnspan=2) +omnitrix_button.grid(column=1, row=0, rowspan=3, columnspan=2, sticky='senw') # middle button omnitrix_left_skip = Button(root, text="<<<", fg="white", bg="black", command=lambda: alien_select(-5, omnitrix_button), highlightthickness=0, bd=0, height=5, width=4) -omnitrix_left_skip.grid(column=0, row=0) +omnitrix_left_skip.grid(column=0, row=0, sticky='senw') # bulk skip left button omnitrix_right_skip = Button(root, text=">>>", fg="white", bg="black", command=lambda: alien_select(5, omnitrix_button), highlightthickness=0, bd=0, height=5, width=4) -omnitrix_right_skip.grid(column=3, row=0) +omnitrix_right_skip.grid(column=3, row=0, sticky='senw') # bulk skip right button omnitrix_left = Button(root, text="<", fg="white", bg="black", - command=lambda: alien_select(-1, omnitrix_button), highlightthickness=0, bd=0, height=30, width=4) -omnitrix_left.grid(column=0, row=1, rowspan=3) + command=lambda: alien_select(-1, omnitrix_button), highlightthickness=0, bd=0) +omnitrix_left.grid(column=0, row=1, rowspan=3, sticky='senw') # changes alien button (left) omnitrix_right = Button(root, text=">", fg="white", bg="black", - command=lambda: alien_select(1, omnitrix_button), highlightthickness=0, bd=0, height=30, width=4) -omnitrix_right.grid(column=3, row=1, rowspan=3) + command=lambda: alien_select(1, omnitrix_button), highlightthickness=0, bd=0) +omnitrix_right.grid(column=3, row=1, rowspan=3, sticky='senw') # changes alien button (right) - quit_button = Button(root, text="X", fg="white", bg="black", command=root.destroy, highlightthickness=0, bd=0, width=10, height=2) quit_button.grid(column=1, row=3, columnspan=2) # kills program +# ? def submit_color(): +# ? new_bg = background.get() +# ? print(new_bg) +# ? print(background.get()+"\n") +# ? background.set(new_bg) + +# ? color_entry = Entry(root, fg="white", bg="black", highlightthickness=0, bd=0, textvariable = background) +# ? color_entry.grid(column=1, row=0, sticky='enw') + + +# ? color_submit = Button(root, text="+", fg="white", bg="black", +# ? highlightthickness=0, bd=0,width=10,command =lambda: submit_color()) +# ? color_submit.grid(column=2, row=0, sticky='enw') + root.mainloop()