wx.Frame positioning

While it may true I am trying to write Python as if it were PHP, that is explained by me knowing PHP and not knowing Python. I started coding in 1967 and have experience of Fortran 4, Algol 68, COBOL, Pascal, Basic, PLAN, asm and others. You have decided Python does things the "right way" and won't have it any other way.

No, that's not true at all. Python does it the way Guido designed it. It is what it is. It is consistent, well-documented and well-defined. The key point is that you don't get to say Python is wrong just because it does things differently from what you're used to. If it doesn't agree with you, there are lots of others.

It is NOT true that PHP has to have its functions defined before use. Python could do it simply by doing a dual pass over the code.

Yes, but it doesn't. Neither does C or C++. You simply learn that main() goes at the bottom, and the things it needs are above.

I would also point out that using classes eliminates this problem, because the code for the class is all parsed before any instances of the class can be instantiated.

Event handling occurs after "app.MainLoop()" is executed, so the logical place to put the code lines is after the "app.MainLoop()" line.
OOP imposes a nonsensical structure and line ordering on things which are logically top to bottom.

No, that's silly. You are inventing your own arbitrary criteria and measuring a new language against those criteria. What you are describing has nothing to do with "logical". Get to know Python first, by reading code from successful projects, and come back to us after you've had time to absorb the philosophy.

I am not going to get confused by this approach, although I can see that a room full of programmers all working on the same project might have a problem.

25 years of hugely successful development experience with Python suggests you are incorrect.

···

On Apr 17, 2019, at 9:19 PM, Dave Kimble <dave.kimble.2@gmail.com> wrote:

Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Hi Dave,

I feel your pain with regard to coming to a new language. I started programming about half a dozen years after you did, but I’ve lived through the constant evolution of languages and the attendant silliness of language wars fought over which was the “best” language. One fo the best lessons I’ve learned is to keep my mind open so that I can learn the idioms associated with a particular language. Python has a somewhat unique idiom in how its author designed it, but it becomes easier over time. From my own experience, the more challenging part of a new language is to be able to think in terms of its idioms instead of trying to force the idiom of another language onto it. Whether or not Python is the “right” way is actually somewhat immaterial because wxPython is written in Python. It’s different than PHP (which I’ve worked in) but not insurmountable. I’m working through a book by Mike Driscoll that is devoted to wxPython (link) that you might find helpful. Mike also has other books that are like a quickstart for Python and there are a number of other references available online that may help your learning journey.

Best regards,

Chuck

···

On Apr 17, 2019, at 9:19 PM, Dave Kimble dave.kimble.2@gmail.com wrote:

I have discovered another aspect of the frame positioning problem.

When
the frame has the “style=~wx.CAPTION” option, and frame_pos = wx.Point(200,200) it does position correctly, but with the default style (with my setup) it doesn’t, it positions at wx.Point(x, 0) where x is the width of the taskbar , which is on the left margin).

====

While it may true I am trying to write Python as if it were PHP, that is explained by me knowing PHP and not knowing Python. I started coding in 1967 and have experience of Fortran 4, Algol 68, COBOL, Pascal, Basic, PLAN, asm and others. You have decided Python does things the “right way” and won’t have it any other way. History has shown that new coding languages can go backwards in terms of neatness and intuitiveness. Indentation as syntax looks right, EXCEPT when you want to use indentation for other purposes, then it is impossible without using { }.

It is NOT true that PHP has to have its functions defined before use. Python could do it simply by doing a dual pass over the code.

Event handling occurs after “app.MainLoop()” is executed, so the logical place to put the code lines is after the “app.MainLoop()” line.

OOP imposes a nonsensical structure and line ordering on things which are logically top to bottom.

I am not going to get confused by this approach, although I can see that a room full of programmers all working on the same project might have a problem.

On Sunday, April 14, 2019 at 5:16:08 PM UTC+10, Tim Roberts wrote:

On Apr 13, 2019, at 10:14 PM, Dave Kimble dave....@gmail.com wrote:

Tim, Many thanks for taking the time and effort to go thru all my newbie problems. I have followed all your fixes and everything now works, apart from the frame positioning.

Yes, I am trying to avoid using classes. This goes back to PHP’s horrible syntax for defining classes. It also gets rid of “self” all over the place, which I think is A Good Thing.

It is absolutely NOT a good thing, in either Python or PHP. Using classes and “self” gives you an automatic way to compartmentalize your data and hold state. It is a proven way to reduce bugs. Your scheme puts everything into global variables, which is terrible coding practice.

PHP’s syntax for defining classes is not all that different from other languages. It is quite possible to write good, object-oriented code in PHP, it’s just that almost no one does so. Essentially all of the PHP examples on the web suck.

It’s a bit disappointing that Python cannot seem to cope with the event handler lines coming after app.Mainloop() line (button_clicked not defined), which is the logical place for them… Is there a way round this?

What on earth makes you think that’s logical? Python, like PHP and C, requires that a name be defined before it is used. If you were using classes, that organization would come automatically, because the class would all be defined before any of the class’s code was executed. Where you are making everything a global, it dictates a very specific ordering for your code, because the code is interpreted linearly from top to bottom. app.Mainloop() does not return until the program exits. Thus, when your windows all come up, none of the code after that call will have been seen yet.

And if I can be frank, I don’t think you are really in a position yet to say what is the “logical place” for things. You are trying to write Python as if it were PHP. That is always going to lead to tears, heartache, and bad designs. Seriously, you need to learn the Pythonic way of doing things. The standard practices are there because history has shown us what works.

In wxPHP I would ident the lines for controls to emphasis their hierachies, but in wxPython the rules for idents don’t allow this.

Right. In Python, indentation is syntax. It is one of its most endearing features.


Tim Roberts, ti...@probo.com

Providenza & Boekelheide, Inc.

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

<test1.py>