Unable to record /save the data on my python GUI App

59 views
Skip to first unread message

Ahmad Shaad Safwi

unread,
Nov 9, 2017, 9:10:17 PM11/9/17
to Python Challenge
Hi everyone! I am new to python and I have made a GUI interface for a cafe.But its only limited up to calculating the values  and not storing the results :

-I want to save (Total cost and Bill reference number ) in a file or say a database table.Please help me out sharing the snippet of one section of the code 



def Ref():
    x = random.randint(10908, 500876)
    randomRef = str(x)
    rand.set(randomRef)

    CoF =float(Fries.get())
    CoD =float(Drinks.get())
    CoFilet =float(Filet.get())
    CoBurger =float(Burger.get())
    CoChicBurger =float(Chicken_Burger.get())
    CoCheese_Burger =float(Cheese_Burger.get())

    CostofFries = CoF * 0.99
    CostofDrinks = CoD * 1.00
    CostofFilet = CoFilet * 2.99
    CostofBurger = CoBurger * 2.87
    CostChicken_Burger = CoChicBurger * 2.89
    CostCheese_Burger = CoCheese_Burger * 2.69

    CostofMeal = "£", str('%.2f' % (CostofFries + CostofDrinks + CostofFilet + CostofBurger
                                    + CostChicken_Burger + CostCheese_Burger))

    PayTax = ((CostofFries + CostofDrinks + CostofFilet + CostofBurger
                                    + CostChicken_Burger + CostCheese_Burger) * 0.2)

    TotalCost = (CostofFries + CostofDrinks + CostofFilet + CostofBurger
                                    + CostChicken_Burger + CostCheese_Burger)

    Ser_Charge =  ((CostofFries + CostofDrinks + CostofFilet + CostofBurger
                                    + CostChicken_Burger + CostCheese_Burger)/99)

    Service = "£", str('%.2f' % Ser_Charge)

    OverAllCost = "£", str('%.2f' % (PayTax + TotalCost + Ser_Charge ))
    PaidTax = "£", str('%.2f' % PayTax)

    Service_Charge.set(Service)
    Cost.set(CostofMeal)
    Tax.set(PaidTax)
    SubTotal.set(CostofMeal)
    Total.set(OverAllCost)




Venu Bajaj

unread,
Nov 11, 2017, 7:15:02 AM11/11/17
to Python Challenge
if you want to use sql as databse then you can convert the values into string and then establish a connection and pass the value converted to string and store it there. you may have to use sqllite3 for inserting the values.
Reply all
Reply to author
Forward
0 new messages