How to reconfig Tkinter scrolled text - python

I have this situation where I need to make the scrolledText as readonly, so the user can only add values to it through a button, like the following:
from tkinter import *
from tkinter import scrolledtext
startingWin = Tk()
myEntry = Entry(startingWin, font=("Courier",25, "bold"), width=15)
myScrolledText = scrolledtext.ScrolledText(startingWin, font=("Courier",25, "bold"),width=15, height=3, state='disabled')
def addEntryContentToScrolledText(entry, scrolledText):
entryValue = str((entry.get()).strip())
scrolledtext.config(state='normal')
if entryValue not in str(scrolledText.get('1.0', 'end-1c')) and entryValue != "":
scrolledText.insert(INSERT, (entryValue + "\n"))
scrolledtext.config(state='disabled')
myAddButton = Button(startingWin, text="Add")
myAddButton.config(command=lambda: addEntryContentToScrolledText(myEntry, myScrolledText))
myScrolledText.grid(row=0, column=1)
myEntry.grid(row=0, column=0)
myAddButton.grid(row=1, column=0)
startingWin.mainloop()
However, I get this error AttributeError: module 'tkinter.scrolledtext' has no attribute 'config'
How can I reconfigure the scrolledText?

Your widget name is myScrolledText, not scrolledtext: (scrolledtext is the imported module name)
from tkinter import *
from tkinter import scrolledtext
startingWin = Tk()
myEntry = Entry(startingWin, font=("Courier",25, "bold"), width=15)
myScrolledText = scrolledtext.ScrolledText(startingWin, font=("Courier",25, "bold"),width=15, height=3, state='disabled')
def addEntryContentToScrolledText(entry, textwidget):
entryValue = str((entry.get()).strip())
textwidget.configure(state='normal')
if entryValue not in str(textwidget.get('1.0', 'end-1c')) and entryValue != "":
textwidget.insert(INSERT, (entryValue + "\n"))
textwidget.configure(state='disabled')
myAddButton = Button(startingWin, text="Add", command=lambda: addEntryContentToScrolledText(myEntry, myScrolledText))
myScrolledText.grid(row=0, column=1)
myEntry.grid(row=0, column=0)
myAddButton.grid(row=1, column=0)
startingWin.mainloop()

Related

Q: Why 'Label' object has no attribute 'set'

This is my math game but, when 'ask' str is update its error and question isn't change.
I try to solved it by change the code position but it didn't work.
Error detected:
line 25, in retrieve_input
..... question_str.set(ask)
..... AttributeError: 'Label' object has no attribute 'set'
from tkinter import *
import random
import time
End = False
score=0
question=['13**2','5+1','60*2']
random.shuffle(question)
ask=question.pop()
text = ('text')
#command
def retrieve_input():
global ans,score,ask
if len(question)!=0:
ans=textBox.get("1.0","end-1c")
print(ans)
if int(ans) == int(eval(ask)):
score=int(score)+1
status_str.set('Score '+str(score))
random.shuffle(question)
ask=question.pop()
question_str.set(ask)
return score,ask
#app window
window = Tk()
window.title('Math Problem')
window.geometry('700x400')
#score
status_str = StringVar()
status_str.set('Score '+str(score))
show_status = Label(window, textvariable=status_str)
show_status.pack(pady=20)
#question
question_str = StringVar()
question_str.set(ask)
question_str = Label(window, textvariable=question_str)
question_str.pack(pady=25)
#answer box
textBox=Text(window, height=1, width=25, font=(100), borderwidth=(10))
textBox.pack(pady=10)
#submit button
buttonsubmit=Button(window, height=1, width=10, text="Submit", command=lambda: retrieve_input())
buttonsubmit.pack(pady=10)
#text
text_str = StringVar()
text_str.set(text)
text_str = Label(window, textvariable=text_str, font=(28))
text_str.pack(pady=30)
window.mainloop()
what happened is not a big deal just try to make a different names for each item because python confused for getting from the label I tried the code and it worked successfully
the code:
from tkinter import *
import random
import time
End = False
score=0
question=['13**2','5+1','60*2']
random.shuffle(question)
ask=question.pop()
text = ('text')
#command
def retrieve_input():
global ans,score,ask
if len(question)!=0:
ans=textBox.get("1.0","end-1c")
print(ans)
if int(ans) == int(eval(ask)):
score=int(score)+1
status_str.set('Score '+str(score))
random.shuffle(question)
ask=question.pop()
question_str.set(ask)
return score,ask
#app window
window = Tk()
window.title('Math Problem')
window.geometry('700x400')
#score
status_str = StringVar()
status_str.set('Score '+str(score))
show_status = Label(window, textvariable=status_str)
show_status.pack(pady=20)
#question
question_str = StringVar()
question_str.set(ask)
question_str_label = Label(window, textvariable=question_str)
question_str_label.pack(pady=25)
#answer box
textBox=Text(window, height=1, width=25, font=(100), borderwidth=(10))
textBox.pack(pady=10)
#submit button
buttonsubmit=Button(window, height=1, width=10, text="Submit", command=lambda: retrieve_input())
buttonsubmit.pack(pady=10)
#text
text_str = StringVar()
text_str.set(text)
text_str = Label(window, textvariable=text_str, font=(28))
text_str.pack(pady=30)
window.mainloop()

in tkinter how do i get a number into an entry

Im a beginner in Python and running into the following problem:
for an assignment i need to get the number that gets inserted into text1, then when i push the button pk<<<kw multiply it by 1.36 and insert it into text2. and reverse by pressing the other button.
only i have no clue how.
from tkinter import *
root= Tk()
root.title("python programma omrekenen")
root.geometry("300x200")
def Iets():
label = Label(text="vermogen in pk:")
label.place(x=50,y=50)
text1=IntVar()
entry1=Entry(textvariable=text1)
entry1.place(x=150,y=50)
x1=text1.get()
def Functie 10:
def Functie 11:
button=Button (text="PK>>>KW", command=Functie10)
button.place (x=50,y=100)
button=Button (text="PK<<<KW", command=functie11)
button.place (x=150,y=150)
label = Label(text="vermogen in KW:")
label.place(x=50,y=150)
text2=IntVar()
entry2=Entry(textvariable=text2)
entry2.place(x=150,y=150)
x2=text2.get()
root.mainloop()
sorry for the bad english
That little code should hopefully help you out :
from tkinter import *
root = Tk()
root.title("python programma omrekenen")
root.geometry("300x200")
def Iets():
Entry1 = Entry(root, bd=4)
Entry1.grid(row=1, column=2)
Entry1.delete(0, END)
Entry1.insert(0, "Insert number")
Entry2 = Entry(root, bd=4)
Entry2.grid(row=2, column=2)
Entry2.insert(0, "Result")
def multiply(entry: int):
if entry == 1:
Entry2.delete(0, END)
try:
Entry2.insert(0, f"{int(Entry1.get()) * 2}")
except ValueError:
Entry2.insert(0, f"Invalid value")
Entry1.delete(0, END)
if entry == 2:
Entry1.delete(0, END)
try:
Entry1.insert(0, f"{int(Entry2.get()) * 2}")
except ValueError:
Entry1.insert(0, f"Invalid value")
Entry2.delete(0, END)
Button1 = Button(root, text='Multiply', bd=2, bg='green', command=lambda: multiply(1))
Button1.grid(row=1, column=1)
Button2 = Button(root, text='Multiply', bd=2, bg='green', command=lambda: multiply(2))
Button2.grid(row=2, column=1)
Iets()
root.mainloop()
Not sure if thats what you ment by reverse it but yeah.. its easy to understand so you should be fine !
command is used to call a function.
In your case , it does a multiplication on a number and gets inserted into an entry field.
Also , delete & insert are 2 tkinter methods clear & insert the data respectively
from tkinter import *
root= Tk()
root.title("python programma omrekenen")
root.geometry("300x400")
text1=IntVar()
text2=IntVar()
def first():
entry2.delete(0,END)
entry2.insert(0,text1.get()*1.36)
def second():
entry1.delete(0,END)
entry1.insert(0,text2.get()*1.36)
label = Label(text="vermogen in pk:")
label.place(x=50,y=50)
entry1=Entry(textvariable=text1)
entry1.place(x=150,y=50)
button=Button (text="PK>>>KW", command=first)
button.place (x=50,y=100)
button=Button (text="PK<<<KW", command=second)
button.place (x=50,y=200)
label = Label(text="vermogen in KW:")
label.place(x=50,y=150)
entry2=Entry(textvariable=text2)
entry2.place(x=150,y=150)
root.mainloop()

How to format the text input from Text Widget in Tkinter

In my tkinter program I'm collecting text from the user using Text widget, this is later printed on the screen using a label widget. Although I'm able to print it onto the screen, the text is all center aligned. Since what I'm collecting is a procedure for something it gets difficult to read, so I need it to be left aligned.
This is my Procedure method -
Once the procedure is collected it is stored into a dictionary
def Procedure(self):
textfield = Text(gui, height=30, width=82)
textfield.place(x="20", y="100")
procedure_label = LabelWidget(self.screen, "Procedure", "Courier", 40)
procedure_label.Call().place(x="220", y="20")
button_save = Button(gui, text="Next", padx="50", pady="20", bg="lightgrey",
command=partial(self.CheckPage, 4, procedure=textfield))
button_save.place(x="250", y="600")
This is how I'm printing my proceudre
proc_text_label = ""
for i in fullDictProc:
proc_text_label_temp = Label(root, text=i, wraplength=900)
proc_text_label = proc_text_label_temp
proc_text_label.config(font=("Courier", 12))
proc_text_label.place(x=70, y=250)
Here is a minimal reproducible code to demonstrate the problem
Run it and see the alignment of the text.
from tkinter import *
from functools import partial
gui = Tk()
gui.geometry("700x700")
def printit(textfield):
procedure_list = [textfield.get("1.0", "end-1c")]
textfield.place_forget()
proc_text_label = ""
for i in procedure_list:
proc_text_label_temp = Label(gui, text=i, wraplength=900)
proc_text_label = proc_text_label_temp
proc_text_label.config(font=("Courier", 12))
proc_text_label.place(x=70, y=250)
textfield = Text(gui, height=30, width=82)
textfield.place(x="20", y="100")
button_save = Button(gui, text="Next", padx="50", pady="20", bg="lightgrey",
command=partial(printit, textfield))
button_save.place(x=500, y=600)
gui.mainloop()
I think what you are looking for might be justify:
proc_text_label.config(justify='left')
Have a look at The Tkinter Label Widget
I think what you're looking for is the anchor parameter.
This is how it worked with your minimal example:
from tkinter import *
from functools import partial
gui = Tk()
gui.geometry("700x700")
def printit(textfield):
procedure_list = [textfield.get("1.0", "end-1c")]
textfield.place_forget()
proc_text_label = ""
for i in procedure_list:
proc_text_label_temp = Label(gui, text=i, wraplength=900,
anchor='w',
bg='blue',
width=50)
proc_text_label = proc_text_label_temp
proc_text_label.config(font=("Courier", 12))
proc_text_label.place(x=70, y=250)
textfield = Text(gui, height=30, width=82)
textfield.place(x="20", y="100")
button_save = Button(gui, text="Next", padx="50", pady="20", bg="lightgrey",
command=partial(printit, textfield))
button_save.place(x=500, y=600)
gui.mainloop()

get entered text and exit if the text in mass (tkinter)

good day! here's my code:
import tkinter as tk
namemass =["dev", "Dev1"]
self.entry_name = ttk.Entry(self)
self.entry_name.place(x=200, y=50)
btn_cancel = ttk.Button(self, text="cancel", command=self.destroy)
btn_cancel.place(x=300, y=800)
btn_ok = ttk.Button(self, text="ok")
btn_ok.place(x=320, y=170)
so, i have 2 buttons and enter box. I want the program to get the text from the enter box and if namemass list have that inside, then exit. in console program i would code it like that:
name = input()
namemass = ["dev", "Dev1"]
if name in namemass:
import sys
sys.exit()
else:
..........
how to do it using tkinter? thank you in advance!
To fetch the current entry text, use the get method:
current_text = Entry.get()
in your example you can just:
from tkinter import *
import sys
def destroy():
name = entry_name.get()
if name in namemass:
sys.exit()
root = Tk()
namemass = ["dev", "Dev1"]
entry_name = Entry(root)
entry_name.pack()
btn_cancel = Button(root, text="cancel", command=destroy)
btn_cancel.pack()
btn_ok = Button(root, text="ok")
btn_ok.pack()
root.mainloop()
Much easier for Python 3.8, using Walrus. Just add the function for _ok. And add command in btn_ok.
from tkinter import *
import sys
namemass = ["dev", "Dev1"]
def destroy():
#sys.exit()
root.destroy()
def _ok():
if(name_in_list := entry_name.get()) in namemass:
sys.exit()
root = Tk()
entry_name = Entry(root)
entry_name.pack()
btn_cancel = Button(root, text="cancel", command=destroy)
btn_cancel.pack()
btn_ok = Button(root, text="ok", command=_ok)
btn_ok.pack()
root.mainloop()

An unexpected window appears in tkinter python

I made a separate file called clinic1.py for the other code and import it to the main page. Everything works fine however another window appears when I click save button on the add new item page.
When I place all the code on the main page that small window doesn't appear.
I cant find whats causing another window to appear when it's in a separate file.
This is my main page:
from tkinter import *
from tkinter import ttk
import tkinter.messagebox
large_font = ('Verdana',12)
storedusername =['foo'] storedpass=['123'] storedretype=[]
list_of_users=storedusername
list_of_passwords=storedpass
def all_clinic_frames(event):
combo_clinic=combo.get()
if combo_clinic == 'Clinic 1':
enter()
root = Tk()
root.geometry('800x600')
root.title('CSSD')
topFrame=Frame(root,width=800,height=100,padx=310)
area=Label(topFrame,text='CSSD')
area.config(font=("Courier", 50))
frame=Frame(root,highlightbackground="black", highlightcolor="black", highlightthickness=1, width=100, height=100, bd= 0)
frame.place(relx=.5, rely=.5, anchor="center")
username = Label(frame, text='User Name') username.config(font='Arial',width=15) password = Label(frame, text='Password') password.config(font='Arial',width=15) enteruser = Entry(frame, textvariable=StringVar(),font=large_font) enterpass = Entry(frame, show='*', textvariable=StringVar(),font=large_font)
combo_choice=StringVar()
combo=ttk.Combobox(frame,textvariable=combo_choice)
combo['values']=('Clinic 1')
combo.state(['readonly'])
combo.grid(row=0,sticky=NW)
combo.set('Choose Area...')
combo.bind('<<ComboboxSelected>>',all_clinic_frames)
topFrame.grid(row=0,sticky=N) topFrame.grid_propagate(False) area.grid(row=0,column=1,sticky=N) username.grid(row=1, sticky=E) enteruser.grid(row=1, column=1) password.grid(row=2, sticky=E) enterpass.grid(row=2, column=1)
def valid():
usernameRight=enteruser.get()
passwordRight=enterpass.get()
while True:
try:
if (usernameRight==list_of_users[0]) and (passwordRight==list_of_passwords[0]):
import clinic1
clinic1.main_page()
quit()
break
except IndexError:
invalid = Label(frame, text='User name or Password is incorrect!', fg='red')
invalid.grid(row=3, columnspan=2)
break
def enter():
register = Button(frame, text='Sign In',relief=RAISED,fg='white',bg='red',command=valid)
register.grid(row=3,column=1,ipadx=15,sticky=E)
def quit():
root.destroy()
And this is the second file that I imported in the main page which i saved as clinic1.py
from tkinter import*
import tkinter.messagebox
newInstList=[]
def addItem(event=None):
global back_add,quantityentry,itemEntry,itemEntry1,quantityentry1
itemFrameTop=Frame(root, width=800,height=100,bg='pink')
itemFrameTop.grid_propagate(False)
itemFrameTop.grid(row=0)
area1_item = Label(itemFrameTop, text='CSSD', pady=5,padx=230)
area1_item.config(font=("Courier", 30))
area1_item.grid_propagate(False)
area1_item.grid(row=0,column=1,sticky=NE)
clinic_1 = Label(itemFrameTop, text='Clinic 1', bg='red', fg='white', bd=5)
clinic_1.config(font=("Courier", 15))
clinic_1.grid_propagate(False)
clinic_1.grid(row=1, sticky=W,padx=10)
itemFrameMid=Frame(root,width=700,height=600,bg='blue')
itemFrameMid.grid_propagate(False)
itemFrameMid.grid(row=1)
itemname=Label(itemFrameMid,text='Item name:')
itemname.config(font=('Arial,15'))
itemname.grid_propagate(False)
itemname.grid(row=1,sticky=E)
quantity=Label(itemFrameMid,text='Qty:')
quantity.config(font=('Arial,15'))
quantity.grid_propagate(False)
quantity.grid(row=1,column=3, sticky=E,padx=10)
itemEntry=Entry(itemFrameMid)
itemEntry.config(font=('Arial,15'))
itemEntry.grid(row=1,column=1,sticky=EW,padx=30,pady=10)
itemEntry1 = Entry(itemFrameMid)
itemEntry1.config(font=('Arial,15'))
itemEntry1.grid(row=2, column=1)
quantityentry=Entry(itemFrameMid,width=5)
quantityentry.config(font=('Arial',15))
quantityentry.grid(row=1, column=4)
quantityentry1 = Entry(itemFrameMid, width=5)
quantityentry1.config(font=('Arial', 15))
quantityentry1.grid(row=2, column=4,padx=10)
"""When I click save button another small window appears"""
okbutton = Button(itemFrameMid, text='Save', command=saveCheck)
okbutton.config(font=('Arial', 12))
okbutton.grid(row=3, column=4, padx=15)
back_add = Label(itemFrameTop, text='Back')
back_add.config(font=('Courier,15'))
back_add.grid(row=0, sticky=W, padx=30)
back_add.bind('<Button-1>', main_page)
back_add.bind('<Enter>', red_text_back1)
back_add.bind('<Leave>', black_text_back1)
def saveCheck():
saveQuestion=tkinter.messagebox.askquestion('CSSD', 'Are you sure you want to save?')
if saveQuestion == 'yes':
newInstList.append(itemEntry.get())
newInstList.append(quantityentry.get())
newInstList.append(itemEntry1.get())
newInstList.append(quantityentry1.get())
print(newInstList)
main_page()
elif saveQuestion == 'no':
pass
def red_text_back1(event=None):
back_add.config(fg='red')
def black_text_back1(event=None):
back_add.config(fg='black')
def red_text_add(event=None):
addnew.config(fg='red')
def black_text_add(event=None):
addnew.config(fg='black')
def main_page(event=None):
global addnew,usedInst,logOut
frame1 = Frame(root, width=800, height=100,bg='pink')
frame1.grid(row=0, column=0, sticky="nsew")
frame1.grid_propagate(False)
midframe1=Frame(root,width=800,height=600)
midframe1.grid_propagate(False)
midframe1.grid(row=1)
area1 = Label(frame1, text='CSSD',pady=5,padx=350)
area1.config(font=("Courier", 30))
area1.grid(row=0)
clinic1=Label(frame1,text='Clinic 1',bg='red',fg='white',bd=5)
clinic1.config(font=("Courier", 15))
clinic1.grid_propagate(False)
clinic1.grid(row=1,sticky=W,padx=10)
addnew=Label(midframe1,text='+ Add new item')
addnew.config(font=('Arial',15))
addnew.grid(row=2,column=1,sticky=E,ipadx=50)
addnew.bind('<Button-1>', addItem)
addnew.bind('<Enter>', red_text_add)
addnew.bind('<Leave>', black_text_add)
root = Tk()
root.geometry('800x600')
Both files have this line of code:
root = Tk()
Each time you do that, you get another root window. A tkinter application needs to have exactly one instance of Tk running at a time.
You need to remove the last two lines from clinic1.py. You will also need to pass in the reference to root to any methods from clinic1.py that need it.
First file.
from tkinter import *
from tkinter import ttk
import tkinter.messagebox
large_font = ('Verdana',12)
storedusername =['foo']
storedpass=['123']
storedretype=[]
list_of_users=storedusername
list_of_passwords=storedpass
def all_clinic_frames(event):
combo_clinic=combo.get()
if combo_clinic == 'Clinic 1':
enter()
root = Tk()
root.geometry('800x600')
root.title('CSSD')
topFrame=Frame(root,width=800,height=100,padx=310)
area=Label(topFrame,text='CSSD')
area.config(font=("Courier", 50))
frame=Frame(root,highlightbackground="black", highlightcolor="black", highlightthickness=1, width=100, height=100, bd= 0)
frame.place(relx=.5, rely=.5, anchor="center")
myvar=StringVar()
username = Label(frame, text='User Name')
username.config(font='Arial',width=15)
password = Label(frame, text='Password')
password.config(font='Arial',width=15)
enteruser = Entry(frame, textvariable=myvar, font=large_font)
pass1=StringVar()
enterpass = Entry(frame, show='*', textvariable=pass1, font=large_font)
combo_choice=StringVar()
combo=ttk.Combobox(frame,textvariable=combo_choice)
combo['values']=[('Clinic 1')]
combo.state(['readonly'])
combo.grid(row=0,sticky=NW)
combo.set('Choose Area...')
combo.bind('<<ComboboxSelected>>',all_clinic_frames)
topFrame.grid(row=0,sticky=N)
topFrame.grid_propagate(False)
area.grid(row=0,column=1,sticky=N)
username.grid(row=1, sticky=E)
enteruser.grid(row=1, column=1)
password.grid(row=2, sticky=E)
enterpass.grid(row=2, column=1)
def valid():
usernameRight=enteruser.get()
passwordRight=enterpass.get()
while True:
try:
if (usernameRight==list_of_users[0]) and (passwordRight==list_of_passwords[0]):
import clinic1
clinic1.main_page(root)
# quit()
break
except IndexError:
invalid = Label(frame, text='User name or Password is incorrect!', fg='red')
invalid.grid(row=3, columnspan=2)
break
def enter():
register = Button(frame, text='Sign In',relief=RAISED,fg='white',bg='red',command=valid)
register.grid(row=3,column=1,ipadx=15,sticky=E)
def quit():
root.destroy()
root.mainloop()
clinic1.py
from tkinter import*
import tkinter.messagebox
newInstList=[]
def addItem(root, event=None):
global back_add,quantityentry,itemEntry,itemEntry1,quantityentry1
if event is None:
event = Event()
itemFrameTop=Frame(root, width=800, height=100, bg='pink')
itemFrameTop.grid_propagate(False)
itemFrameTop.grid(row=0)
area1_item = Label(itemFrameTop, text='CSSD', pady=5,padx=230)
area1_item.config(font=("Courier", 30))
area1_item.grid_propagate(False)
area1_item.grid(row=0,column=1,sticky=NE)
clinic_1 = Label(itemFrameTop, text='Clinic 1', bg='red', fg='white', bd=5)
clinic_1.config(font=("Courier", 15))
clinic_1.grid_propagate(False)
clinic_1.grid(row=1, sticky=W,padx=10)
itemFrameMid=Frame(root,width=700,height=600,bg='blue')
itemFrameMid.grid_propagate(False)
itemFrameMid.grid(row=1)
itemname=Label(itemFrameMid,text='Item name:')
itemname.config(font=('Arial,15'))
itemname.grid_propagate(False)
itemname.grid(row=1,sticky=E)
quantity=Label(itemFrameMid,text='Qty:')
quantity.config(font=('Arial,15'))
quantity.grid_propagate(False)
quantity.grid(row=1,column=3, sticky=E,padx=10)
itemEntry=Entry(itemFrameMid)
itemEntry.config(font=('Arial,15'))
itemEntry.grid(row=1,column=1,sticky=EW,padx=30,pady=10)
itemEntry1 = Entry(itemFrameMid)
itemEntry1.config(font=('Arial,15'))
itemEntry1.grid(row=2, column=1)
quantityentry=Entry(itemFrameMid,width=5)
quantityentry.config(font=('Arial',15))
quantityentry.grid(row=1, column=4)
quantityentry1 = Entry(itemFrameMid, width=5)
quantityentry1.config(font=('Arial', 15))
quantityentry1.grid(row=2, column=4,padx=10)
"""When I click save button another small window appears"""
okbutton = Button(itemFrameMid, text='Save', command=lambda: saveCheck(root))
okbutton.config(font=('Arial', 12))
okbutton.grid(row=3, column=4, padx=15)
back_add = Label(itemFrameTop, text='Back')
back_add.config(font=('Courier,15'))
back_add.grid(row=0, sticky=W, padx=30)
back_add.bind('<Button-1>', main_page)
back_add.bind('<Enter>', red_text_back1)
back_add.bind('<Leave>', black_text_back1)
def saveCheck(root):
saveQuestion=tkinter.messagebox.askquestion('CSSD', 'Are you sure you want to save?')
if saveQuestion == 'yes':
newInstList.append(itemEntry.get())
newInstList.append(quantityentry.get())
newInstList.append(itemEntry1.get())
newInstList.append(quantityentry1.get())
print(newInstList)
main_page(root)
elif saveQuestion == 'no':
pass
def red_text_back1(event=None):
back_add.config(fg='red')
def black_text_back1(event=None):
back_add.config(fg='black')
def red_text_add(event=None):
addnew.config(fg='red')
def black_text_add(event=None):
addnew.config(fg='black')
def main_page(root):
global addnew,usedInst,logOut
frame1 = Frame(root, width=800, height=100,bg='pink')
frame1.grid(row=0, column=0, sticky="nsew")
frame1.grid_propagate(False)
midframe1=Frame(root,width=800,height=600)
midframe1.grid_propagate(False)
midframe1.grid(row=1)
area1 = Label(frame1, text='CSSD',pady=5,padx=350)
area1.config(font=("Courier", 30))
area1.grid(row=0)
clinic1=Label(frame1,text='Clinic 1',bg='red',fg='white',bd=5)
clinic1.config(font=("Courier", 15))
clinic1.grid_propagate(False)
clinic1.grid(row=1,sticky=W,padx=10)
addnew=Button(midframe1,text='+ Add new item', font=('Arial', 15), command=lambda: addItem(root))
addnew.grid(row=2,column=1,sticky=E,ipadx=50)
# addnew.bind('<Button-1>', lambda r=root: addItem(r))
addnew.bind('<Enter>', red_text_add)
addnew.bind('<Leave>', black_text_add)

Categories