how to hide or delete my buttons in Tkinter python?

im making a small game in a canvas with turtle and a menu with tkinter. the game stays in the tkinter window. so far im able to manipulate the canvas when pressing on a button, and to manipulate the tkinter window. but after pressing on the game button i want the 2 buttons to disappear. to hide or to be deleted. i cannot figure out how to do that? could anybody help me with this? this is my code:

import tkinter as tk
from turtle import RawTurtle

root = tk.Tk()

canvas = tk.Canvas(master = root, width = 0, height = 0)

def testdel():   
    global canvas
    canvas.config(width = 0, height = 0)

def testteken():
    global canvas
    canvas.config(width = 100, height = 100)
    t = RawTurtle(canvas)
    t.pencolor("#ff0000") # Red
    t.goto(200, 110)
    t.goto(0, 0)

button1 = tk.Button(master = root, text = "delete", command = testdel).pack(side = tk.LEFT)
button2 = tk.Button(master = root, text = "draw", command = testteken).pack(side = tk.LEFT)



i fixed this problem by changing the 'pack' code behind the button to the normal pack-way >> button1.pack() after this theo's solution did work :)

Read more here:

Content Attribution

This content was originally published by Wwes at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: