Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to get input in tkinter

#Import the required Libraries
from tkinter import *
from tkinter import ttk

#Create an instance of Tkinter frame
win= Tk()

#Set the geometry of Tkinter frame
win.geometry("750x250")

def display_text():
   global entry
   string= entry.get()
   label.configure(text=string)

#Initialize a Label to display the User Input
label=Label(win, text="", font=("Courier 22 bold"))
label.pack()

#Create an Entry widget to accept User Input
entry= Entry(win, width= 40)
entry.focus_set()
entry.pack()

#Create a Button to validate Entry Widget
ttk.Button(win, text= "Okay",width= 20, command= display_text).pack(pady=20)

win.mainloop()
Comment

tkinter input box

import tkinter as tk

root= tk.Tk()

canvas1 = tk.Canvas(root, width = 400, height = 300)
canvas1.pack()

entry1 = tk.Entry (root) 
canvas1.create_window(200, 140, window=entry1)

def getSquareRoot ():  
    x1 = entry1.get()
    
    label1 = tk.Label(root, text= float(x1)**0.5)
    canvas1.create_window(200, 230, window=label1)
    
button1 = tk.Button(text='Get the Square Root', command=getSquareRoot)
canvas1.create_window(200, 180, window=button1)

root.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: distance euc of two arrays python 
Python :: python random 
Python :: sklearn roc curve 
Python :: sklearn rmsle 
Python :: python calculate computation time 
Python :: opencv get area of contour 
Python :: how to append to text file with new line by line in python 
Python :: extract ints from strings in Pandas 
Python :: how to read from a file into a list in python 
Python :: delete image with python 
Python :: timedelta year python 
Python :: how to get unix timestamp in python 
Python :: python pil invert image color 
Python :: python what does yield do 
Python :: python average of two lists by row 
Python :: python array delete last column 
Python :: how to set a image as background in tkitner 
Python :: tkinter maximum window size 
Python :: pandas sum multiple columns groupby 
Python :: import randomforestclassifier 
Python :: ImportError: No module named django.core.wsgi 
Python :: count how many duplicates python pandas 
Python :: python hsl to rgb 
Python :: get current month python 
Python :: django integer field example 
Python :: remove single and double quotes from string python 
Python :: add horizontal line plotly 
Python :: imbade image to jupyter notebook 
Python :: pandas remove index column when saving to csv 
Python :: how to remove first row of numpy array 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =