Page 2 of 2

Re: Python - capture a Button Click

Posted: 01 Aug 2009, 09:00
by DesignDevil
Hi clintonman,

the "adjusting of spacing" is a problem in python. If you do it wrong python interprets the code wrong. example:

In Basic you write a IF THEN contruct in this way:

Code: Select all

IF A=B THEN
   Do anything
ELSE
   Do another thing
END IF

Keep going
in python there is no END IF or brackets to tell where the "end is". PYthon needs the spacing to find this out. Example:

Code: Select all

If A==B:
   Do anything
Else:
   Do another thing

Keep going
Wrong is:

Code: Select all

If A==B:
   Do anything
Else:
   Do another thing

   Keep going
in this case is "Keep going under the ELSE construct.

That means if you readjust the spacing for this:

Code: Select all

message_map = {
         win32con.WM_DESTROY: self.OnDestroy
         }
you have to be aware that the inner line is mor inner then the contruct around. Also very importend in python: It is Case Sensitive - sometimes i am also to blind to see. Well, python is a challange in my eyes :)