When I try to put my button in a frame, it goes into the Main Window instead of in to the frame. What am I doing wrong? When it shows up, it "packs" underneath the Frames instead of going in to the correct frame.
I tried changing the order, changing the frame names. Nothing is working. Here is my code:
import random
from tkinter import *
#declare variables
computer_options = ["Rock", "Paper", "Scissors"]
user_choice = ""
scoreboard = 0
#functions
def rock_command():
global computer_choice
global user_choice
global scoreboard
computer_choice = random.choice(computer_options)
user_choice = "Rock"
if computer_choice == "Rock":
scoreboard = scoreboard
elif computer_choice == "Scissors":
scoreboard = scoreboard + 1
elif computer_choice == "Paper":
scoreboard = scoreboard - 1
def paper_command():
global computer_choice
global user_choice
global scoreboard
computer_choice = random.choice(computer_options)
user_choice = "Paper"
if computer_choice == "Paper":
scoreboard = scoreboard
elif computer_choice == "Rock":
scoreboard = scoreboard + 1
elif computer_choice == "Scissors":
scoreboard = scoreboard - 1
def scissors_command():
global computer_choice
global user_choice
global scoreboard
computer_choice = random.choice(computer_options)
user_choice = "Scissors"
if computer_choice == "Scissors":
scoreboard = scoreboard
elif computer_choice == "Paper":
scoreboard = scoreboard + 1
elif computer_choice == "Rock":
scoreboard = scoreboard - 1
#set up main window
root = Tk()
#set up frames
title_frame = Frame(root, bg="blue", height=200, width= 600).pack()
image_frame = Frame(root, bg="red", height=200, width= 600).pack()
buttonFrame = Frame(root, bg="green", height=200, width= 600).pack()
score_frame = Frame(root, bg="yellow", height=200, width= 600).pack()
#buttons
paper_button = Button(buttonFrame, text="Paper", command ="paper_command").pack()
#rock_button = Button(buttonFrame, text="Rock", command=rock_command)
#scissors_button = Button(buttonFrame, text="Scissors", command ="scissors_command")
#loop program
root.mainloop()