Python Tkinter Inventory sumCalling an external command in PythonWhat are metaclasses in Python?Is there a way to run Python on Android?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?

Create all possible words using a set or letters

Yosemite Fire Rings - What to Expect?

What is Cash Advance APR?

How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?

Is the U.S. Code copyrighted by the Government?

What are the purposes of autoencoders?

Lowest total scrabble score

Is there a single word describing earning money through any means?

250 Floor Tower

How much character growth crosses the line into breaking the character

Loading commands from file

How do I color the graph in datavisualization?

Pre-mixing cryogenic fuels and using only one fuel tank

Travelling outside the UK without a passport

Approximating irrational number to rational number

Fear of getting stuck on one programming language / technology that is not used in my country

Why did the HMS Bounty go back to a time when whales are already rare?

Should I outline or discovery write my stories?

Where does the bonus feat in the cleric starting package come from?

Creature in Shazam mid-credits scene?

Calculating Wattage for Resistor in High Frequency Application?

On a tidally locked planet, would time be quantized?

How should I respond when I lied about my education and the company finds out through background check?

Why does the Sun have different day lengths, but not the gas giants?



Python Tkinter Inventory sum


Calling an external command in PythonWhat are metaclasses in Python?Is there a way to run Python on Android?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow can I safely create a nested directory in Python?Does Python have a ternary conditional operator?How to get the current time in PythonHow can I make a time delay in Python?Does Python have a string 'contains' substring method?













0















I am new to python and saw a source code regarding some inventory app made with tkinter and I got the hang of it modifying and trying to understand the code but there's something I cant seem to do, calculating the total price of the product(quantity * price). When i multiply the PRODUCT_QTY and PRODUCT_PRICE it returns 0 so I dont know how to asign the value to the tkinter variables IntVar().Here is the code of the viewform of the created products:



def ViewForm():
global tree
TopViewForm = Frame(viewform, width=600, bd=1, relief=SOLID)
TopViewForm.pack(side=TOP, fill=X)
LeftViewForm = Frame(viewform, width=600)
LeftViewForm.pack(side=LEFT, fill=Y)
MidViewForm = Frame(viewform, width=600)
MidViewForm.pack(side=RIGHT)
lbl_text = Label(TopViewForm, text="View Products", font=('arial', 18), width=600)
lbl_text.pack(fill=X)
lbl_txtsearch = Label(LeftViewForm, text="Search", font=('arial', 15))
lbl_txtsearch.pack(side=TOP, anchor=W)
search = Entry(LeftViewForm, textvariable=SEARCH, font=('arial', 15), width=10)
search.pack(side=TOP, padx=10, fill=X)
btn_search = Button(LeftViewForm, text="Search", command=Search)
btn_search.pack(side=TOP, padx=10, pady=10, fill=X)
btn_reset = Button(LeftViewForm, text="Reset", command=Reset)
btn_reset.pack(side=TOP, padx=10, pady=10, fill=X)
btn_delete = Button(LeftViewForm, text="Delete", command=Delete)
btn_delete.pack(side=TOP, padx=10, pady=10, fill=X)
scrollbarx = Scrollbar(MidViewForm, orient=HORIZONTAL)
scrollbary = Scrollbar(MidViewForm, orient=VERTICAL)
tree = ttk.Treeview(MidViewForm, columns=("ProductID", "Product Name", "Product Qty", "Product Price"), selectmode="extended", height=100, yscrollcommand=scrollbary.set, xscrollcommand=scrollbarx.set)
scrollbary.config(command=tree.yview)
scrollbary.pack(side=RIGHT, fill=Y)
scrollbarx.config(command=tree.xview)
scrollbarx.pack(side=BOTTOM, fill=X)
tree.heading('ProductID', text="ProductID",anchor=W)
tree.heading('Product Name', text="Product Name",anchor=W)
tree.heading('Product Qty', text="Product Qty",anchor=W)
tree.heading('Product Price', text="Product Price",anchor=W)
tree.column('#0', stretch=NO, minwidth=0, width=0)
tree.column('#1', stretch=NO, minwidth=0, width=0)
tree.column('#2', stretch=NO, minwidth=0, width=200)
tree.column('#3', stretch=NO, minwidth=0, width=120)
tree.column('#4', stretch=NO, minwidth=0, width=120)
tree.pack()
DisplayData()









share|improve this question






















  • P.S the variables are declared like this then retrieved from a database :USERNAME = StringVar() PASSWORD = StringVar() PRODUCT_NAME = StringVar() PRODUCT_PRICE = IntVar() PRODUCT_QTY = IntVar() SEARCH = StringVar(

    – Em44
    2 days ago












  • Did you try casting them to numerical types in case they were in a possible 'string' state ?

    – Antry
    2 days ago











  • "I dont know how to asign the value to the tkinter variables IntVar()" - Have you read documentation on IntVar? That will tell you how to set the values.

    – Bryan Oakley
    2 days ago











  • Yes i typecasted them and used the .get() attribute but the problem is with getting the values from them since when i multiply them it returns 0, even if the qty and price are numbers(1,2) or something.I want to get the values form the database and display the total without having to do calculations every time(queries)

    – Em44
    2 days ago











  • "When i multiply the PRODUCT_QTY and PRODUCT_PRICE it returns 0": Unfortunatly your code didn't show that. Your whole code in the Question is not usefull for what you are asking. Edit your Question and replace it with the relevant part.

    – stovfl
    2 days ago















0















I am new to python and saw a source code regarding some inventory app made with tkinter and I got the hang of it modifying and trying to understand the code but there's something I cant seem to do, calculating the total price of the product(quantity * price). When i multiply the PRODUCT_QTY and PRODUCT_PRICE it returns 0 so I dont know how to asign the value to the tkinter variables IntVar().Here is the code of the viewform of the created products:



def ViewForm():
global tree
TopViewForm = Frame(viewform, width=600, bd=1, relief=SOLID)
TopViewForm.pack(side=TOP, fill=X)
LeftViewForm = Frame(viewform, width=600)
LeftViewForm.pack(side=LEFT, fill=Y)
MidViewForm = Frame(viewform, width=600)
MidViewForm.pack(side=RIGHT)
lbl_text = Label(TopViewForm, text="View Products", font=('arial', 18), width=600)
lbl_text.pack(fill=X)
lbl_txtsearch = Label(LeftViewForm, text="Search", font=('arial', 15))
lbl_txtsearch.pack(side=TOP, anchor=W)
search = Entry(LeftViewForm, textvariable=SEARCH, font=('arial', 15), width=10)
search.pack(side=TOP, padx=10, fill=X)
btn_search = Button(LeftViewForm, text="Search", command=Search)
btn_search.pack(side=TOP, padx=10, pady=10, fill=X)
btn_reset = Button(LeftViewForm, text="Reset", command=Reset)
btn_reset.pack(side=TOP, padx=10, pady=10, fill=X)
btn_delete = Button(LeftViewForm, text="Delete", command=Delete)
btn_delete.pack(side=TOP, padx=10, pady=10, fill=X)
scrollbarx = Scrollbar(MidViewForm, orient=HORIZONTAL)
scrollbary = Scrollbar(MidViewForm, orient=VERTICAL)
tree = ttk.Treeview(MidViewForm, columns=("ProductID", "Product Name", "Product Qty", "Product Price"), selectmode="extended", height=100, yscrollcommand=scrollbary.set, xscrollcommand=scrollbarx.set)
scrollbary.config(command=tree.yview)
scrollbary.pack(side=RIGHT, fill=Y)
scrollbarx.config(command=tree.xview)
scrollbarx.pack(side=BOTTOM, fill=X)
tree.heading('ProductID', text="ProductID",anchor=W)
tree.heading('Product Name', text="Product Name",anchor=W)
tree.heading('Product Qty', text="Product Qty",anchor=W)
tree.heading('Product Price', text="Product Price",anchor=W)
tree.column('#0', stretch=NO, minwidth=0, width=0)
tree.column('#1', stretch=NO, minwidth=0, width=0)
tree.column('#2', stretch=NO, minwidth=0, width=200)
tree.column('#3', stretch=NO, minwidth=0, width=120)
tree.column('#4', stretch=NO, minwidth=0, width=120)
tree.pack()
DisplayData()









share|improve this question






















  • P.S the variables are declared like this then retrieved from a database :USERNAME = StringVar() PASSWORD = StringVar() PRODUCT_NAME = StringVar() PRODUCT_PRICE = IntVar() PRODUCT_QTY = IntVar() SEARCH = StringVar(

    – Em44
    2 days ago












  • Did you try casting them to numerical types in case they were in a possible 'string' state ?

    – Antry
    2 days ago











  • "I dont know how to asign the value to the tkinter variables IntVar()" - Have you read documentation on IntVar? That will tell you how to set the values.

    – Bryan Oakley
    2 days ago











  • Yes i typecasted them and used the .get() attribute but the problem is with getting the values from them since when i multiply them it returns 0, even if the qty and price are numbers(1,2) or something.I want to get the values form the database and display the total without having to do calculations every time(queries)

    – Em44
    2 days ago











  • "When i multiply the PRODUCT_QTY and PRODUCT_PRICE it returns 0": Unfortunatly your code didn't show that. Your whole code in the Question is not usefull for what you are asking. Edit your Question and replace it with the relevant part.

    – stovfl
    2 days ago













0












0








0








I am new to python and saw a source code regarding some inventory app made with tkinter and I got the hang of it modifying and trying to understand the code but there's something I cant seem to do, calculating the total price of the product(quantity * price). When i multiply the PRODUCT_QTY and PRODUCT_PRICE it returns 0 so I dont know how to asign the value to the tkinter variables IntVar().Here is the code of the viewform of the created products:



def ViewForm():
global tree
TopViewForm = Frame(viewform, width=600, bd=1, relief=SOLID)
TopViewForm.pack(side=TOP, fill=X)
LeftViewForm = Frame(viewform, width=600)
LeftViewForm.pack(side=LEFT, fill=Y)
MidViewForm = Frame(viewform, width=600)
MidViewForm.pack(side=RIGHT)
lbl_text = Label(TopViewForm, text="View Products", font=('arial', 18), width=600)
lbl_text.pack(fill=X)
lbl_txtsearch = Label(LeftViewForm, text="Search", font=('arial', 15))
lbl_txtsearch.pack(side=TOP, anchor=W)
search = Entry(LeftViewForm, textvariable=SEARCH, font=('arial', 15), width=10)
search.pack(side=TOP, padx=10, fill=X)
btn_search = Button(LeftViewForm, text="Search", command=Search)
btn_search.pack(side=TOP, padx=10, pady=10, fill=X)
btn_reset = Button(LeftViewForm, text="Reset", command=Reset)
btn_reset.pack(side=TOP, padx=10, pady=10, fill=X)
btn_delete = Button(LeftViewForm, text="Delete", command=Delete)
btn_delete.pack(side=TOP, padx=10, pady=10, fill=X)
scrollbarx = Scrollbar(MidViewForm, orient=HORIZONTAL)
scrollbary = Scrollbar(MidViewForm, orient=VERTICAL)
tree = ttk.Treeview(MidViewForm, columns=("ProductID", "Product Name", "Product Qty", "Product Price"), selectmode="extended", height=100, yscrollcommand=scrollbary.set, xscrollcommand=scrollbarx.set)
scrollbary.config(command=tree.yview)
scrollbary.pack(side=RIGHT, fill=Y)
scrollbarx.config(command=tree.xview)
scrollbarx.pack(side=BOTTOM, fill=X)
tree.heading('ProductID', text="ProductID",anchor=W)
tree.heading('Product Name', text="Product Name",anchor=W)
tree.heading('Product Qty', text="Product Qty",anchor=W)
tree.heading('Product Price', text="Product Price",anchor=W)
tree.column('#0', stretch=NO, minwidth=0, width=0)
tree.column('#1', stretch=NO, minwidth=0, width=0)
tree.column('#2', stretch=NO, minwidth=0, width=200)
tree.column('#3', stretch=NO, minwidth=0, width=120)
tree.column('#4', stretch=NO, minwidth=0, width=120)
tree.pack()
DisplayData()









share|improve this question














I am new to python and saw a source code regarding some inventory app made with tkinter and I got the hang of it modifying and trying to understand the code but there's something I cant seem to do, calculating the total price of the product(quantity * price). When i multiply the PRODUCT_QTY and PRODUCT_PRICE it returns 0 so I dont know how to asign the value to the tkinter variables IntVar().Here is the code of the viewform of the created products:



def ViewForm():
global tree
TopViewForm = Frame(viewform, width=600, bd=1, relief=SOLID)
TopViewForm.pack(side=TOP, fill=X)
LeftViewForm = Frame(viewform, width=600)
LeftViewForm.pack(side=LEFT, fill=Y)
MidViewForm = Frame(viewform, width=600)
MidViewForm.pack(side=RIGHT)
lbl_text = Label(TopViewForm, text="View Products", font=('arial', 18), width=600)
lbl_text.pack(fill=X)
lbl_txtsearch = Label(LeftViewForm, text="Search", font=('arial', 15))
lbl_txtsearch.pack(side=TOP, anchor=W)
search = Entry(LeftViewForm, textvariable=SEARCH, font=('arial', 15), width=10)
search.pack(side=TOP, padx=10, fill=X)
btn_search = Button(LeftViewForm, text="Search", command=Search)
btn_search.pack(side=TOP, padx=10, pady=10, fill=X)
btn_reset = Button(LeftViewForm, text="Reset", command=Reset)
btn_reset.pack(side=TOP, padx=10, pady=10, fill=X)
btn_delete = Button(LeftViewForm, text="Delete", command=Delete)
btn_delete.pack(side=TOP, padx=10, pady=10, fill=X)
scrollbarx = Scrollbar(MidViewForm, orient=HORIZONTAL)
scrollbary = Scrollbar(MidViewForm, orient=VERTICAL)
tree = ttk.Treeview(MidViewForm, columns=("ProductID", "Product Name", "Product Qty", "Product Price"), selectmode="extended", height=100, yscrollcommand=scrollbary.set, xscrollcommand=scrollbarx.set)
scrollbary.config(command=tree.yview)
scrollbary.pack(side=RIGHT, fill=Y)
scrollbarx.config(command=tree.xview)
scrollbarx.pack(side=BOTTOM, fill=X)
tree.heading('ProductID', text="ProductID",anchor=W)
tree.heading('Product Name', text="Product Name",anchor=W)
tree.heading('Product Qty', text="Product Qty",anchor=W)
tree.heading('Product Price', text="Product Price",anchor=W)
tree.column('#0', stretch=NO, minwidth=0, width=0)
tree.column('#1', stretch=NO, minwidth=0, width=0)
tree.column('#2', stretch=NO, minwidth=0, width=200)
tree.column('#3', stretch=NO, minwidth=0, width=120)
tree.column('#4', stretch=NO, minwidth=0, width=120)
tree.pack()
DisplayData()






python user-interface tkinter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 2 days ago









Em44Em44

96




96












  • P.S the variables are declared like this then retrieved from a database :USERNAME = StringVar() PASSWORD = StringVar() PRODUCT_NAME = StringVar() PRODUCT_PRICE = IntVar() PRODUCT_QTY = IntVar() SEARCH = StringVar(

    – Em44
    2 days ago












  • Did you try casting them to numerical types in case they were in a possible 'string' state ?

    – Antry
    2 days ago











  • "I dont know how to asign the value to the tkinter variables IntVar()" - Have you read documentation on IntVar? That will tell you how to set the values.

    – Bryan Oakley
    2 days ago











  • Yes i typecasted them and used the .get() attribute but the problem is with getting the values from them since when i multiply them it returns 0, even if the qty and price are numbers(1,2) or something.I want to get the values form the database and display the total without having to do calculations every time(queries)

    – Em44
    2 days ago











  • "When i multiply the PRODUCT_QTY and PRODUCT_PRICE it returns 0": Unfortunatly your code didn't show that. Your whole code in the Question is not usefull for what you are asking. Edit your Question and replace it with the relevant part.

    – stovfl
    2 days ago

















  • P.S the variables are declared like this then retrieved from a database :USERNAME = StringVar() PASSWORD = StringVar() PRODUCT_NAME = StringVar() PRODUCT_PRICE = IntVar() PRODUCT_QTY = IntVar() SEARCH = StringVar(

    – Em44
    2 days ago












  • Did you try casting them to numerical types in case they were in a possible 'string' state ?

    – Antry
    2 days ago











  • "I dont know how to asign the value to the tkinter variables IntVar()" - Have you read documentation on IntVar? That will tell you how to set the values.

    – Bryan Oakley
    2 days ago











  • Yes i typecasted them and used the .get() attribute but the problem is with getting the values from them since when i multiply them it returns 0, even if the qty and price are numbers(1,2) or something.I want to get the values form the database and display the total without having to do calculations every time(queries)

    – Em44
    2 days ago











  • "When i multiply the PRODUCT_QTY and PRODUCT_PRICE it returns 0": Unfortunatly your code didn't show that. Your whole code in the Question is not usefull for what you are asking. Edit your Question and replace it with the relevant part.

    – stovfl
    2 days ago
















P.S the variables are declared like this then retrieved from a database :USERNAME = StringVar() PASSWORD = StringVar() PRODUCT_NAME = StringVar() PRODUCT_PRICE = IntVar() PRODUCT_QTY = IntVar() SEARCH = StringVar(

– Em44
2 days ago






P.S the variables are declared like this then retrieved from a database :USERNAME = StringVar() PASSWORD = StringVar() PRODUCT_NAME = StringVar() PRODUCT_PRICE = IntVar() PRODUCT_QTY = IntVar() SEARCH = StringVar(

– Em44
2 days ago














Did you try casting them to numerical types in case they were in a possible 'string' state ?

– Antry
2 days ago





Did you try casting them to numerical types in case they were in a possible 'string' state ?

– Antry
2 days ago













"I dont know how to asign the value to the tkinter variables IntVar()" - Have you read documentation on IntVar? That will tell you how to set the values.

– Bryan Oakley
2 days ago





"I dont know how to asign the value to the tkinter variables IntVar()" - Have you read documentation on IntVar? That will tell you how to set the values.

– Bryan Oakley
2 days ago













Yes i typecasted them and used the .get() attribute but the problem is with getting the values from them since when i multiply them it returns 0, even if the qty and price are numbers(1,2) or something.I want to get the values form the database and display the total without having to do calculations every time(queries)

– Em44
2 days ago





Yes i typecasted them and used the .get() attribute but the problem is with getting the values from them since when i multiply them it returns 0, even if the qty and price are numbers(1,2) or something.I want to get the values form the database and display the total without having to do calculations every time(queries)

– Em44
2 days ago













"When i multiply the PRODUCT_QTY and PRODUCT_PRICE it returns 0": Unfortunatly your code didn't show that. Your whole code in the Question is not usefull for what you are asking. Edit your Question and replace it with the relevant part.

– stovfl
2 days ago





"When i multiply the PRODUCT_QTY and PRODUCT_PRICE it returns 0": Unfortunatly your code didn't show that. Your whole code in the Question is not usefull for what you are asking. Edit your Question and replace it with the relevant part.

– stovfl
2 days ago












0






active

oldest

votes











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%2f55281388%2fpython-tkinter-inventory-sum%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















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%2f55281388%2fpython-tkinter-inventory-sum%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

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript