Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

creating an entry widget for input in tkinter

# Program to make a simple
# login screen 
 
 
import tkinter as tk
  
root=tk.Tk()
 
# setting the windows size
root.geometry("600x400")
  
# declaring string variable
# for storing name and password
name_var=tk.StringVar()
passw_var=tk.StringVar()
 
  
# defining a function that will
# get the name and password and
# print them on the screen
def submit():
 
    name=name_var.get()
    password=passw_var.get()
     
    print("The name is : " + name)
    print("The password is : " + password)
     
    name_var.set("")
    passw_var.set("")
     
     
# creating a label for
# name using widget Label
name_label = tk.Label(root, text = 'Username', font=('calibre',10, 'bold'))
  
# creating a entry for input
# name using widget Entry
name_entry = tk.Entry(root,textvariable = name_var, font=('calibre',10,'normal'))
  
# creating a label for password
passw_label = tk.Label(root, text = 'Password', font = ('calibre',10,'bold'))
  
# creating a entry for password
passw_entry=tk.Entry(root, textvariable = passw_var, font = ('calibre',10,'normal'), show = '*')
  
# creating a button using the widget
# Button that will call the submit function
sub_btn=tk.Button(root,text = 'Submit', command = submit)
  
# placing the label and entry in
# the required position using grid
# method
name_label.grid(row=0,column=0)
name_entry.grid(row=0,column=1)
passw_label.grid(row=1,column=0)
passw_entry.grid(row=1,column=1)
sub_btn.grid(row=2,column=1)
  
# performing an infinite loop
# for the window to display
root.mainloop()
Comment

PREVIOUS NEXT
Code Example
Python :: search for a word in pdf using python 
Python :: how to print specific part of a dictionary in python 
Python :: plus in python 
Python :: count nan values 
Python :: xpath starts-with and ends-with 
Python :: python get array from json 
Python :: pytplot arc 
Python :: xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 0 
Python :: letters to numbers python 
Python :: add new row to dataframe pandas 
Python :: python dictonary set default 
Python :: append extend python 
Python :: print whole list python 
Python :: pyodbc cursor create list of dictionaries 
Python :: run python script on android 
Python :: django login page 
Python :: tqdm in place 
Python :: media pipe install ERROR: Could not find a version that satisfies the requirement mediapipe (from versions: none) 
Python :: python session set cookies 
Python :: delete rows in a table that are present in another table pandas 
Python :: length of list python 
Python :: python verificar se é numero 
Python :: django templates 
Python :: tiff to jpg in python 
Python :: remove na python 
Python :: knn with sklearn 
Python :: how to check encoding of csv 
Python :: python pandas how to get the dataframe size 
Python :: plotly color specific color 
Python :: python set with counts 
ADD CONTENT
Topic
Content
Source link
Name
1+3 =