diff --git a/ben10.py b/ben10.py index 7fadda2..0c173b9 100644 --- a/ben10.py +++ b/ben10.py @@ -6,11 +6,13 @@ from PIL import ImageTk, Image start() # start up sound effect +background = "#70b607" + root = Tk() root.title("Omnitrix") # root.attributes('-fullscreen', True) root.geometry("640x480") -root.configure(bg="#70b607") +root.configure(bg=background) root.columnconfigure(1, weight=1) root.rowconfigure(1, weight=1) # root window parameters @@ -18,31 +20,31 @@ root.rowconfigure(1, weight=1) path = "res/Omnitrix.png" img = ImageTk.PhotoImage(Image.open(path)) -omnitrix_button = Button(root, bg="#70b607", image=img, activebackground='#70b607', +omnitrix_button = Button(root, bg=background, image=img, activebackground=background, highlightthickness=0, bd=0, command=button_press) omnitrix_button.image = img omnitrix_button.grid(column=1, row=0, rowspan=3, columnspan=2) # middle button -omnitrix_left_skip = Button(root, text="<<<", fg="white", bg="black", command=lambda: skip_down(omnitrix_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) # bulk skip left button -omnitrix_right_skip = Button(root, text=">>>", fg="white", bg="black", command=lambda: skip_up(omnitrix_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) # bulk skip right button omnitrix_left = Button(root, text="<", fg="white", bg="black", - command=lambda: count_down(omnitrix_button), highlightthickness=0, bd=0, height=30, width=4) + command=lambda: alien_select(-1, omnitrix_button), highlightthickness=0, bd=0, height=30, width=4) omnitrix_left.grid(column=0, row=1, rowspan=3) # changes alien button (left) omnitrix_right = Button(root, text=">", fg="white", bg="black", - command=lambda: count_up(omnitrix_button), highlightthickness=0, bd=0, height=30, width=4) + command=lambda: alien_select(1, omnitrix_button), highlightthickness=0, bd=0, height=30, width=4) omnitrix_right.grid(column=3, row=1, rowspan=3) # changes alien button (right) diff --git a/functions.py b/functions.py index 3a3edda..0be9c04 100644 --- a/functions.py +++ b/functions.py @@ -5,66 +5,20 @@ from boombox import BoomBox counter = 0 # determans which image is shown -def count_up(omnitrix_button): +def alien_select(index, omnitrix_button): BoomBox("res/sound_switch.mp3").play() global counter - counter += 1 - if counter < 0: - path = image_display(counter * -1) - else: - path = image_display(counter) + counter += index + path = image_display(abs(counter)) img = ImageTk.PhotoImage(Image.open(path)) omnitrix_button.configure(image=img) - omnitrix_button.image = img # keep a reference! -# whenever "omnitrix_left" button is pressed, plays sound effect, adds 1 to the counter and change the image - -def count_down(omnitrix_button): - BoomBox("res/sound_switch.mp3").play() - global counter - counter -= 1 - if counter < 0: - path = image_display(counter * -1) - else: - path = image_display(counter) - img = ImageTk.PhotoImage(Image.open(path)) - omnitrix_button.configure(image=img) - omnitrix_button.image = img # keep a reference! -# whenever "omnitrix_left" button is pressed, plays sound effect, subtracts 1 to the counter and change the image - + omnitrix_button.image = img # keep a reference +# controls how much up or down the list you go def button_press(): BoomBox("res/sound_transformation.mp3").play() # whenever the "middle_button" button is pressed play sound effect - -def skip_up(omnitrix_button): - BoomBox("res/sound_switch.mp3").play() - global counter - counter += 5 - if counter < 0: - path = image_display(counter * -1) - else: - path = image_display(counter) - img = ImageTk.PhotoImage(Image.open(path)) - omnitrix_button.configure(image=img) - omnitrix_button.image = img # keep a reference! -# whenever "omnitrix_left_skip" button is pressed, plays sound effect, adds 5 to the counter and change the image - - -def skip_down(omnitrix_button): - BoomBox("res/sound_switch.mp3").play() - global counter - counter -= 5 - if counter < 0: - path = image_display(counter * -1) - else: - path = image_display(counter) - img = ImageTk.PhotoImage(Image.open(path)) - omnitrix_button.configure(image=img) - omnitrix_button.image = img # keep a reference! -# whenever "omnitrix_right_skip" button is pressed, plays sound effect, subtracts 5 to the counter and change the image - - def start(): BoomBox("res/sound_startup.mp3").play() # when program first starts up, plays sound effect