[Tutor] visibility of variables

2005-08-01 Thread Victor Reijs

Hello all of you,

I have problems with the visibility of variables in python. I am
used to the idea of Javascript and other languages where one can define
global variables if they are defined outside a function. It seems Python
is not doing that, but how can I make it work?

I think it needs some twist in my mind to get used to it, but I still
don't grasp it. Can you help?

I have attached a program that is not functioning as I would like to
have it functioning.
It seems that the 'gementenkleur' in funct1 and funct2 are the value of
gemetenkleur at the start of the program, but they don't chance after
the definition of gemetenkleur=bmifrao1.bmp

I 'know' this is something particular to Python, by how can I work
around this? I could add gemetenkleur in the argument list of the funct1
and funct2 functions, but in my case I don't want this (funct1 will be a
function to be used in scipy.fmin, and I have the idea that only the
simplex can be as an argument).

Is there a good page on the web that described this visibility issue (or
does it have a different name?) of Python? The delveintopython.pdf does
not help me and also a tutorial of hetland.org (Instant python:
instant-python.php.htm ) seems not to speak the right language for me;-).

Hope someone can help me. I have the idea this is essential to
understand before continuing more in Python.


All the best,


Victor






bmifrao1bmp=[(41, 37, 33), (63, 56, 53), (107, 97, 92), (228, 226, 222), (81, 
64, 107), (107, 131, 82), (236, 207, 71), (158, 58, 42)]
print 'original bmifrao1bmp ',bmifrao1bmp
#gemetenkleur=[(41, 37, 33), (63, 56, 53), (107, 97, 92), (228, 226, 222), (81, 
64, 107), (107, 131, 82), (236, 207, 71), (158, 58, 42)]
gemetenkleur=[[47,46,47],[62,65,61],[116,114,114],[238,233,232],[65,62,116],[0,144,75],[245,211,0],[207,65,60]]
endkleur=[[47,46,47],[62,65,61],[116,114,114],[238,233,232],[65,62,116],[0,144,75],[245,211,0],[207,65,60]]


def funct1():
print 'gemetenkleur in func1: ',gemetenkleur
a=funct2(gemetenkleur)

def funct2(kleuren):
   print 'kleuren in funct2 (should be same as gemetenkleur): ',kleuren
   return 1

def Do():
   gemetenkleur=bmifrao1bmp[:]
   print 'gemetenkleur has to be from now bmifrao1bmp: ',gemetenkleur
   funct1()
   
Do()   

  


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


Re: [Tutor] visibility of variables

2005-08-01 Thread Victor Reijs
THANKS Kent.
It seems I used the wrong keywords to find answer to my question. This 
page is very very helpfull! I now works indeed. THANKS for your fast help.

All the best,

Victor

Kent Johnson wrote:
>>I have problems with the visibility of variables in python. I am
>>used to the idea of Javascript and other languages where one can define
>>global variables if they are defined outside a function. It seems Python
>>is not doing that, but how can I make it work?
>>
>>I think it needs some twist in my mind to get used to it, but I still
>>don't grasp it. Can you help?
> 
> In function Do() you must add the declaration
>   global gemetenkleur
> 
> See 
> http://www.python.org/doc/faq/programming.html#how-do-you-set-a-global-variable-in-a-function
>  and the entry that follows it for some explanation.

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


[Tutor] print a line in IDLE as bold, italics or a color

2005-08-02 Thread Victor Reijs
Hello all of you,

I am trying to simply(?) print some text in a print statement as bold 
(or itlaics or an certain color). How do I do this in python?
Browsing the web gives we all kind of soluation, but non seem to work (a 
lot are related when printing on the web).

Say I want to print the text (in the mentioned format):
This is bold, red, blue, italics

How do I do this in python 2.2 and using IDLE?

Thanks for your help.

All the best,


Victor


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


Re: [Tutor] print a line in IDLE as bold, italics or a color

2005-08-02 Thread Victor Reijs
Hello Danny,

Danny Yoo wrote:
>>This is in a seperate text box, but I want to have the colors
>>(bold/italics) in the default IDLE window.
> 
> This will probably be more difficult.  I don't believe IDLE itself allows
> a user's program to set its own fonts and colors within the running IDLE
> window.
> 
> I'm sure it's technically possible, but not without some significant
> hacking at the IDLE interface.

Error messages in IDLE also get a color (red), so it loooks to be 
standard 'IDLE'/python;-)
Also IDEL recognize keywords while typing and changes the color (to 
orange), so it is quite normal in IDLE...
But now; how can user's python program use it?

All the best,


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


Re: [Tutor] print a line in IDLE as bold, italics or a color

2005-08-03 Thread Victor Reijs
Hello Alan,

Thanks for your feedback. I managed to get some color in my print in 
IDLE (or the Paint Shop Pro Script Output window):
###
import sys
print >> sys.stderr,'Hello world'
###


All the best,


Victor

Alan G wrote:
> Is there any reason why you want to change the ouput only in IDLE?
> Or do you really want to be able to control the output of your
> program wherever it runs? If the latter then you will need to
> create your own Text window and display the output there.

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


Re: [Tutor] print a line in IDLE as bold, italics or a color

2005-08-03 Thread Victor Reijs
Hello Alan,

Alan G wrote:
>> Thanks for your feedback. I managed to get some color in my print in 
>> IDLE (or the Paint Shop Pro Script Output window): 
> 
> I'm intrigued. Does PSP now support scripting in Python?
> Is that a standard feature? (I'm a Photoshop Elements user
> myself...)

It is python (I wonder even if the system itself is not python;-), 
because the calls to PSP routines are kind of Python calls...

I am working on this:
http://www.iol.ie/~geniet/eng/pspscripthelp.htm


All the best,


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


[Tutor] dialog boxes

2005-09-06 Thread Victor Reijs
Hello all of you,

I want to use yes/no-, text-, info-, checklist- dialog boxes in my image
manipulation program (on a Windows XP Pro system using python 2.2 and
2.3). What is the best way to do this?

Thanks for your feedback.


All the best,


Victor


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


[Tutor] dialog boxes for Windows

2005-09-21 Thread Victor Reijs
Hello all of you,

I want to use yes/no-, text-, info-, checklist- dialog boxes in my image
manipulation program (on a Windows XP Pro system using python 2.2 and
2.3). What is the best way to do this?
Do peopel have some examples or links? I want to know which python 
modules are needed and where to get.

Thanks for your feedback.


All the best,


Victor




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