how to find the text inside button in tkinter
my_text = my_button.cget('text')
how to find the text inside button in tkinter
my_text = my_button.cget('text')
python hoe to make a text box
import tkinter as tk
root= tk.Tk()
canvas1 = tk.Canvas(root, width = 400, height = 300, relief = 'raised')
canvas1.pack()
label1 = tk.Label(root, text='Calculate the Square Root')
label1.config(font=('helvetica', 14))
canvas1.create_window(200, 25, window=label1)
label2 = tk.Label(root, text='Type your Number:')
label2.config(font=('helvetica', 10))
canvas1.create_window(200, 100, window=label2)
entry1 = tk.Entry (root)
canvas1.create_window(200, 140, window=entry1)
def getSquareRoot ():
x1 = entry1.get()
label3 = tk.Label(root, text= 'The Square Root of ' + x1 + ' is:',font=('helvetica', 10))
canvas1.create_window(200, 210, window=label3)
label4 = tk.Label(root, text= float(x1)**0.5,font=('helvetica', 10, 'bold'))
canvas1.create_window(200, 230, window=label4)
button1 = tk.Button(text='Get the Square Root', command=getSquareRoot, bg='brown', fg='white', font=('helvetica', 9, 'bold'))
canvas1.create_window(200, 180, window=button1)
root.mainloop()
creating a text box with tkinter py
import tkinter as tk
class Application(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.master = master
self.pack()
self.create_widgets()
def create_widgets(self):
self.w3=tk.Entry(self.master)
self.w3.pack(side='top')
self.quit = tk.Button(self.master, text='quit', command=self.master.destroy).pack()
self.test = tk.Button(self.master, text='print', command=self.get_text).pack()
def get_text(self):
print(self.w3.get())
root = tk.Tk()
app = Application(master=root)
app.mainloop()
how to create a enter box in tkinter
canvas1 = tk.Canvas(root, width = 400, height = 300)
canvas1.pack()
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us