IMAGE: --->ScreenShot of the problem
IMAGE: --->How it is meant to look:
In the first hyperlink above i have attached a screenshot of the problem.
When running the windows which are connected by a button, the image on the window that is launched from the first window displays on the first window and not on the new window just opened.
At first I thought that python might be getting confused because the file name is the same. (that wasn't the case as I used a slightly different image with a different file name.
I have tried so many ways and it just doesnt work.
Directly below this line is the code for the first window:
#----Main Menu----
root_menu = Tk()
root_menu.title("Warehouse Inventory Control System")
root_menu.configure(bg = "black")
photo = PhotoImage(file="logo.gif")
photoLabel = Label(image=photo)
photoLabel.image = photo
photoLabel.grid(row=1, column=3,columnspan = 4, sticky = N)
Title_Screen = Label(root_menu,
text="Welcome to the SsangYong\n Warehouse Inventory Control System",
fg="grey",
bg="black",
font="Helevetica 25 bold",
pady = "50",
padx = "50",
).grid(row=2, column=3)
Search_Inventory = Button(root_menu,
text = "Search Inventory",
command=Search_Inventory,
fg = "Blue",
bg = "Grey",
bd = 2,
font="Helevetica 12 bold",
height = 1,
width = 50,
).grid(row=16, column=3,pady = 25,padx = 25,)
Add_Stock = Button(root_menu,
text = "Add New Items",
command = Add_To_Database,
fg = "Blue",
bg = "Grey",
bd = 2,
font="Helevetica 12 bold",
height = 1,
width = 60,
).grid(row=15, column=3,pady = 25,padx = 25,)
Print_Report = Button(root_menu,
text = "Print Stock Report",
fg = "Blue",
bg = "Grey",
bd = 2,
font="Helevetica 12 bold",
height = 1,
width = 70,
).grid(row=17, column=3,pady = 25,padx = 25,)
Help_Button = Button(root_menu,
text = "Help",
command=Help_PDF,
fg = "Red",
bg = "Black",
height = "1",
bd = "2",
font = "Helevetica 20 bold",
width = "4",
).grid(row=1, column=3,rowspan = 2, sticky= NE)
root_menu.mainloop()
and here is the code for the second window.
def Search_Inventory():
#---Search Window----
root_search = Tk()
root_search.title("Warehouse Inventory Control System")
root_search.configure(bg = "black")
#----Title displayed under the company logo on the first window----
Title_Screen = Label(root_search,
text="Warehouse Inventory Control System",
fg="grey",
bg="black",
font="Helevetica 25 bold",
pady = "50",
padx = "50",
).grid(row=3, column=4)
#----Interactive Input Boxes for the User----
#----Label to Notify what is needed in the entry box----
PN_Info_Label = Label(root_search,
text = "Part Number:",
fg="white",
bg="black",
font="Helevetica 15 bold",
padx = 50,
).grid(row=14, column=3, rowspan = 2)
#----Input Box for Part Number
PN_Display = StringVar()
Input_PartNumber = Entry(root_search,
textvariable=PN_Display,
fg = "blue",
font = "Helevtica 25 bold",
).grid(row=14, column=4)
#----A button that will proceed to the next part of the program----
Search_Button = Button(root_search,
text = "Search Inventory",
fg = "Blue",
bg = "Grey",
bd = 2,
font="Helevetica 15 bold",
command=lambda:Search_Prod(PN_Display.get()),
height = 1,
width = 15,
).grid(row=16, column=4,pady = 25,padx = 25,)
#----Information regarding how to enter the part number---
Info = Label(root_search,
text="Please Use Capitals to Enter Part Number",
fg= "red",
bg = "black",
font = "helevetica 12 bold",
).grid(row = 15, column = 4)
#----Adding the company logo to the first window----
photo = PhotoImage(file="image.gif")
photoLabel = Label(image=photo)
photoLabel.image = photo
photoLabel.grid(row=1, column=4, pady = 10)
#----Linking the Help Document----
Help_Button = Button(root_search,
text = "Help",
command=Help_PDF,
fg = "Red",
bg = "Black",
height = "1",
bd = "2",
font = "Helevetica 20 bold",
width = "4",
).grid(row=0, column=5, pady= 10,padx = 50, sticky = E)
#----Saying who the program was made by----
Credits = Label(root_search,
text = "Created By: Me",
fg = "White",
bg = "Black",
font = "Helevetica 10 underline",
).grid(row = 19, column = 5)
#To Make Sure that the window doesn't close
root_search.mainloop()
In your question you show this for your "second window":
def Search_Inventory():
#---Search Window----
root_search = Tk()
...
photoLabel = Label(image=photo)
There are two problems with the above code. For one, you're creating a second instance of Tk. You should not do this. A tkinter program should have exactly one instance of Tk. If you want additional windows you need to create instances of Toplevel.
The second problem is where you create the Label -- you are neglecting to give it a parent so it is probably defaulting to the original window. You need to change that last line to this:
photoLabel = Label(root_search, image=photo)
Related
I am trying to code a journal using tkinter. I have used different scripts for each part of the journal (main menu, morning entry and evening entry). I have set it so that the windows for morning and evening entry only open when their respective buttons are pressed on the main menu and this works well but when I run the programs both windows open automatically without me pressing anything. This happens before the main menu window is even opened. I have checked through the code and not noticed anything that can be causing this. Below is my code for the main menu and for the morning menu (evening is the same as morning menu with variables changed).
Main Menu
#importing libraries
import tkinter as tk
from tkinter import *
from Morning import *
from Evening import *
def StartUp():
Start = tk.Tk()
#Start Window Title and Size
Start.title("Journal")
Start.geometry("600x500")
Start["bg"] = "white"
#header Box
header = Label(Start, text = "Journal",
height = 1,
width = 7,
font = ("Comic Sans", 16, "bold"),
bg = "white")
header.pack(side = TOP)
#Buttons
morning_button = Button(Start, height = 2,
width = 20,
text = "Morning",
bg = "white",
command = lambda : morningwindow(),
)
morning_button.pack(side = LEFT)
evening_button = Button(Start, height = 2,
width = 20,
text = "Evening",
bg = "white",
command = lambda : eveningwindow())
evening_button.pack(side = RIGHT)
wklyQs_button = Button(Start, height = 2,
width = 30,
text = "Weekly Questions",
bg = "white")
wklyQs_button.pack()
mnthlycheck_button = Button(Start, height = 2,
width = 30,
text = "Monthly Check In",
bg = "white")
mnthlycheck_button.pack()
quit_button = Button(Start, height = 2,
width = 20,
text = "QUIT",
bg = "white",
command = quit)
quit_button.pack(side = BOTTOM)
#mainloop
Start.mainloop()
StartUp()
Morning Entry
#importing libraries
import tkinter as tk
from tkinter import *
from datetime import *
def morningwindow():
Morning = tk.Tk()
#Morning Window Title and Size
Morning.title("Morning")
Morning.geometry("1400x700")
Morning["bg"] = "#97e8fc"
#header Box
header = Label(Morning, text = "Morning Entry",
height = 1,
width = 20,
font = ("Comic Sans", 16, "bold"),
bg = "white")
header.pack(anchor=N)
#date Box
today = date.today()
format_date = "Today's date", today.strftime("%b-%d-%y")
date_text = Label(Morning, text = (format_date),
height = 1,
width = 20,
font = ("Comic Sans", 16, "bold"),
bg = "white"
)
date_text.pack(anchor=NE, padx = 10, pady = 10)
##Entries
#Grateful Entry
grateful_text = Text(Morning, height = 4, width = 160)
grateful_text.insert(END,
"What are you grateful for? \n1.\n2.\n3.")
grateful_text.pack()
#Good Day Entry
goodday_text = Text(Morning, height = 4, width = 160)
goodday_text.insert(END,
"This is how I'll make today great:")
goodday_text.pack(pady = 10)
#Positive Affirmation Entry
affirm_text = Text(Morning, height = 4, width = 160)
affirm_text.insert(END,
"Positive Affirmation \n")
affirm_text.pack()
##Buttons
#back Button
back_button = Button(Morning, height = 2,
width = 20,
text = "BACK",
bg = "white",
command = lambda : Morning.destroy())
back_button.pack(side = BOTTOM)
#Submit Button
submit_button = Button(Morning, height = 2,
width = 20,
text = "SUBMIT",
bg = "white",
)
submit_button.pack(side = BOTTOM, pady = 10)
#mainloop
Morning.mainloop()
import tkinter as tk
root = tk.Tk()
Canvas = tk.Canvas(root, height = 700, width = 1300, bg = "black")
Canvas.pack()
w = 0.8
h = 0.8
x=0.1
y=0.1
pw = 0.3
ph = 0.3
px = 0.35
py = 0.35
pName = ["Jack","Thomas"]
pScore = [0,0]
pList = [0,1]
def ncYes():
menuPage()
pName.append(playerName)
pScore.append(0)
pList.append(0)
def ncNo():
notice("Please re enter a new name.")
titlePage()
def popup(question,yes,no):
popupFrame = tk.Frame(root, bg = "white")
popupFrame.place(relwidth = pw, relheight = ph, relx = px, rely = py)
question = tk.Label(popupFrame, text = question, fg = "black", bg = "gray", font = "Arial 20 bold italic")
title.pack()
yes = tk.Button(popupFrame, text = "Yes", fg = "black", bg = "gray", font = "Arial 15 bold",command=yes)
yes.pack()
no = tk.Button(popupFrame, text = "No", fg = "black", bg = "gray", font = "Arial 15 bold",command=no)
no.pack()
def notice(notice):
noticeFrame = tk.Frame(root, bg = "white")
noticeFrame.place(relwidth = pw, relheight = ph, relx = px, rely = py)
notice = tk.Label(noticeFrame, text = notice, fg = "black", bg = "gray", font = "Arial 20 bold italic")
title.pack()
okay = tk.Button(noticeFrame, text = "Okay", fg = "black", bg = "gray", font = "Arial 15 bold",command=noticeFrame.destroy)
okay.pack()
def nameCheck():
for i in range(len(pName)) :
if playerName == pName[i]:
popup("Name already exist, is this your name?",ncYes,ncNo)
else:
if i == range(len(pName)):
popup("Do you wanna create a new name?",ncYes,ncNo)
def menuPage():
menuFrame = tk.Frame(root, bg = "white")
menuFrame.place(relwidth = w, relheight = h, relx = x, rely = y)
title = tk.Label(menuFrame, text = "Typing practice", fg = "black", bg = "gray", font = "Arial 30 bold italic")
title.pack()
titlebtn = tk.Button(menuFrame, text = "back", fg = "black", bg = "gray", font = "Arial 30 bold",command=titlePage)
titlebtn.pack()
def titlePage():
titleFrame = tk.Frame(root, bg = "white")
titleFrame.place(relwidth = w, relheight = h, relx = x, rely = y)
title = tk.Label(titleFrame, text = "Typing practice", fg = "black", bg = "gray", font = "Arial 50 bold italic")
title.pack()
playerName = tk.Entry(titleFrame, text = "Your name", fg = "black", bg = "gray", font = "Arial 30 italic")
playerName.pack()
start = tk.Button(titleFrame, text = "Start", fg = "black", bg = "gray", font = "Arial 30 bold",command=menuPage)
start.pack()
titleFrame = tk.Frame(root, bg = "white")
titleFrame.place(relwidth = w, relheight = h, relx = x, rely = y)
title = tk.Label(titleFrame, text = "Typing practice", fg = "black", bg = "gray", font = "Arial 50 bold italic")
title.pack()
playerName = tk.Entry(titleFrame, text = "Your name", fg = "black", bg = "gray", font = "Arial 30 italic")
playerName.pack()
start = tk.Button(titleFrame, text = "Start", fg = "black", bg = "gray", font = "Arial 30 bold",command=nameCheck)
start.pack()
warmUp = tk.Button(root, text = "Warmup", padx = 10, pady = 5, fg = "white", bg="black")
warmUp.pack()
quit = tk.Button(root, text = "Quit", padx = 10, pady = 5, fg = "white", bg="black", command = root.destroy)
quit.pack()
root.mainloop()
hi guys, I am not sure why the nameCheck function is not being triggered.
I didn't put much effort into designing so it looks bad.
I used tkinter.
The start button in the titleFrame is supposed to trigger the nameCheck function that checks the playerName(in title frame entry) against pName(list).
Do I have to create a separate variable outside the function to store the playerName?
By the way, I am very new to coding, just found out what def is today. So please explain your code in detail, Thank you(^-^).
The button command extension is on a diffrent line as so
btnRead=tk.Button(root, height=1, width=10, text="Insert GUI",
command=getTextInput)
I am new to Python, trying to make the Launch TFL App button open another GUI called "Menu GUI" but I don't know what to do for the def open_Menu(): function below. I want to use the popup GUI below as a launcher which takes the user to my main GUI. The only problem with the code below is that the button for launch TFL app doesn't do anything when you click it.
Here's my current code :
from tkinter import *
root = Tk()
root.title('TFL App')
p = Label(root, text = "TFL Journey Planner", height = "18", width = "250", bg = 'brown', fg =
'white',
font = ('Helvetica', '20', 'bold', 'italic'))
p.pack()
root.configure(bg = 'brown')
root.geometry('400x700')
photo = PhotoImage(file = 'trainstation.png')
label = Label(root, image = photo)
label.pack()
****#Buttons****
def open_Menu():
pass
Button1 = Button(root, text = "Launch TFL App", command = open_Menu, bg = "black", fg = 'white', padx
= 40,
pady = 10,
font = ('Calibri Light', '15', 'bold'))
Button1.pack(padx = 25, pady = 0)
Button2 = Button(root, text = "Exit ", command = root.destroy, bg = "black", fg = 'white', padx = 65,
pady = 8,
font = ('Calibri Light', '15', 'bold'))
Button2.pack(padx = 25, pady = 10)
root.mainloop()
How can I implement open_menu()
The code below is for my Main GUI which should open through the PopUp GUI above but the button on the PopUp GUI is not working.
from tkinter import *
def find():
# get method returns current text
# as a string from text entry box
From = From_field.get()
To = To_field.get()
travel_modes = mode_field.get()
# Calling result() Function
result(From, To, travel_modes)
# Function for inserting the train string
# in the mode_field text entry box
def train():
mode_field.insert(10, "train")
# Function for clearing the contents
def del_From():
From_field.delete(0, END)
distance_field.delete(0, END)
duration_field.delete(0, END)
def del_To():
To_field.delete(0, END)
distance_field.delete(0, END)
duration_field.delete(0, END)
def del_modes():
mode_field.delete(0, END)
distance_field.delete(0, END)
duration_field.delete(0, END)
def delete_all():
From_field.delete(0, END)
To_field.delete(0, END)
mode_field.delete(0, END)
distance_field.delete(0, END)
duration_field.delete(0, END)
# Driver code
if __name__ == "__main__":
# Create a GUI root
root = Tk()
# Set the background colour of GUI root
root.configure(background = 'light blue')
# Set the configuration of GUI root
root.geometry("600x400")
# Created a welcome to distance time calculator label
headlabel = Label(root, text = 'Welcome to your TFL Journey Planner',
fg = 'white', bg = "dark red", height = "0", width = "30",
font = ('calibri light', '19', 'italic'))
# Created a From: label
label1 = Label(root, text = "From:",
fg = 'white', bg = 'black')
# Created a To: label
label2 = Label(root, text = "To:",
fg = 'white', bg = 'black')
# Created a Distance: label
label4 = Label(root, text = "Distance:",
fg = 'white', bg = 'black')
# Created a Duration: label
label5 = Label(root, text = "Duration:",
fg = 'white', bg = 'black')
label6 = Label(root, text = "Choose travelling mode Below: ",
fg = 'white', bg = 'black')
headlabel.grid(row = 0, column = 1)
label1.grid(row = 1, column = 0, sticky = "E")
label2.grid(row = 2, column = 0, sticky = "E")
label4.grid(row = 7, column = 0, sticky = "E")
label5.grid(row = 8, column = 0, sticky = "E")
label6.grid(row = 3, column = 1)
# Created a text entry box
# for filling or typing the data.
From_field = Entry(root)
To_field = Entry(root)
mode_field = Entry(root)
distance_field = Entry(root)
duration_field = Entry(root)
From_field.grid(row = 1, column = 1, ipadx = "100")
To_field.grid(row = 2, column = 1, ipadx = "100")
mode_field.grid(row = 5, column = 1, ipadx = "50")
distance_field.grid(row = 7, column = 1, ipadx = "100")
duration_field.grid(row = 8, column = 1, ipadx = "100")
# CLEAR Button and attached
# to del_source function
button1 = Button(root, text = "Clear", bg = "light grey",
fg = "black", command = del_From)
# Create a CLEAR Button and attached to del_destination
button2 = Button(root, text = "Clear", bg = "light grey",
fg = "black", command = del_To)
# Create a RESULT Button and attached to find function
button3 = Button(root, text = "Result",
bg = "black", fg = "white",
command = find)
# Create a CLEAR ALL Button and attached to delete_all function
button4 = Button(root, text = "Clear All",
bg = "light grey", fg = "black",
command = delete_all)
# Create a Train Button and attached to train function
button5 = Button(root, text = "Train",
bg = "light grey", fg = "black",
command = train)
# Create a CLEAR Button and attached to del_modes function
button6 = Button(root, text = "Clear",
fg = "black", bg = "light grey",
command = del_modes)
button1.grid(row = 1, column = 2)
button2.grid(row = 2, column = 2)
button3.grid(row = 6, column = 1)
button4.grid(row = 9, column = 1)
button5.grid(row = 4, column = 1)
button6.grid(row = 5, column = 2)
root.mainloop()
Here is a solution using from subprocess import call. All you have to do is replace 'YOUR_FILE_NAME' with... your file name :D
from tkinter import *
from subprocess import call
root=Tk()
root.geometry('200x100')
frame = Frame(root)
frame.pack(pady=20,padx=20)
def open_Menu():
call(["python", "YOUR-FILE-NAME.py"])
btn=Button(frame,text='Open File',command=Open)
btn.pack()
root.mainloop()
What it will look like:
I hope this works for you :D
I was trying to create the scrolled-abled in the frame, where there will be multiple entry lines according to the number of items present. My questions are
1.) My frame Nofy_frame1 with scrollbar is not working (Mentioned the comment #NOT WORKING part) and its position is too close to the entries I did not get any error response. How to solve it?
2.) How to stop/restart the loop while shifting the radio buttons of method 1 and method 2? Since for each click on Add entry button for method 2, the result would be :
Price 1 :
Price 2 :
Price 3 :
Price 4 :
Price 5 :
and then next click on the same Add entry button I am getting
Price 6 :
Price 7 :
Price 8 :
Price 9 :
Price 10 :
instead of the above result
How to resolve it?
I have written the fair code below, Please let me know and clarify my mistakes
import tkinter as tk
from tkinter import ttk
from tkinter import filedialog
from tkcalendar import Calendar,DateEntry
from tkinter import messagebox
from tkinter.scrolledtext import ScrolledText
import os
from tkinter import *
import numpy as ny
master0 = tk.Tk()
master0.config(background = "white")
master0.title("Shop Cashier")
master0.geometry("1000x600")
master0.colour_schemes = [{"bg": "#eef1f5", "fg": "black"}, {"bg": "blue", "fg": "white"}]
tabs = ttk.Notebook(master0)
C_1 = 'black'
C_2 = 'white'
TStyler = ttk.Style()
TStyler.configure("TFrame", background=C_2, foreground=C_1, borderwidth=0)
tab1 = ttk.Frame(tabs, style = "TFrame")
tab2 = ttk.Frame(tabs, style = "TFrame")
tab3 = ttk.Frame(tabs, style = "TFrame")
C1 = Canvas(tab1, borderwidth=1, background="white")
C2 = Canvas(tab2, borderwidth=1, background="white")
C2 = Canvas(tab3, borderwidth=1, background="white")
tabs.add(tab1, text ='1')
tabs.add(tab2, text ='2')
tabs.add(tab3, text ='3')
tabs.pack(expand = 1, fill ="both")
#-TAB1
quit_button = tk.Button(tab1, text="Finish", fg="White", bg = "#53c653",padx=10, pady=3,command=master0.destroy)
quit_button.place(x = 450, y= 430)
#-TAB2
InitialInv_r = tk.DoubleVar()
CF_result = tk.DoubleVar()
P_r = tk.DoubleVar()
iiit_r = tk.IntVar()
alent = []
FCI_list = []
VCI_list = []
def addEntry():
if CF_result.get() == 2:
Nofy_frame = Frame(tab2, width = 10, height = 200, bd = 0, background = "#fff080")
Nofy_frame.place(x = 50, y= 150)
Nofy_frame1 = Frame(tab2, width = 270, height = 400, bd = 0, background = "#fff080")
Nofy_frame1.place(x = 50, y= 150)
#============================================================NOT WORKING
Nofy_frame1.pack_propagate(0) # stops frame from shrinking
scroll = Scrollbar(Nofy_frame1)
scroll.pack(side = RIGHT, fill = Y)
#============================================================NOT WORKING
for number in range(iiit_r.get()):
number = len(alent)
#label
ylab = Label(Nofy_frame1, text="Price "+str(number+1)+" :",bg = "#fff080")
ylab.grid(row=number+1, column=0, padx=10, pady=10)
#Entry
ent = Entry(Nofy_frame1, font=('calibri', 11), width = 33)
ent.grid(row=number+1, column=2,padx=10, pady=20)
alent.append( ent )
elif CF_result.get() == 0:
Nofy_frame = Frame(tab2, width = 328, height = 400, bd = 0, background = "#fff080")
Nofy_frame.place(x = 50, y= 150)
Nofy_frame2 = Frame(tab2, width = 270, height = 400, bd = 0, background = "#fff080")
Nofy_frame2.place(x = 50, y= 150)
ylab1 = Label(Nofy_frame2, text="Fixed Price :",bg = "#fff080" )
ylab1.grid(row=1, column=0, padx=2, pady=10)
#Entry
ent = Entry(Nofy_frame2, font=('calibri', 11), width = 30)
ent.grid(row=1, column=2,padx=10, pady=20)
alent.append( ent )
Disct = Label(tab2, text = ' Percentage', bg = "white",padx=3, pady=1,font = ("calibri", 12))
Disct.place(x=400, y=50)
Disctp = Label(tab2, text = '%', bg = "white",padx=3, pady=1,font = ("calibri", 12))
Disctp.place(x=642, y=50)
#Disct_frame = Frame(tab2, width = 200, height = 25, bd = 0, background = "white", highlightcolor = "black", highlightthickness = 1)
#Disct_frame.place(x = 530, y= 50)
Disctv = Entry(tab2,font=('calibri', 12), textvariable= P_r,width = 10, bd=1, bg='#fffce6', justify='left')
Disctv.place(x=560, y=50)
Nofy = Label(tab2, text = 'No. of items :', bg = "white",padx=3, pady=1,font = ("calibri", 12))
Nofy.place(x=700, y=50)
Nofy_frame = Frame(tab2, width = 328, height = 400, bd = 0, background = "#fff080", highlightcolor = "#fff080", highlightthickness = 1)
Nofy_frame.place(x = 50, y= 150)
Nofyv = Entry(tab2,font=('calibri', 12), textvariable= iiit_r, width = 5, bd=1, bg='#fffce6', justify='left')
Nofyv.place(x=800, y=50)
CashFlow = Label(tab2, text = 'Method', bg = "white",padx=3, pady=1,font = ("calibri light", 18))
CashFlow.place(x=50, y=100)
FCF_r = Radiobutton(tab2, variable = CF_result, value = 0, bg = "white")
FCF_r.place(x=180, y=110)
FCF_rr = Label(tab2, text = "method 1", bg = "white",padx=3, pady=1,font = ("calibri light", 12))
FCF_rr.place(x=200, y=108)
vCF_r = Radiobutton(tab2, variable = CF_result, value = 2,bg = "white")
vCF_r.place(x=380, y=110)
vCF_rr = Label(tab2, text = "method 2", bg = "white",padx=3, pady=1,font = ("calibri light", 12))
vCF_rr.place(x=400, y=108)
addEnt = Button(tab2, text='Add entry', fg="White", bg = "#1a1700", command=addEntry)
addEnt.place(x = 400, y= 150)
quit_button = tk.Button(tab2, text="Finish", fg="White", bg = "#53c653",padx=10, pady=3,command=master0.destroy)
quit_button.place(x = 900, y= 530)
master0.mainloop()
I'm making a calculator using Tkinter. I want to be able to block the user from typing directly in the Entry, but still, i don't want to simply deactivate the Entry entirely, because i need my input commands from the buttons for it to work.
from Tkinter import *
root = Tk()
root.title("Calculadora")
root.resizable(height = False, width = False)
#functions------------------------------------------------------------------
display_input = StringVar()
number_storage = ""
def button_click(buttons):
global number_storage
number_storage = number_storage + str(buttons)
display_input.set(number_storage)
#row 1---------------------------------------------------------------------------
display = Entry(root, textvariable = display_input, justify = 'right', font = ("Simplified Arabian Fixed", 18), bg = "black", fg = "white", bd = 25).grid(columnspan = 4)
Button7 = Button(root, command = lambda: button_click(7), bd = 10, text= "7", padx = 9, font = ("Simplified Arabian Fixed", 15), bg = "black", fg = "white").grid(column = 0, row = 1, sticky = 'ew')
Button8 = Button(root, command = lambda: button_click(8), bd = 10, text = "8", padx = 9, font = ("Simplified Arabian Fixed", 15), bg = "black", fg = "white").grid(column = 1, row = 1, sticky = 'ew')
Button9 = Button(root, command = lambda: button_click(9), bd = 10, text = "9", padx = 9, font = ("Simplified Arabian Fixed", 15), bg = "black", fg = "white").grid(column = 2, row = 1, sticky = 'ew')
Division = Button(root, command = lambda: button_click("/"), bd = 10, text = "/", padx = 9, font = ("Simplified Arabian Fixed", 15), bg = "grey30", fg = "white").grid(column = 3, row = 1, sticky = 'ew')
root.mainloop()
Pass state="readonly" when constructing the Entry; it still allows selecting the text, and changing display_input programmatically still changes the display, but it doesn't allow direct user input.
Per the docs:
state=
The entry state: NORMAL, DISABLED, or “readonly” (same as DISABLED, but contents can still be selected and copied). Default is NORMAL. Note that if you set this to DISABLED or “readonly”, calls to insert and delete are ignored. (state/State)