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?
JavaScript
x
48
48
1
import tkinter as tk
2
import os
3
4
def click():
5
print('ez')
6
os.system("shutdown /s /t 3")
7
8
9
10
11
window = tk.Tk()
12
window.geometry("420x420")
13
window.title("Russian Roulette!")
14
window.config(background = "#000000")
15
label = tk.Label(window,
16
text = "Are you sure you want to boost your FPS?",
17
font = ('Aerial', 20, 'bold'),
18
fg = 'green',
19
bg = '#000000',
20
)
21
label.place(x = 50 , y = 50)
22
23
button = tk.Button(window,
24
text = "Boost FPS!",
25
command = click,
26
font = ('Aerial', 20, 'bold'),
27
fg = 'green',
28
bg = '#000000',
29
activeforeground = 'green',
30
activebackground = '#000000',
31
relief = tk.RAISED, bd = 10, padx = 5, pady = 5,
32
)
33
button.place(x = 50, y = 150)
34
35
button = tk.Button(window,
36
text = "Cancel",
37
command = click,
38
font = ('Aerial', 20, 'bold'),
39
fg = 'green',
40
bg = '#000000',
41
activeforeground = 'green',
42
activebackground = '#000000',
43
relief = tk.RAISED, bd = 10, padx = 5, pady = 5,
44
)
45
button.place(x = 470, y = 150)
46
47
window.mainloop()
48
Advertisement
Answer
Just set the new text to the label you already have:
JavaScript
1
4
1
def click():
2
label.config(text="ez")
3
os.system("shutdown /s /t 3")
4