Tkinter Newbie Question

2007-12-06 Thread robbie
Hello Group,

I'm a programmer with many years experience, but am new to Python and
to object oriented programming. I'm working my way through a book on
Python, and have been tweaking the examples to see what they do. I've
run into a situation that I don't understand, though I expect it's
pretty simple for anyone more skilled than I am. Here's a snippet of
code:

This first example works. It creates three windows with a button in
each that prints a word when I press the button:

from Tkinter import *
root = Tk()

trees = [('The Larch!',  'light blue'),
 ('The Pine!',   'light green'),
 ('The Giant Redwood!',  'red')]

def salutation():
print  "Something!"

for (tree, color) in trees:
win = Toplevel(root)
win.title('Sing...')
win.protocol('WM_DELETE_WINDOW', lambda:0)
win.iconbitmap('py-blue-trans-out.ico')
msg = Button(win, text='Write Something', command=salutation)
msg.pack(expand=YES, fill=BOTH)
msg.config(fg='black', bg=color, font=('times', 30, 'bold
italic'))

root.title('Lumberjack demo')
Label(root, text='Main window', width=30).pack()
Button(root, text='Quit All', command=root.quit).pack()
win.mainloop()

This second example doesn't work.  The only difference is that I gave
the salutation function a parameter and tried to pass a string as the
parameter from the button. It appears to call the function once for
each window as they're being created, but doesn't do anything when the
buttons in the windows are pressed.

from Tkinter import *
root = Tk()

trees = [('The Larch!',  'light blue'),
 ('The Pine!',   'light green'),
 ('The Giant Redwood!',  'red')]

def salutation(j=""):
print j + " Something!"

for (tree, color) in trees:
win = Toplevel(root)
win.title('Sing...')
win.protocol('WM_DELETE_WINDOW', lambda:0)
win.iconbitmap('py-blue-trans-out.ico')
msg = Button(win, text='Write Something',
command=salutation(tree))
msg.pack(expand=YES, fill=BOTH)
msg.config(fg='black', bg=color, font=('times', 30, 'bold
italic'))

I figure there's something very basic I'm missing about passing a
parameter from a Tkinter widget to a function. Can anyone tell me what
I'm doing wrong?

Thank you so much!
Robbie in Montana
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Tkinter Newbie Question

2007-12-08 Thread robbie
Hi Mark,

Thank you so much for the help. I figured it was something pretty
simple like that. And I was also puzzled by the concept of the lambda
function, so now I know what they do too. I just tried it out, and it
works well.

Much appreciated,
Ciao back at you,
Robbie


-- 
http://mail.python.org/mailman/listinfo/python-list


Newbie Question: How to use a .pth file on a Macintosh

2008-05-24 Thread Robbie
Hello All,

Hopefully this is an easy question: I'd like to use a .pth file on my
Macintosh so that I can easily import modules that I've created in my
own working directory. I've created a file called Robbie.pth. It
includes a single line:
 /Robbie/PythonWork

I can't seem to figure out where to put this file so that Python will
recognize it when I start it up. I know that the path is correct
because if I do the command sys.path.append('/Robbie/PythonWork') then
everything works as expected. I just don't want to have to execute
this command every time I start Python.

I've looked at what's in sys.path, and have tried putting the file in
various of the directories listed, to no avail. I've also tried
putting it in the same directory where IDLE is (/Applications/
MacPython 2.5) and that doesn't work either.

What am I missing?

FYI I'm running MaxOS 10.4.8 and Python 2.5,

Thank you in advance for the help.

-Robbie
--
http://mail.python.org/mailman/listinfo/python-list


Python script error when using print

2010-04-06 Thread Robbie
Hi all,

So, I'm trying to use Python with an apache2 server to create some web
pages.  The web server is configured and seems to work correctly, but
only with a certain type of script.

For instance, this script works fine

#!/usr/bin/env python
def index():
s = "Hello World"
return s

But, a script like this, does not.
#!/usr/bin/env python
print "hello world"

When I try to use the script with print, the server returns a broken
link error.  There is nothing in the apache error log to help me
understand why it won't work.

Any help?

thanks

robbie

-- 
http://mail.python.org/mailman/listinfo/python-list


I could not install pygame no matter what

2023-01-21 Thread Robbie mezazem
70916814/error-metadata-generation-failed-cant-install-artic-module

Sent from Mail for Windows

-- 
https://mail.python.org/mailman/listinfo/python-list


RE: evaluation question

2023-02-08 Thread Robbie mezazem
Ok I understand


Sent from Mail for Windows

From: Rob Cliffe via Python-list
Sent: Tuesday, February 7, 2023 6:54 PM
To: Chris Angelico; 
python-list@python.org
Subject: Re: evaluation question



On 07/02/2023 08:15, Chris Angelico wrote:
> On Tue, 7 Feb 2023 at 18:49, Rob Cliffe via Python-list
>  wrote:
>>
>>
>> On 02/02/2023 09:31, mutt...@dastardlyhq.com wrote:
>>> On Wed, 1 Feb 2023 18:28:04 +0100
>>> "Peter J. Holzer"  wrote:
 --b2nljkb3mdefsdhx
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable

 On 2023-02-01 09:00:39 -, mutt...@dastardlyhq.com wrote:
> Its not evolution, its revolution. Evolution retains old functionality.
 Tell a penguin that it can fly :-)
>>> Yeah ok :) But the ancestors of penguins didn't wake up one morning, flap
>>> their wings and fall out the tree, it happened gradually. Python2 syntax
>>> could have been retained for X versions of 3 just as C++ keeps old stuff
>>> until its eventually deprecated them removed.
>> Yeah?  So what would this do:
>>   print ()
>> In Python 2 this prints an empty tuple.
>> In Python 3 this is a call to the print function with no arguments,
>> which prints a blank line.
>> You can't have it both ways.
>> In any case, supporting two different syntaxes simultaneously would be
>> messy and difficult to maintain.
> There are two solutions to this. The most obvious is "from __future__
> import print_function", which gives you the full power and flexibility
> of Py3 in anything back as far as 2.6; the other is to always pass a
> single string argument to print:
>
> print("")
> print("spam %d ham %d" % (spam, ham))
>
> This will work in pretty much ANY version of Python [1] and doesn't
> require any sort of per-module configuration.
>
> The idea that old syntax should be retained is only part of the story.
> While it's definitely important to not break old code unnecessarily,
> it is far more important to ensure that there's *some way* to write
> code that works across multiple versions. That's what we have here:
> even with the breaking changes, there was usually a way to make your
> code run identically on multiple versions. Sometimes this means a
> compatibility shim at the top, like "try: raw_input; except NameError:
> raw_input = input", and sometimes it means following a discipline like
> putting b"..." for all strings that need to be bytes. But there always
> needs to be a way.
>
> ChrisA
>
> [1] This is the part where someone points out to me that it wouldn't
> work in Python 1.3 or something
You are quite right Chris, and indeed I have used both solutions in my
own code to keep 2-3 compatibility.
I was just pointing out that continuing to support Python 2 syntax in
Python 3 was not an option.
Best wishes
Rob Cliffe
--
https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list