Installing tkinter | Building a GUI in python

How to install tkinter in Python version 3*? | Installing tkinter python

Hey Guys! You must have seen its solution everywhere before reaching my site. So don’t worry your problem going to solve here.

Step 1: Install tk instead of tkinter using the below command in Python Console, must right correct as shown – capital small keep in mind – both in small letter

!pip install tk

I want to say that tkinter package is already come with Python software package. Not need for installation of tkinter

Step 2: Go to Spyder and write the given code if error is not occured then start your GUI code.

import tkinter 
top = tkinter
top = tkinter.Tk();

You have must keep in mind that tkinter in small letter but in Tk, T capital and k small letter. After writing this above code run this and you get window as Output :

tkinter window

This window will appear on your page. That means your tkinter is working now.

How to make a Form in Python through Tkinter

from tkinter import *
import tkinter as tk

my_compdictionary = { 'algorithm': 'step by step instruction', 'bug': 'pieceof code that causes a progrsm to fail'}
#messagebox.showinfo("Hello", "Red Button clicked")  
def click():
    input = textentry.get("1.0",END)
    #Entry = textentry.get()
        Definition = my_compdictionary[input]
        Definition = "sorry there is no word like that please try again"
    output.insert(END, Definition)

window = Tk()
window.title("ClassStudies ")
window.configure(background ="black")

#photo1 = PhotoImage(file="C:\\Python_GUI\\unnamed.jpg")
#Label (window,image=photo1, bg="black").grid(row=0, column = 0, sticky=w)

#create label
Label (window, text="Enter the character for searching string:", bg="black",fg="white", font="none 12 bold").grid(row=1, column=0, sticky=W)

#create a text 
textentry = Entry (window, width=20, bg="white").grid(row=2, column=0, sticky=W)

#add submit  
Button (window, text="SUBMIT", width=6, command=click).grid(row=3,column = 0, sticky=W)

Label (window, text="\nDefinition", bg="black",fg="white", font="none 12 bold").grid(row=4, column=0, sticky=W)

output = Text(window, width=75, height=6, wrap=WORD, background = "white").grid(row=5, column=0, columnspan=2, sticky=W)

def close_window():
Button(window, text="Exit", width=6, command=close_window).grid(row=6,column = 0, sticky=W)
#the dictionary

####main loop

Output :

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top