Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #97955 > unrolled thread

how to use variable outside function tkinter entry

Started by"Harrie Hoenjet" <h.hoenjet@planet.nl>
First post2015-10-26 19:24 +0100
Last post2015-10-26 14:46 -0600
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  how to use variable outside function tkinter entry "Harrie Hoenjet" <h.hoenjet@planet.nl> - 2015-10-26 19:24 +0100
    Re: how to use variable outside function tkinter entry Peter Pearson <pkpearson@nowhere.invalid> - 2015-10-26 18:58 +0000
    Re: how to use variable outside function tkinter entry Randy Day <randy.day@sasktel.netx> - 2015-10-26 14:46 -0600

#97955 — how to use variable outside function tkinter entry

From"Harrie Hoenjet" <h.hoenjet@planet.nl>
Date2015-10-26 19:24 +0100
Subjecthow to use variable outside function tkinter entry
Message-ID<562e7038$0$24168$e4fe514c@news.kpn.nl>
Hi guys,
suppose i have a tkinter Entry widget (Python 3.4 Tkinter 8.5)
mySalary = Entry(root, textvariable='salary', command=calculate')

I have defined
salary = IntVar()

and a function:
def calculate():
    wages = salary.get()
    ....
    return


How can i use the variable wages outside the function calculate?
For example: print(wages) or print (w=calculate()) when I add return wages) 
does not work.
I want to use the variable wages somewhere else in the programm.
I get weird errors like get() misses argument self

Who can help me?
Harry 

[toc] | [next] | [standalone]


#97956

FromPeter Pearson <pkpearson@nowhere.invalid>
Date2015-10-26 18:58 +0000
Message-ID<d97bfdFgb5aU1@mid.individual.net>
In reply to#97955
On Mon, 26 Oct 2015 19:24:20 +0100, Harrie Hoenjet <h.hoenjet@planet.nl> wrote:
> Hi guys,
> suppose i have a tkinter Entry widget (Python 3.4 Tkinter 8.5)
> mySalary = Entry(root, textvariable='salary', command=calculate')
>
> I have defined
> salary = IntVar()
>
> and a function:
> def calculate():
>     wages = salary.get()
>     ....
>     return
>
>
> How can i use the variable wages outside the function calculate?
> For example: print(wages) or print (w=calculate()) when I add return wages) 
> does not work.

Huh?  "print (w=calculate())" ?  What language is this, anyway?

Try

  w = calculate()
  print(w)

and if it doesn't work, report the exact output here.

-- 
To email me, substitute nowhere->runbox, invalid->com.

[toc] | [prev] | [next] | [standalone]


#97959

FromRandy Day <randy.day@sasktel.netx>
Date2015-10-26 14:46 -0600
Message-ID<MPG.30984d1a6fa6188e98968a@freenews.netfront.net>
In reply to#97955


> and a function:
> def calculate():
>     wages = salary.get()
>     ....
>     return

Are you wanting 'return wages'? You 
need to tell calculate() what is to 
return.

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web