button command problems tkinter - python

I have the following scraper:
I want to do an action to import the links when I click the button that corresponds to each one.
def ListarPeliculas(win, canvas, box_formulario, paginacion):
canvas.config(bg='#CCC')
#canvas.pack(side=LEFT, pady=20)
canvas.pack(side=LEFT, pady=20)
global scrollbar
scrollbar = Scrollbar(win, command=canvas.yview)
scrollbar.config(bg='#CCC')
scrollbar.pack(side=LEFT, pady=20, fill=Y)
canvas.configure(yscrollcommand=scrollbar.set)
def on_configure(event):
canvas.configure(scrollregion=canvas.bbox('all'))
canvas.bind('<Configure>', on_configure)
box_formulario.config(bg='#CCC', padx=40)
canvas.create_window((0, 0), window=box_formulario, anchor='n')
url = 'https://divxtotal7.com/peliculas/page/'+paginacion.get()
header = var.user_agent
r = requests.get(url, headers=header)
soup = html.fromstring(r.text)
links_posts = soup.xpath('//ul[#class="miniboxs miniboxs-ficha"]//div[#class="meta"]/a/#href')
titulos_posts = soup.xpath('//ul[#class="miniboxs miniboxs-ficha"]//div[#class="meta"]/a/text()')
idiomas = soup.xpath('//ul[#class="miniboxs miniboxs-ficha"]//div[#class="imagen"]//img[#class="lazy"]/#src')
row = 1
count = 0
for link_post, titulo_post, idioma in zip(links_posts, titulos_posts, idiomas):
if idioma == '/images/espanolEspañol.png' or idioma == '/images/espanolEspanol.png':
idioma = 'Español España'
elif idioma == '/images/espanolVOSE.png':
idioma = 'Subtitulado a español'
elif idioma == '/images/espanolEspanol Latino.png':
idioma = 'Español Latino'
numero = Label(box_formulario, text=str(row))
numero.config(bg='#CCC', fg='black', font=('Arial', 10), pady=5)
numero.grid(row=row, column=0, sticky='nw')
#name_peliculas = Label(box_formulario, text=titulo_post)
#name_peliculas.config(bg='#CCC', fg='black', font=('Arial', 8), pady=5)
#name_peliculas.grid(row=row, column=1, sticky='n')
peliculas_listada = Label(box_formulario, text=link_post, textvariable=link_post)
peliculas_listada.config(bg='#CCC', fg='black', font=('Arial', 10), pady=5)
peliculas_listada.grid(row=row, column=1, sticky='n', columnspan=2, padx=60)
idioma_listada = Label(box_formulario, text=idioma)
idioma_listada.config(bg='#CCC', fg='black', font=('Arial', 10), pady=5)
idioma_listada.grid(row=row, column=3, sticky='nw')
importar = Button(box_formulario, text='Importar', command=lambda: [print(link_post)])
importar.config(bg='orange', font=('Arial', 10, 'bold'))
importar.grid(row=row, column=4, sticky='e', padx=25, pady=5)
count += 1
row += 1
but when I get the link I get the last link and not what corresponds to each one
What I get every time I click on any button is the following link, the same one and not the one that corresponds to each one
https://divxtotal7.com/descargar/43813/padre,-soldado,-hijo/
https://divxtotal7.com/descargar/43813/padre,-soldado,-hijo/

thanks to the user the solution was this
def ListarPeliculas(win, canvas, box_formulario, paginacion):
canvas.config(bg='#CCC')
#canvas.pack(side=LEFT, pady=20)
canvas.pack(side=LEFT, pady=20)
global scrollbar
scrollbar = Scrollbar(win, command=canvas.yview)
scrollbar.config(bg='#CCC')
scrollbar.pack(side=LEFT, pady=20, fill=Y)
canvas.configure(yscrollcommand=scrollbar.set)
def on_configure(event):
canvas.configure(scrollregion=canvas.bbox('all'))
canvas.bind('<Configure>', on_configure)
box_formulario.config(bg='#CCC', padx=40)
canvas.create_window((0, 0), window=box_formulario, anchor='n')
url = 'https://divxtotal7.com/peliculas/page/'+paginacion.get()
header = var.user_agent
r = requests.get(url, headers=header)
soup = html.fromstring(r.text)
links_posts = soup.xpath('//ul[#class="miniboxs miniboxs-ficha"]//div[#class="meta"]/a/#href')
titulos_posts = soup.xpath('//ul[#class="miniboxs miniboxs-ficha"]//div[#class="meta"]/a/text()')
idiomas = soup.xpath('//ul[#class="miniboxs miniboxs-ficha"]//div[#class="imagen"]//img[#class="lazy"]/#src')
row = 1
count = 0
for link_post, titulo_post, idioma in zip(links_posts, titulos_posts, idiomas):
if idioma == '/images/espanolEspañol.png' or idioma == '/images/espanolEspanol.png':
idioma = 'Español España'
elif idioma == '/images/espanolVOSE.png':
idioma = 'Subtitulado a español'
elif idioma == '/images/espanolEspanol Latino.png':
idioma = 'Español Latino'
numero = Label(box_formulario, text=str(row))
numero.config(bg='#CCC', fg='black', font=('Arial', 10), pady=5)
numero.grid(row=row, column=0, sticky='nw')
#name_peliculas = Label(box_formulario, text=titulo_post)
#name_peliculas.config(bg='#CCC', fg='black', font=('Arial', 8), pady=5)
#name_peliculas.grid(row=row, column=1, sticky='n')
peliculas_listada = Label(box_formulario, text=link_post, textvariable=link_post)
peliculas_listada.config(bg='#CCC', fg='black', font=('Arial', 10), pady=5)
peliculas_listada.grid(row=row, column=1, sticky='n', columnspan=2, padx=60)
idioma_listada = Label(box_formulario, text=idioma)
idioma_listada.config(bg='#CCC', fg='black', font=('Arial', 10), pady=5)
idioma_listada.grid(row=row, column=3, sticky='nw')
importar = Button(box_formulario, text='Importar', command=lambda link=link_post: print(link))
importar.config(bg='orange', font=('Arial', 10, 'bold'))
importar.grid(row=row, column=4, sticky='e', padx=25, pady=5)
count += 1
row += 1

Related

When I click a global tkinter button, works only the first time

There are four buttons that hide or show a canvas. When I clicked the first time it work but then I don't really know it doesn't work. I made the buttons global because I need to reposition them depending on the canvas. How can I fix this? The function show_shares and show_DividendGrowth are the single ones that are used and they are creating some table cells and charts.
from tkinter import ttk
import pygsheets
from tkinter import *
from Shares import show_shares
from DividendGrowth import show_DividendGrowth
from MonthlyDividend import show_MonthlyDividend
from Evolution import showEvolution
client = pygsheets.authorize(service_account_file="dividend-portfolio.json")
sh = client.open('Portfolio')
wk1 = sh.sheet1
window = Tk()
window.title('Dividend Portfolio')
window.attributes('-fullscreen', True)
container = ttk.Frame(window)
container.pack(fill="both", expand=1)
canvas = Canvas(container)
scrollable_frame = ttk.Frame(canvas)
scrollbar_vertical = ttk.Scrollbar(container, orient="vertical", command=canvas.yview)
scrollbar_vertical.pack(side="right", fill="y")
canvas.configure(yscrollcommand=scrollbar_vertical.set)
canvas.bind('<Configure>', lambda e: canvas.configure(scrollregion=canvas.bbox("all")))
canvas.pack(fill=BOTH, expand=1)
canvas.create_window((0, 0), window=scrollable_frame, anchor="nw")
current_page = [0, 0, 0, 0]
shares_canvas = Canvas(scrollable_frame)
dividendGrowth_canvas = Canvas(scrollable_frame)
monthlyDividend_canvas = Canvas(scrollable_frame)
evolution_canvas = Canvas(scrollable_frame)
global shares_button, dividendGrowth_button, monthlyDividend_button, evolution_button
def placeButtons(master):
global shares_button, dividendGrowth_button, monthlyDividend_button, evolution_button
shares_button = Button(master, text="Actiuni", borderwidth=2,relief="solid", width=9, height=1, font=("Calibri", 13), bg="dodgerblue", fg="white")
dividendGrowth_button = Button(master, text="Dividende si cresteri", borderwidth=2, relief="solid", width=16, height=1, font=("Calibri", 13), bg="dodgerblue", fg="white")
monthlyDividend_button = Button(master, text="Dividende lunare", borderwidth=2, relief="solid", width=14, height=1, font=("Calibri", 13), bg="dodgerblue", fg="white")
evolution_button = Button(master, text="Evolutie", borderwidth=2,relief="solid", width=9, height=1, font=("Calibri", 13), bg="dodgerblue", fg="white")
def start(current_page):
if current_page[0] == 0:
current_page = [1, 0, 0, 0]
show_shares(shares_canvas)
shares_canvas.grid()
dividendGrowth_canvas.grid_forget()
monthlyDividend_canvas.grid_forget()
evolution_canvas.grid_forget()
placeButtons(shares_canvas)
shares_button.grid(row=102, column=0, columnspan=2, padx=6, pady=4, sticky=W)
dividendGrowth_button.grid(row=102, column=0, columnspan=3, padx=90, pady=4, sticky=E)
monthlyDividend_button.grid(row=102, column=1, columnspan=4, padx=47, sticky=W)
evolution_button.grid(row=102, column=3, columnspan=4, padx=56, sticky=W)
start(current_page)
def showShares(event, current_page):
start(current_page)
def showDividendGrowth(event, current_page):
if current_page[1] == 0:
current_page = [0, 1, 0, 0]
shares_canvas.grid_forget()
monthlyDividend_canvas.grid_forget()
evolution_canvas.grid_forget()
show_DividendGrowth(dividendGrowth_canvas)
dividendGrowth_canvas.grid()
placeButtons(dividendGrowth_canvas)
shares_button.grid(row=102, column=0, columnspan=2, padx=6, pady=4, sticky=W)
dividendGrowth_button.grid(row=102, column=0, columnspan=4, padx=101, pady=4, sticky=W)
monthlyDividend_button.grid(row=102, column=1, columnspan=5, padx=157, sticky=W)
evolution_button.grid(row=102, column=3, columnspan=4, padx=53, sticky=W)
scrollbar_orizontal = ttk.Scrollbar(container, orient="horizontal", command=canvas.xview)
scrollbar_orizontal.pack(side="bottom", fill="x")
canvas.configure(xscrollcommand=scrollbar_orizontal.set)
shares_button.bind('<Button-1>', lambda event: show_shares(event))
dividendGrowth_button.bind('<Button-1>', lambda event: showDividendGrowth(event, current_page))
window.mainloop()

How to solve the "bad window path name ".!labelframe.!canvas.!frame" error in tkinter python?

This is my code:
mycanvas = Canvas(self.search_result_frame)
mycanvas.pack(side=LEFT)
yscrollbar = ttk.Scrollbar(self.search_result_frame, orient="vertical", command=mycanvas.yview)
yscrollbar.pack(side=RIGHT, fill=Y)
mycanvas.configure(yscrollcommand=yscrollbar.set)
mycanvas.bind('<Configure>', lambda e: mycanvas.configure(scrollregion = mycanvas.bbox('all')))
self.sample_frame = Frame(mycanvas)
mycanvas.create_window((0,0), window=self.sample_frame, anchor=E)
for widget in self.search_result_frame.winfo_children():
widget.destroy()
if len(matching_bills) > 0:
for bill in matching_bills:
with open(f'{self.bill_folder}//{bill}//data//bill_details.json', 'r') as bill_json_file:
bill_details = json.loads(bill_json_file.read())
customer_name = bill_details["customer_details"][0]
payment_method = bill_details["payment_method"]
date_of_issue = bill_details["date_of_issue"]
date_of_issue = datetime.strptime(date_of_issue, "%d/%m/%Y")
date_of_issue = date_of_issue.strftime("%d %b %Y")
# # -------------------- Search Result Frame Contents
result_frame = Frame(self.sample_frame, bg=self.bg3, bd=5, relief=GROOVE)
result_frame.pack(fill=BOTH, pady=2)
result_billno_lbl = Label(result_frame, text=bill, bg=self.bg1, fg="#FFF", font=self.search_results_font1, padx=22, pady=3)
result_billno_lbl.grid(row=0, column=0, padx=50, pady=8, sticky=W)
billed_to_lbl = Label(result_frame, text=f"Billed To - {customer_name}", bg=self.bg1, fg="#FFF", font=self.search_results_font2, bd=2, relief=RAISED, padx=12, pady=3)
billed_to_lbl.grid(row=0, column=1, padx=80, sticky=W)
billed_type_lbl = Label(result_frame, text=f"Bill Type - {payment_method}", bg=self.bg1, fg="#FFF", font=self.search_results_font2, bd=2, relief=RAISED, padx=12, pady=3)
billed_type_lbl.grid(row=0, column=2, sticky=W)
issued_on_lbl = Label(result_frame, text=f"Issued On - {date_of_issue}", bg=self.bg1, fg="#FFF",
font=self.search_results_font2, bd=2, relief=RAISED, padx=12, pady=3)
issued_on_lbl.grid(row=0, column=3, padx=80, sticky=W)
view_btn = Button(result_frame, text="View", font="Comicsan 14", bd=2, relief=GROOVE, bg="#000", fg="#FFF", padx=1, command=lambda bill=bill: self.view_bill(bill))
view_btn.grid(row=0, column=4, padx=3, columnspan=2, sticky=W)
elif len(matching_bills) == 0:
for widgets in self.search_result_frame.winfo_children():
widgets.destroy()
no_result_lbl = Label(self.search_result_frame, text=f"No search result found for {bill_cat}", font=self.search_results_font1, bg=self.bg3, fg="#FFF")
no_result_lbl.pack(fill=X)
When I run it, it shows me the bad window path name ".!labelframe.!canvas.!frame error and when I try to do the same thing without object-oriented in tkinter then it works well !

I can't get data from user to calculate

I want to create a program that is a Bakery online shop but I'm stuck on a show bill page, I want to show the menu list, Amount, Price, Total of that cake or drink in one line and the last line is all total
this my code :
from tkinter import*
def mainwindow():
main = Tk()
x = main.winfo_screenwidth() / 2 - (w / 2)
y = main.winfo_screenheight() / 2 - (h / 2)
main.geometry("%dx%d+%d+%d" % (w, h, x, y))
main.title("Cake_Shop by Winit Auppkarasakun")
main.option_add("*font", "times 17 bold")
menubar = Menu(main)
filemenu = Menu(menubar, tearoff=False)
filemenu.add_command(label="Menu", command=menu)
filemenu.add_command(label="Checkout", command=checkout)
filemenu.add_command(label="Exit", command=main.quit)
menubar.add_cascade(label="File", menu=filemenu)
main.configure(bg="pink", menu=menubar)
return main
def menu():
frame1 = Frame(main, bg="yellow")
frame1.place(x=0, y=0, width=w, height=h)
frame1.columnconfigure((0,1), weight=1)
frame1.rowconfigure((0,1,2,3,4,5,6,7,8,9), weight=1)
Label(frame1, text="Strawberry Cake : ", bg="yellow", fg="blue", font="times 18 bold").grid(row=0, column=0)
Label(frame1, image = img_menu_1, bg="yellow").grid(row=1, column=0)
Label(frame1, text="Price 85", bg="yellow", fg="black").grid(row=2, column=0)
Spinbox(frame1, from_=0, to=10, textvariable=cake_spy1).grid(row=3, column=0)
Label(frame1, text="Cheese Cake : ", bg="yellow", fg="blue", font="times 18 bold").grid(row=4, column=0)
Label(frame1, image = img_menu_2, bg="yellow").grid(row=5, column=0)
Label(frame1, text="Price 95", bg="yellow", fg="black").grid(row=6, column=0)
Spinbox(frame1, from_=0, to=10, textvariable=cake_spy2).grid(row=7, column=0)
Label(frame1, text="Strawberry Mixed : ", bg="yellow", fg="blue", font="times 18 bold").grid(row=0, column=1)
Label(frame1, image = img_drink_1, bg="yellow").grid(row=1, column=1)
Label(frame1, text="Price 120", bg="yellow", fg="black").grid(row=2, column=1)
Spinbox(frame1, from_=0, to=10, textvariable=drink_spy1).grid(row=3, column=1)
Label(frame1, text="Orange Mixed : ", bg="yellow", fg="blue", font="times 18 bold").grid(row=4, column=1)
Label(frame1, image = img_drink_2, bg="yellow").grid(row=5, column=1)
Label(frame1, text="Price 140", bg="yellow", fg="black").grid(row=6, column=1)
Spinbox(frame1, from_=0, to=10, textvariable=drink_spy2).grid(row=7, column=1)
def checkout():
frame2 = Frame(main, bg="lightgreen")
frame2.place(x=0, y=0, width=w, height=h)
frame2.rowconfigure((0,1,2,3,4,5), weight=1)
frame2.columnconfigure((0,1,2,3), weight=1)
Label(frame2, text="Menu list", bg="lightgreen", fg="black").grid(row=0, column=0, sticky=N, pady=10)
Label(frame2, text="Amount", bg="lightgreen", fg="black").grid(row=0, column=1, sticky=N, pady=10)
Label(frame2, text="Price", bg="lightgreen", fg="black").grid(row=0, column=2, sticky=N, pady=10)
Label(frame2, text="Total(Baths)", bg="lightgreen", fg="black").grid(row=0, column=3, sticky=N, pady=10)
for i,des in enumerate(name_menu_list):
Label(frame2, text=des["Menu list"]).grid(row=i+1, column=0, sticky="news")
Label(frame2, text=des["Amount"]).grid(row=i+1, column=1, sticky="news")
Label(frame2, text=des["Price"]).grid(row=i+1, column=2, sticky="news")
Label(frame2, text=des["Total(Baths)"]).grid(row=i+1, column=3, sticky="news")
def calculate():
global total
global menu_total
menu_total = 0
total = 0
if cake_spy1.get() > 0:
menu_total = cake_spy1.get() * 85
total = total + menu_total
show_menu = {"Menu list":"Strawberry Cake", "Amount":cake_spy1, "Price":85, "Total(Baths)":menu_total}
elif cake_spy2.get() > 0:
menu_total = cake_spy2.get() * 95
total = total + menu_total
show_menu = {"Menu list":"Cheese Cake", "Amount":cake_spy2, "Price":95, "Total(Baths)":menu_total}
elif drink_spy1.get() > 0:
menu_total = drink_spy1.get() * 120
total = total + menu_total
show_menu = {"Menu list":"Strawberry Mixed", "Amount":drink_spy1, "Price":120, "Total(Baths)":menu_total}
elif drink_spy2.get() > 0:
menu_total = drink_spy2.get() * 140
total = total + menu_total
show_menu = {"Menu list":"Orange Mixed", "Amount":drink_spy2, "Price":140, "Total(Baths)":menu_total}
name_menu_list.append(show_menu)
menu_total = 0
total = 0
w = 800
h = 700
main = mainwindow()
cake_spy1 = StringVar()
cake_spy2 = StringVar()
drink_spy1 = StringVar()
drink_spy2 = StringVar()
frame0 = Frame(main, bg="pink") #for homepage
frame0.grid(row=0, column=0, sticky="news")
img_home = PhotoImage(file="images/myshop.png")
Label(frame0, image=img_home, bg="pink").grid(row=0, column=0, sticky="news", padx=130, pady=40)
Label(frame0, text="...Welcome to my resturent...", bg="pink", fg="black", font="times 25 bold").grid(row=1, column=0)
img_menu_1 = PhotoImage(file="images/cake1.png")
img_menu_2 = PhotoImage(file="images/cake2.png")
img_drink_1 = PhotoImage(file="images/drink1.png")
img_drink_2 = PhotoImage(file="images/drink2.png")
name_menu_list = []
menu_name = StringVar()
main.mainloop()
this all my code the problem function is checkout and calculate
Thank you for helping me

Can someone tell me why there's 3 massagebox appeared upon Bind(<'FocusIn'>)

self.Lowest = tk.Label(self.Frame2, font=('Arial', 12), text='lower limit', bg='#E8E8E8', bd=7, anchor=W)
self.Lowest.grid(row=4, column=1)
self.Lowest_e = tk.Entry(self.Frame2, font=('Arial', 12), bg='white', bd=5, width=19, justify='left')
self.Lowest_e.bind('<FocusIn>', self.click_standard)
self.Lowest_e.grid(row=4, column=2)
def click_standard(self, event): #
if self.standards is not None:
messagebox.showinfo("Notification", "Tolerance values must not be different!")

How to fix issue with tkinter checkboxes?

I'm trying to make a python(2.7) Cafe System. I created most of the functions just one function It is supposed to after I click the check button to open up the entry. Just when I click the check box button it won't open does anyone know why?
from Tkinter import *
import random
import time
import datetime
root = Tk()
root.geometry("1350x750+0+0")
root.title("Cafe Management System")
root.configure(background='black')
Tops = Frame(root, width=1350, height=100, bd=14, relief="raise")
Tops.pack(side=TOP)
f1 = Frame(root, width=900, height=650, bd=8, relief="raise")
f1.pack(side=LEFT)
f2 = Frame(root, width=440, height=650, bd=8, relief="raise")
f2.pack(side=RIGHT)
f1a = Frame(f1, width=900, height=320, bd=6, relief="raise")
f1a.pack(side=TOP)
f2a = Frame(f1, width=900, height=320, bd=6, relief = "raise")
f2a.pack(side=BOTTOM)
ft2 = Frame(f2, width= 440,height=450,bd=12,relief="raise")
ft2.pack(side=TOP)
fb2 = Frame(f2, width=440, height=250, bd=16, relief="raise")
fb2.pack(side=BOTTOM)
f1aa = Frame(f1a, width=400, height=330, bd=16, relief="raise")
f1aa.pack(side=LEFT)
f1ab = Frame(f1a, width=400, height=330, bd=16, relief="raise")
f1ab.pack(side=RIGHT)
f2aa = Frame(f2a, width=450, height=330, bd=14, relief="raise")
f2aa.pack(side=LEFT)
f2ab = Frame(f2a, width=450, height=330, bd=14, relief="raise")
f2ab.pack(side=RIGHT)
Tops.configure(background='black')
f1.configure(background='black')
f2.configure(background='black')
lblInfo = Label(Tops, font=('arial', 70, 'bold'), text="Cafe Management")
lblInfo.grid(row=0, column=0)
#===============================Functions============================
def qExit():
root.destroy()
def Reset():
PaidTax.set("")
SubTotal.set("")
TotalCost.set("")
CostofDrinks.set("")
CostofCakes.set("")
ServiceCharge.set("")
txtReciept.delete("1.0",END)
E_Latta.set("0")
E_Coffee_Cake.set("0")
#===============================Variables============================
var1=IntVar()
DateofOrder = StringVar()
Reciept_Ref = StringVar()
PaidTax = StringVar()
SubTotal = StringVar()
TotalCost = StringVar()
CostofCakes=StringVar()
CostofDrinks=StringVar()
ServiceCharge=StringVar()
E_Latta = StringVar()
E_Coffee_Cake=StringVar()
E_Coffee_Cake.set("0")
DateofOrder.set(time.strftime("%H:%M:%S"))
#=========================DRINKS======================
Latta = Checkbutton(f1ab, text="Latte \t", variable = var1, onvalue = 1, offvalue = 0,
font=('arial',18,'bold')).grid(row=0, sticky=W)
#=======================Enter Widget For Cakes=================
txtLatta = Entry(f1aa, font=('arial', 16, 'bold'), bd=8, width=6, justify='left', textvariable=E_Coffee_Cake, state=DISABLED)
txtLatta.grid(row=0, column=1)
#===========================================================Check b
def chkbutton_value():
if (var1.get() == 1):
txtLatta.configure(state=NORMAL)
elif var1.get()==0:
txtLatta.configure(state=DISABLED)
E_Latta.set("0")
#===========================================================Check btns
var1.set(0)
txtLatta.configure(state=DISABLED)
#=======================================Infomation====
lblReciept = Label(ft2, font=('arial', 12, 'bold'), text="Reciept", bd=2).grid(row=0,column=0,sticky=W,)
txtReciept = Text(fb2,font=('arial',11,'bold'), bd=8, width=59)
txtReciept.grid(row=1, column=0)
#========================================Items
lblCostofDrinks=Label(f2aa,font=('arial', 16, 'bold'), text="Cost of Drinks", bd=8)
lblCostofDrinks.grid(row=0, column=0, sticky=W)
txtCostofDrinks=Entry(f2aa, font=('arial', 16, 'bold'), bd=8,
insertwidth=2,justify='left', textvariable=CostofDrinks)
txtCostofDrinks.grid(row=0, column=1, sticky=W)
lblCostofCakes=Label(f2aa,font=('arial', 16, 'bold'), text="Cost of Cakes", bd=8)
lblCostofCakes.grid(row=1, column=0, sticky=W)
txtCostofCakes=Entry(f2aa, font=('arial', 16, 'bold'), bd=8,
insertwidth=2,justify='left',textvariable=CostofCakes)
txtCostofCakes.grid(row=1, column=1, sticky=W)
lblServiceCharge=Label(f2aa,font=('arial', 16, 'bold'), text="Service Charge", bd=8)
lblServiceCharge.grid(row=2, column=0, sticky=W)
txtServiceCharge=Entry(f2aa, font=('arial', 16, 'bold'), bd=8,
insertwidth=2, justify='left')
txtServiceCharge.grid(row=2, column=1, sticky=W)
#========================================Payment Info===================================
lblPaidTax=Label(f2ab,font=('arial', 16, 'bold'), text="Tax", bd=8)
lblPaidTax.grid(row=0, column=0, sticky=W)
txtPaidTax=Entry(f2ab, font=('arial', 16, 'bold'), bd=8,
insertwidth=2, justify='left', textvariable=PaidTax)
txtPaidTax.grid(row=0, column=1, sticky=W)
lblSubTotal=Label(f2ab,font=('arial', 16, 'bold'), text="Sub Total", bd=8)
lblSubTotal.grid(row=1, column=0, sticky=W)
txtSubTotal=Entry(f2ab, font=('arial', 16, 'bold'), bd=8,
insertwidth=2, justify='left', textvariable=SubTotal)
txtSubTotal.grid(row=1, column=1, sticky=W)
lblTotalCost=Label(f2ab,font=('arial', 16, 'bold'), text="Total", bd=8)
lblTotalCost.grid(row=2, column=0, sticky=W)
txtTotalCost=Entry(f2ab, font=('arial', 16, 'bold'), bd=8,
insertwidth=2, justify='left', textvariable=TotalCost)
txtTotalCost.grid(row=2, column=1, sticky=W)
CostofDrinks.set("")
CostofCakes.set("")
#========================================Buttons=======================
btnTotal = Button(fb2,padx=16,pady=1,bd=4,fg="black",font=('arial', 16,'bold'), width=5,
text="Total ").grid(row=3, column=1)
btnReciept = Button(fb2,padx=16,pady=1,bd=4,fg="black",font=('arial', 16,'bold'), width=5,
text="Reciept ").grid(row=3, column=2)
btnReset = Button(fb2,padx=16,pady=1,bd=4,fg="black",font=('arial', 16,'bold'), width=5,
text="Reset ", command=Reset).grid(row=3, column=3)
btnExit = Button(fb2,padx=16,pady=1,bd=4,fg="black",font=('arial', 16,'bold'), width=5,
text="Exit ",command=qExit).grid(row=3, column=4)
root.mainloop()
After taking some time on this one I noticed several formatting problems. However I am just going to answer the question about the checkbox issue.
You need to change your creation of each checkbox to include command = chkbutton_value.
Take a look at how I would create your Latta check button.
Latta = Checkbutton(f1ab, text="Latte \t", onvalue = 1, offvalue = 0,
font=('arial',18,'bold'), variable = var1, command = chkbutton_value)
NOTE: you need to make sure the function chkbutton_value(): is before the creation of your check buttons because you will get a error otherwise. NameError: name 'chkbutton_value' is not defined

Categories

Resources