Skip to content
Advertisement

How do i make the print to appear in tkinter window?

So i made this program for fun but i saw that when i click the button the “ez” text appears in pycharm and i wanted to make it appear in the window of the program. Does anyone know how i can do that?

import tkinter as tk
import os

def click():
    print('ez')
    os.system("shutdown /s /t 3")




window = tk.Tk()
window.geometry("420x420")
window.title("Russian Roulette!")
window.config(background = "#000000")
label = tk.Label(window,
                 text = "Are you sure you want to boost your FPS?",
                 font = ('Aerial', 20, 'bold'),
                 fg = 'green',
                 bg = '#000000',
                 )
label.place(x = 50 , y = 50)

button = tk.Button(window,
                   text = "Boost FPS!",
                   command = click,
                   font = ('Aerial', 20, 'bold'),
                   fg = 'green',
                   bg = '#000000',
                   activeforeground = 'green',
                   activebackground = '#000000',
                   relief = tk.RAISED, bd = 10, padx = 5, pady = 5,
                   )
button.place(x = 50, y = 150)

button = tk.Button(window,
                   text = "Cancel",
                   command = click,
                   font = ('Aerial', 20, 'bold'),
                   fg = 'green',
                   bg = '#000000',
                   activeforeground = 'green',
                   activebackground = '#000000',
                   relief = tk.RAISED, bd = 10, padx = 5, pady = 5,
                   )
button.place(x = 470, y = 150)

window.mainloop()

Advertisement

Answer

Just set the new text to the label you already have:

def click():
    label.config(text="ez")
    os.system("shutdown /s /t 3")
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement