[Tutor] Tkinter help?

2015-05-18 Thread cartman6921
*Below is a code made by me in 5 minutes, I am new to Tkinter so am kinda
noobish. as you can see, lemon equals 0 at the start and when you click the
button it adds 1 to the amount lemon equals. After about 15 minutes of
trying and 10 minutes googling i can find nothing to help me. when the code
loops, lemon is set back to 0 again, how do i stop lemon from being set back
to 0.

I need it so if you press the button eg 4 times, lemon=4*

from tkinter import *
root=Tk()

root.title(Lemonade Stand)
root.geometry(500x500+500+300)

lemon=0

def BuyLemon():
str(lemon)+str(1)
print(lemon)

button = Button(root,text=Buy Lemon x1, command=BuyLemon)
button.pack()

root.mainloop()




--
View this message in context: 
http://python.6.x6.nabble.com/Tkinter-help-tp5095151.html
Sent from the Python - tutor mailing list archive at Nabble.com.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter help?

2015-05-18 Thread Alan Gauld

On 18/05/15 19:27, cartman6921 wrote:

*Below is a code made by me in 5 minutes, I am new to Tkinter so am kinda
noobish.


We all have to start somewhere.

Unfortunately there are a few issues with your code.
I'll try to deal with them as we go through.


from tkinter import *
root=Tk()

root.title(Lemonade Stand)
root.geometry(500x500+500+300)

lemon=0

def BuyLemon():
 str(lemon)+str(1)
 print(lemon)


This function doesn't do what you think it does.
The second line takes the string representation of
lemon ('0') and adds the string representation of
1 ('1') using string concatenation to produce '01'

Then it throws it away.
Finally it prints lemon which remains unchanged as zero.

You need to have an assignment inside the function
that modifies lemon. But because you are modifying a
global variable you need to declare lemon as global
inside the function. So you get:

def buyLemon():
global lemon
lemon = str(lemon) + str(1)
print (lemon)

However if you just use that function you will wind
up, after 4 presses, with '0' which is not what
you want.

Instead of converting to strings just add the numbers:

def buyLemon():
global lemon
lemon +=1
print (lemon)


button = Button(root,text=Buy Lemon x1, command=BuyLemon)
button.pack()

root.mainloop()


Once you get that working your next step should be to get
the output printed on the GUI rather than the console. For
that you should probably start with a Label widget. You
can then assign the string representation of lemon to the
text attribute of the label.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor


[Tutor] TKinter help

2011-01-15 Thread walter weston

I am just starting to learn Tkinter and I was wondering if I should just run 
tkinter in pythons new findow and run the program. Iv done this before and my 
python crashed.. plus I want to create a text widget that has a quit box. will 
pythons IDLE be able to handle this and display the widget ? or are there other 
IDE's that I need to use?
  ___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] TKinter help

2011-01-15 Thread Alan Gauld


walter weston hacker0...@hotmail.com wrote


I am just starting to learn Tkinter and I was wondering if I should
just run tkinter in pythons new window and run the program.


You don;t run Tkinter, it is just a set of modules like any other.
So you run Python as normal, whether from ODLE or from
the command line.

Older versions of IDLE, being written in Tkinter, got confused
so the best advice was wriite the code in IDLE but run it
separately. However newer version of IDLE seem better able
to cope. Personally, however, I'd still recommend running the
code outside IDLE.


...I want to create a text widget that has a quit box.
will pythons IDLE be able to handle this and display the widget ?


IDLE won't display anything but it will run the program which
will display the widgets in a separate window.


or are there other IDE's that I need to use?


IDLE should be fine if you like it. Just if in doubt try running
the code from a command line (or file explorer window).

If you are having difficulty it is best to post actual code with
actual errors and we can give specific answers.

HTH,

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Tkinter Help

2008-07-21 Thread Ruivaldo Neto
Hi,

I have a Python app that runs as a Windows Service. Inside this
application, there is a Thread that starts a webservice.
When this webservice is called, this thread displays a simple Tkinter
window with some entry´s for input.

But the mainloop simple stays running without presenting any popup or error.
The app is running as SYSTEM on Windows. As other user, the code works great.

Any advice to make this work ?

Thanks in advance.


Ruivaldo Neto
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter Help

2008-07-21 Thread arsyed
On Mon, Jul 21, 2008 at 1:59 PM, Ruivaldo Neto [EMAIL PROTECTED] wrote:

 Hi,

 I have a Python app that runs as a Windows Service. Inside this
 application, there is a Thread that starts a webservice.
 When this webservice is called, this thread displays a simple Tkinter
 window with some entry´s for input.

 But the mainloop simple stays running without presenting any popup or
 error.
 The app is running as SYSTEM on Windows. As other user, the code works
 great.

 Any advice to make this work ?

 Thanks in advance.



I think this is because you need to have the service marked as
Interactive.  This page has some information:

http://msdn.microsoft.com/en-us/library/ms683502(VS.85).aspx

It might be worth asking the question in the py-win32 group or some windows
related forum.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter Help

2008-07-21 Thread Alan Gauld

Ruivaldo Neto [EMAIL PROTECTED] wrote


I have a Python app that runs as a Windows Service. Inside this
application, there is a Thread that starts a webservice.
When this webservice is called, this thread displays a simple 
Tkinter

window with some entry´s for input.


Thats usually a very bad idea. Presenting services  with GUIs
can lead to lockups and other bad things under Windows so
you should only do it if absolutely essential. Are you sure there
is no other way to run your app? Maybe with the GUI part as
a separate program that communicates with the service?


But the mainloop simple stays running without presenting
any popup or error. The app is running as SYSTEM on
Windows. As other user, the code works great.


I think the requirements of a service mean there are some
extra flags that need to be set. MSDN is probably your best
bet for info. It will also explain why services and GUIs don't
usually mix.


Any advice to make this work ?


Don't do it. Find another way.

Alan G. 



___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter help required

2005-12-15 Thread Vlad Popescu
Thanks a bunch, Michael. I am using Fedora Core 4 and have
installed the tkinter package via yum. Everything is working
great as far as I can tell. That really helped. Thanks again

 On Wed, 14 Dec 2005 15:05:07 +0200
 Vlad Popescu [EMAIL PROTECTED] wrote:
 
 Hi Vlad,
 
  Hello everyone,
  
  I have been desperately trying to get Tkinter to run, but
 without much
  success thus far. I've followed the instructions at
  http://wiki.python.org/moin/TkInter ; importing _tkinter
 does not work
  and I have no idea what files I should edit in order to add
 the module.
  Both Tcl and Tk, along with their -devel packages, are
 installed and
  updated. Python version is 2.4.1
  
 
 it looks like you are running a linux box?
 If so , probably Tkinter is in a separate package that may be
 called tkinter or python-tk
 or something similar, depending on the distro. May be this
 package is not installed?
 
 Regards
 
 Michael


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Tkinter help required

2005-12-14 Thread Vlad Popescu
Hello everyone,

I have been desperately trying to get Tkinter to run, but without much
success thus far. I've followed the instructions at
http://wiki.python.org/moin/TkInter ; importing _tkinter does not work
and I have no idea what files I should edit in order to add the module.
Both Tcl and Tk, along with their -devel packages, are installed and
updated. Python version is 2.4.1

Any suggestions? 

Thanks in advance,
Vlad


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Tkinter help required

2005-12-14 Thread Michael Lange
On Wed, 14 Dec 2005 15:05:07 +0200
Vlad Popescu [EMAIL PROTECTED] wrote:

Hi Vlad,

 Hello everyone,
 
 I have been desperately trying to get Tkinter to run, but without much
 success thus far. I've followed the instructions at
 http://wiki.python.org/moin/TkInter ; importing _tkinter does not work
 and I have no idea what files I should edit in order to add the module.
 Both Tcl and Tk, along with their -devel packages, are installed and
 updated. Python version is 2.4.1
 

it looks like you are running a linux box?
If so , probably Tkinter is in a separate package that may be called tkinter 
or python-tk
or something similar, depending on the distro. May be this package is not 
installed?

Regards

Michael
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor