How do you create an input method by pressing a button in python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How do you create an input method by pressing a button in python

20th Aug 2018, 6:00 PM
Joel Varghese Oommen
2 Answers
+ 8
#Button value increases when you click #Is this what you want? import tkinter as tk win = tk.Tk() win.geometry('600x600') def click(): num = int(btn['text']) btn.config(text = str(num + 1)) btn = tk.Button(text = '0', command = click) btn.pack(fill = tk.BOTH, expand = tk.YES) win.mainloop()
20th Aug 2018, 6:16 PM
Mert Yazıcı
Mert Yazıcı - avatar
+ 3
tKinter only works in the IDLE but not in the code playground. You have import the tKinter module in IDLE by the command ####### import tkinter
21st Aug 2018, 5:31 PM
Evans
Evans - avatar