0

Hello I am new to programming and I am trying to make a calculator that I can input the exchange rate I buy at and the percentage I mark up by so then I will get the selling price.

I am struggling with the code that needs to add my entry then display in my label.

from tkinter import *

class Application(Frame):
    def __init__(self, master):
        super(Application, self).__init__(master)
        self.grid()
        self.create_widgets()

    def create_widgets(self):
        # create first Label
        self.L1 = Label(self , text="Exchange Rate : ")
        self.L1.grid(row=0 , column=0 , sticky = E)
        # create second Label
        self.L2 = Label(self , text="Mark up percentage : ")
        self.L2.grid(row=1 , column=0 , sticky = E)
        # create third Label
        self.L3 = Label(self , text="Buying price : ")
        self.L3.grid(row=2 , column=0 , sticky = E)
        # create fourth Label
        self.ValueLabel = Label(self , text="Selling price :  £ ")
        self.ValueLabel.grid(row=5 , column=0 , sticky = E)
        # create fifth label
        self.Value = Label(self , )            # I want to print content4 here
        self.Value.grid(row=5 , column=1)

        # create first Entry
        self.E1 = Entry(self , bd =5)
        self.E1.grid(row=0 , column=1)
        # create second Entry
        self.E2 = Entry(self , bd =5)
        self.E2.grid(row=1 , column=1)
        # create third Entry
        self.E3 = Entry(self , bd =5)
        self.E3.grid(row=2 , column=1)
        # create submit button
        self.submit_bttn = Button(self, text = "Submit",command = self.on_button)
        self.submit_bttn.grid(row = 6, column = 4, sticky = W)

    def on_button(self):
        content1 = int(self.E1.get())
        content2 = int(self.E2.get())
        content3 = int(self.E3.get())
        content4 = int(content1*content2*content3)

root = Tk()
root.title("Calculator")
app = Application(root)

root.mainloop()
Acontz
  • 471
  • 4
  • 11
Jamie
  • 1
  • 1
  • I don't see any buttons, are you taking the input in Entry boxes? Please check previous posts too, for eg: http://stackoverflow.com/questions/22219993/how-can-i-program-a-calculator-with-a-gui-using-tkinter-in-python – Enigma Dec 06 '16 at 22:48
  • inputting data into the Entry boxes – Jamie Dec 06 '16 at 22:52

0 Answers0