Python: Costing calculator output












2















Good day all



I'm busy creating a small costing calculator for the signage department.
I'm not getting the calculator to output the amount.



Brief Description:
You enter the height and width and then when you hit enter it needs to display the cost.



How do I get it to work? Any suggestions please and thanks.



from tkinter import *
from tkinter import ttk

#Define the Functions here
def squeare(height,width):
cost = ((float(height) * float(width))/1000000 * 650 * 1.15 * 1.50)
return cost

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
width = StringVar()

#ttk.Label(mainframe, text="H").grid(column=1, row=1, sticky=E)
height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=3, row=1, sticky=(W,E))

ttk.Label(mainframe, text="X").grid(column=5, row=1, sticky=E)

#ttk.Label(mainframe, text="W").grid(column=6, row=1, sticky=E)
width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=7, row=1, sticky=(W,E))

ttk.Label(mainframe, text="=").grid(column=8, row=1, sticky=E)

#call function
#squeare()

window.mainloop()









share|improve this question


















  • 2





    Could you add the specific problem you are running into and perhaps an error message. This is very broad at the moment

    – Sven Harris
    Nov 22 '18 at 12:32











  • @SvenHarris it's running so I can add the height & width but upon hitting enter nothing happens.

    – Louis Botha
    Nov 22 '18 at 12:44
















2















Good day all



I'm busy creating a small costing calculator for the signage department.
I'm not getting the calculator to output the amount.



Brief Description:
You enter the height and width and then when you hit enter it needs to display the cost.



How do I get it to work? Any suggestions please and thanks.



from tkinter import *
from tkinter import ttk

#Define the Functions here
def squeare(height,width):
cost = ((float(height) * float(width))/1000000 * 650 * 1.15 * 1.50)
return cost

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
width = StringVar()

#ttk.Label(mainframe, text="H").grid(column=1, row=1, sticky=E)
height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=3, row=1, sticky=(W,E))

ttk.Label(mainframe, text="X").grid(column=5, row=1, sticky=E)

#ttk.Label(mainframe, text="W").grid(column=6, row=1, sticky=E)
width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=7, row=1, sticky=(W,E))

ttk.Label(mainframe, text="=").grid(column=8, row=1, sticky=E)

#call function
#squeare()

window.mainloop()









share|improve this question


















  • 2





    Could you add the specific problem you are running into and perhaps an error message. This is very broad at the moment

    – Sven Harris
    Nov 22 '18 at 12:32











  • @SvenHarris it's running so I can add the height & width but upon hitting enter nothing happens.

    – Louis Botha
    Nov 22 '18 at 12:44














2












2








2


0






Good day all



I'm busy creating a small costing calculator for the signage department.
I'm not getting the calculator to output the amount.



Brief Description:
You enter the height and width and then when you hit enter it needs to display the cost.



How do I get it to work? Any suggestions please and thanks.



from tkinter import *
from tkinter import ttk

#Define the Functions here
def squeare(height,width):
cost = ((float(height) * float(width))/1000000 * 650 * 1.15 * 1.50)
return cost

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
width = StringVar()

#ttk.Label(mainframe, text="H").grid(column=1, row=1, sticky=E)
height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=3, row=1, sticky=(W,E))

ttk.Label(mainframe, text="X").grid(column=5, row=1, sticky=E)

#ttk.Label(mainframe, text="W").grid(column=6, row=1, sticky=E)
width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=7, row=1, sticky=(W,E))

ttk.Label(mainframe, text="=").grid(column=8, row=1, sticky=E)

#call function
#squeare()

window.mainloop()









share|improve this question














Good day all



I'm busy creating a small costing calculator for the signage department.
I'm not getting the calculator to output the amount.



Brief Description:
You enter the height and width and then when you hit enter it needs to display the cost.



How do I get it to work? Any suggestions please and thanks.



from tkinter import *
from tkinter import ttk

#Define the Functions here
def squeare(height,width):
cost = ((float(height) * float(width))/1000000 * 650 * 1.15 * 1.50)
return cost

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
width = StringVar()

#ttk.Label(mainframe, text="H").grid(column=1, row=1, sticky=E)
height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=3, row=1, sticky=(W,E))

ttk.Label(mainframe, text="X").grid(column=5, row=1, sticky=E)

#ttk.Label(mainframe, text="W").grid(column=6, row=1, sticky=E)
width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=7, row=1, sticky=(W,E))

ttk.Label(mainframe, text="=").grid(column=8, row=1, sticky=E)

#call function
#squeare()

window.mainloop()






python python-3.x tkinter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 12:26









Louis BothaLouis Botha

164




164








  • 2





    Could you add the specific problem you are running into and perhaps an error message. This is very broad at the moment

    – Sven Harris
    Nov 22 '18 at 12:32











  • @SvenHarris it's running so I can add the height & width but upon hitting enter nothing happens.

    – Louis Botha
    Nov 22 '18 at 12:44














  • 2





    Could you add the specific problem you are running into and perhaps an error message. This is very broad at the moment

    – Sven Harris
    Nov 22 '18 at 12:32











  • @SvenHarris it's running so I can add the height & width but upon hitting enter nothing happens.

    – Louis Botha
    Nov 22 '18 at 12:44








2




2





Could you add the specific problem you are running into and perhaps an error message. This is very broad at the moment

– Sven Harris
Nov 22 '18 at 12:32





Could you add the specific problem you are running into and perhaps an error message. This is very broad at the moment

– Sven Harris
Nov 22 '18 at 12:32













@SvenHarris it's running so I can add the height & width but upon hitting enter nothing happens.

– Louis Botha
Nov 22 '18 at 12:44





@SvenHarris it's running so I can add the height & width but upon hitting enter nothing happens.

– Louis Botha
Nov 22 '18 at 12:44












2 Answers
2






active

oldest

votes


















0














I have bound the window frame with the return key. There is an empty result label. Whenever you press the enter key, its text will be updated.



from tkinter import *
from tkinter import ttk

def squeare(height, width):
cost = float(height) * float(width)/1000000 * 650 * 1.15 * 1.50
result.configure(text=str(cost))

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky="nsew")
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
height.set(0)
width = StringVar()
width.set(0)

height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=0, row=0, sticky="we")

ttk.Label(mainframe, text="X").grid(column=1, row=0, sticky="e")

width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=2, row=0, sticky=(W,E))

ttk.Label(mainframe, text="=").grid(column=3, row=0, sticky="e")
result = ttk.Label(mainframe)
result.grid(row=0, column=4)

window.bind('<Return>', lambda e: squeare(height.get(), width.get()))

window.mainloop()


enter image description here






share|improve this answer


























  • Thank all of you I will review my code and see where I was in the wrong. I appreciate the very quick assistance from all

    – Louis Botha
    Nov 22 '18 at 12:56











  • @LouisBotha Sure. Just edited my code to take care of the default values as well.

    – Miraj50
    Nov 22 '18 at 12:57



















0














The is to catch the 'enter' event for the second input field.



from tkinter import *
from tkinter import ttk

#Define the Functions here
def squeare(height,width):
cost = ((float(height) * float(width))/1000000 * 650 * 1.15 * 1.50)
result.configure(text=str(cost))


def enter(event=None):
squeare(height.get(), width.get())

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
width = StringVar()

#ttk.Label(mainframe, text="H").grid(column=1, row=1, sticky=E)
height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=3, row=1, sticky=(W,E))

ttk.Label(mainframe, text="X").grid(column=5, row=1, sticky=E)

#ttk.Label(mainframe, text="W").grid(column=6, row=1, sticky=E)
width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=7, row=1, sticky=(W,E))

width_entry.bind('<Return>',enter)

ttk.Label(mainframe, text="=").grid(column=8, row=1, sticky=E)
result = ttk.Label(mainframe, text="")
result.grid(column=9, row=1, sticky=E)

window.mainloop()





share|improve this answer


























  • This thing doesn't even work!

    – Germa Vinsmoke
    Nov 22 '18 at 12:49











  • @Uwe Ziegenhagen it works just displaying the result in on the GUIs window, not in it.

    – Louis Botha
    Nov 22 '18 at 12:52











  • Place a result label east to the "=" label and use the configure method of the label. I updated my code

    – Uwe Ziegenhagen
    Nov 22 '18 at 13:09











  • @GermaVinsmoke: Works fine here...

    – Uwe Ziegenhagen
    Nov 22 '18 at 13:10











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53430996%2fpython-costing-calculator-output%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I have bound the window frame with the return key. There is an empty result label. Whenever you press the enter key, its text will be updated.



from tkinter import *
from tkinter import ttk

def squeare(height, width):
cost = float(height) * float(width)/1000000 * 650 * 1.15 * 1.50
result.configure(text=str(cost))

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky="nsew")
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
height.set(0)
width = StringVar()
width.set(0)

height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=0, row=0, sticky="we")

ttk.Label(mainframe, text="X").grid(column=1, row=0, sticky="e")

width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=2, row=0, sticky=(W,E))

ttk.Label(mainframe, text="=").grid(column=3, row=0, sticky="e")
result = ttk.Label(mainframe)
result.grid(row=0, column=4)

window.bind('<Return>', lambda e: squeare(height.get(), width.get()))

window.mainloop()


enter image description here






share|improve this answer


























  • Thank all of you I will review my code and see where I was in the wrong. I appreciate the very quick assistance from all

    – Louis Botha
    Nov 22 '18 at 12:56











  • @LouisBotha Sure. Just edited my code to take care of the default values as well.

    – Miraj50
    Nov 22 '18 at 12:57
















0














I have bound the window frame with the return key. There is an empty result label. Whenever you press the enter key, its text will be updated.



from tkinter import *
from tkinter import ttk

def squeare(height, width):
cost = float(height) * float(width)/1000000 * 650 * 1.15 * 1.50
result.configure(text=str(cost))

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky="nsew")
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
height.set(0)
width = StringVar()
width.set(0)

height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=0, row=0, sticky="we")

ttk.Label(mainframe, text="X").grid(column=1, row=0, sticky="e")

width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=2, row=0, sticky=(W,E))

ttk.Label(mainframe, text="=").grid(column=3, row=0, sticky="e")
result = ttk.Label(mainframe)
result.grid(row=0, column=4)

window.bind('<Return>', lambda e: squeare(height.get(), width.get()))

window.mainloop()


enter image description here






share|improve this answer


























  • Thank all of you I will review my code and see where I was in the wrong. I appreciate the very quick assistance from all

    – Louis Botha
    Nov 22 '18 at 12:56











  • @LouisBotha Sure. Just edited my code to take care of the default values as well.

    – Miraj50
    Nov 22 '18 at 12:57














0












0








0







I have bound the window frame with the return key. There is an empty result label. Whenever you press the enter key, its text will be updated.



from tkinter import *
from tkinter import ttk

def squeare(height, width):
cost = float(height) * float(width)/1000000 * 650 * 1.15 * 1.50
result.configure(text=str(cost))

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky="nsew")
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
height.set(0)
width = StringVar()
width.set(0)

height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=0, row=0, sticky="we")

ttk.Label(mainframe, text="X").grid(column=1, row=0, sticky="e")

width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=2, row=0, sticky=(W,E))

ttk.Label(mainframe, text="=").grid(column=3, row=0, sticky="e")
result = ttk.Label(mainframe)
result.grid(row=0, column=4)

window.bind('<Return>', lambda e: squeare(height.get(), width.get()))

window.mainloop()


enter image description here






share|improve this answer















I have bound the window frame with the return key. There is an empty result label. Whenever you press the enter key, its text will be updated.



from tkinter import *
from tkinter import ttk

def squeare(height, width):
cost = float(height) * float(width)/1000000 * 650 * 1.15 * 1.50
result.configure(text=str(cost))

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky="nsew")
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
height.set(0)
width = StringVar()
width.set(0)

height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=0, row=0, sticky="we")

ttk.Label(mainframe, text="X").grid(column=1, row=0, sticky="e")

width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=2, row=0, sticky=(W,E))

ttk.Label(mainframe, text="=").grid(column=3, row=0, sticky="e")
result = ttk.Label(mainframe)
result.grid(row=0, column=4)

window.bind('<Return>', lambda e: squeare(height.get(), width.get()))

window.mainloop()


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 22 '18 at 12:56

























answered Nov 22 '18 at 12:48









Miraj50Miraj50

2,7801924




2,7801924













  • Thank all of you I will review my code and see where I was in the wrong. I appreciate the very quick assistance from all

    – Louis Botha
    Nov 22 '18 at 12:56











  • @LouisBotha Sure. Just edited my code to take care of the default values as well.

    – Miraj50
    Nov 22 '18 at 12:57



















  • Thank all of you I will review my code and see where I was in the wrong. I appreciate the very quick assistance from all

    – Louis Botha
    Nov 22 '18 at 12:56











  • @LouisBotha Sure. Just edited my code to take care of the default values as well.

    – Miraj50
    Nov 22 '18 at 12:57

















Thank all of you I will review my code and see where I was in the wrong. I appreciate the very quick assistance from all

– Louis Botha
Nov 22 '18 at 12:56





Thank all of you I will review my code and see where I was in the wrong. I appreciate the very quick assistance from all

– Louis Botha
Nov 22 '18 at 12:56













@LouisBotha Sure. Just edited my code to take care of the default values as well.

– Miraj50
Nov 22 '18 at 12:57





@LouisBotha Sure. Just edited my code to take care of the default values as well.

– Miraj50
Nov 22 '18 at 12:57













0














The is to catch the 'enter' event for the second input field.



from tkinter import *
from tkinter import ttk

#Define the Functions here
def squeare(height,width):
cost = ((float(height) * float(width))/1000000 * 650 * 1.15 * 1.50)
result.configure(text=str(cost))


def enter(event=None):
squeare(height.get(), width.get())

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
width = StringVar()

#ttk.Label(mainframe, text="H").grid(column=1, row=1, sticky=E)
height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=3, row=1, sticky=(W,E))

ttk.Label(mainframe, text="X").grid(column=5, row=1, sticky=E)

#ttk.Label(mainframe, text="W").grid(column=6, row=1, sticky=E)
width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=7, row=1, sticky=(W,E))

width_entry.bind('<Return>',enter)

ttk.Label(mainframe, text="=").grid(column=8, row=1, sticky=E)
result = ttk.Label(mainframe, text="")
result.grid(column=9, row=1, sticky=E)

window.mainloop()





share|improve this answer


























  • This thing doesn't even work!

    – Germa Vinsmoke
    Nov 22 '18 at 12:49











  • @Uwe Ziegenhagen it works just displaying the result in on the GUIs window, not in it.

    – Louis Botha
    Nov 22 '18 at 12:52











  • Place a result label east to the "=" label and use the configure method of the label. I updated my code

    – Uwe Ziegenhagen
    Nov 22 '18 at 13:09











  • @GermaVinsmoke: Works fine here...

    – Uwe Ziegenhagen
    Nov 22 '18 at 13:10
















0














The is to catch the 'enter' event for the second input field.



from tkinter import *
from tkinter import ttk

#Define the Functions here
def squeare(height,width):
cost = ((float(height) * float(width))/1000000 * 650 * 1.15 * 1.50)
result.configure(text=str(cost))


def enter(event=None):
squeare(height.get(), width.get())

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
width = StringVar()

#ttk.Label(mainframe, text="H").grid(column=1, row=1, sticky=E)
height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=3, row=1, sticky=(W,E))

ttk.Label(mainframe, text="X").grid(column=5, row=1, sticky=E)

#ttk.Label(mainframe, text="W").grid(column=6, row=1, sticky=E)
width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=7, row=1, sticky=(W,E))

width_entry.bind('<Return>',enter)

ttk.Label(mainframe, text="=").grid(column=8, row=1, sticky=E)
result = ttk.Label(mainframe, text="")
result.grid(column=9, row=1, sticky=E)

window.mainloop()





share|improve this answer


























  • This thing doesn't even work!

    – Germa Vinsmoke
    Nov 22 '18 at 12:49











  • @Uwe Ziegenhagen it works just displaying the result in on the GUIs window, not in it.

    – Louis Botha
    Nov 22 '18 at 12:52











  • Place a result label east to the "=" label and use the configure method of the label. I updated my code

    – Uwe Ziegenhagen
    Nov 22 '18 at 13:09











  • @GermaVinsmoke: Works fine here...

    – Uwe Ziegenhagen
    Nov 22 '18 at 13:10














0












0








0







The is to catch the 'enter' event for the second input field.



from tkinter import *
from tkinter import ttk

#Define the Functions here
def squeare(height,width):
cost = ((float(height) * float(width))/1000000 * 650 * 1.15 * 1.50)
result.configure(text=str(cost))


def enter(event=None):
squeare(height.get(), width.get())

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
width = StringVar()

#ttk.Label(mainframe, text="H").grid(column=1, row=1, sticky=E)
height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=3, row=1, sticky=(W,E))

ttk.Label(mainframe, text="X").grid(column=5, row=1, sticky=E)

#ttk.Label(mainframe, text="W").grid(column=6, row=1, sticky=E)
width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=7, row=1, sticky=(W,E))

width_entry.bind('<Return>',enter)

ttk.Label(mainframe, text="=").grid(column=8, row=1, sticky=E)
result = ttk.Label(mainframe, text="")
result.grid(column=9, row=1, sticky=E)

window.mainloop()





share|improve this answer















The is to catch the 'enter' event for the second input field.



from tkinter import *
from tkinter import ttk

#Define the Functions here
def squeare(height,width):
cost = ((float(height) * float(width))/1000000 * 650 * 1.15 * 1.50)
result.configure(text=str(cost))


def enter(event=None):
squeare(height.get(), width.get())

window = Tk()
window.title("Costing Calculator V1.0")

mainframe = ttk.Frame(window, padding="20 20 20 20")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
window.columnconfigure(0, weight=1)
window.rowconfigure(0, weight=1)

height = StringVar()
width = StringVar()

#ttk.Label(mainframe, text="H").grid(column=1, row=1, sticky=E)
height_entry = ttk.Entry(mainframe, width=7, textvariable=height)
height_entry.grid(column=3, row=1, sticky=(W,E))

ttk.Label(mainframe, text="X").grid(column=5, row=1, sticky=E)

#ttk.Label(mainframe, text="W").grid(column=6, row=1, sticky=E)
width_entry = ttk.Entry(mainframe, width=7, textvariable=width)
width_entry.grid(column=7, row=1, sticky=(W,E))

width_entry.bind('<Return>',enter)

ttk.Label(mainframe, text="=").grid(column=8, row=1, sticky=E)
result = ttk.Label(mainframe, text="")
result.grid(column=9, row=1, sticky=E)

window.mainloop()






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 22 '18 at 13:09

























answered Nov 22 '18 at 12:46









Uwe ZiegenhagenUwe Ziegenhagen

33521128




33521128













  • This thing doesn't even work!

    – Germa Vinsmoke
    Nov 22 '18 at 12:49











  • @Uwe Ziegenhagen it works just displaying the result in on the GUIs window, not in it.

    – Louis Botha
    Nov 22 '18 at 12:52











  • Place a result label east to the "=" label and use the configure method of the label. I updated my code

    – Uwe Ziegenhagen
    Nov 22 '18 at 13:09











  • @GermaVinsmoke: Works fine here...

    – Uwe Ziegenhagen
    Nov 22 '18 at 13:10



















  • This thing doesn't even work!

    – Germa Vinsmoke
    Nov 22 '18 at 12:49











  • @Uwe Ziegenhagen it works just displaying the result in on the GUIs window, not in it.

    – Louis Botha
    Nov 22 '18 at 12:52











  • Place a result label east to the "=" label and use the configure method of the label. I updated my code

    – Uwe Ziegenhagen
    Nov 22 '18 at 13:09











  • @GermaVinsmoke: Works fine here...

    – Uwe Ziegenhagen
    Nov 22 '18 at 13:10

















This thing doesn't even work!

– Germa Vinsmoke
Nov 22 '18 at 12:49





This thing doesn't even work!

– Germa Vinsmoke
Nov 22 '18 at 12:49













@Uwe Ziegenhagen it works just displaying the result in on the GUIs window, not in it.

– Louis Botha
Nov 22 '18 at 12:52





@Uwe Ziegenhagen it works just displaying the result in on the GUIs window, not in it.

– Louis Botha
Nov 22 '18 at 12:52













Place a result label east to the "=" label and use the configure method of the label. I updated my code

– Uwe Ziegenhagen
Nov 22 '18 at 13:09





Place a result label east to the "=" label and use the configure method of the label. I updated my code

– Uwe Ziegenhagen
Nov 22 '18 at 13:09













@GermaVinsmoke: Works fine here...

– Uwe Ziegenhagen
Nov 22 '18 at 13:10





@GermaVinsmoke: Works fine here...

– Uwe Ziegenhagen
Nov 22 '18 at 13:10


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53430996%2fpython-costing-calculator-output%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae

Can an atomic nucleus contain both particles and antiparticles? [duplicate]