Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HI, I am trying to get it so my tkinter code works. I am also trying to add it so when the user clicks the

HI, I am trying to get it so my tkinter code works. I am also trying to add it so when the user clicks the button to make the new window appear it gets rid of the old window. Here is my code. I am hoping you can solve my error and help me add the wanted code.

import tkinter as tk class game(): def __init__(self, user): print("If you know the rules of battleship type(1), if not then type(2)?") choice = input() if choice=="1": print("You know the rules.") if choice == "2": print("Let's learn the rules.") self.rules() def setup(self): data = "hello" root = tk.Tk() root.title("Basic Rules") root.geometry("600x500") frame = tk.Frame(root) frame.pack() Label(root, text= "yay" , fg = "blue", font = "times").pack() button = tk.Button(frame, text="Home Page", fg="blue", command = self.rules) button.pack(side=tk.LEFT) def rules(self): root = tk.Tk() root.title("The Rules") root.geometry("600x500") frame = tk.Frame(root) frame.pack() Label(root, text="Welcome to Battleship.", fg = "blue", font = "times").pack() button = tk.Button(frame, text="Basic Rules", fg="blue", command = self.setup) button.pack(side=tk.LEFT) #T = Text(root, height=2, width=30) #T.pack() #T.insert(END, "Just a text widget") root.mainloop()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Database For Big Data And Analytics

Authors: Cristian Molaro, Surekha Parekh, Terry Purcell, Julian Stuhler

1st Edition

1583473858, 978-1583473856

More Books

Students also viewed these Databases questions

Question

1. Explain how business strategy affects HR strategy.

Answered: 1 week ago