From: Hugh K. <ma...@hu...> - 2007-11-03 22:56:55
|
I found PythonCard some time ago while looking for a way to write 'real programmes' for Windows. Its simplicity and logical structure appealed to me. Through it I have learnt a huge amount about both Python and wxWidgets. In particular the ability to adapt, amend and extend the tools is very satisfying. Like others I found the inability to use sizers easily was a drawback. Not so much of a drawback as to make me want to learn C++ and code in wxWidgets, or to give up PythonCard, but at the same time I objected to mixing programmatic generation of sizers into my code - it is also a hard way to learn. Inspiration for a solution came with Alex Tweedly's simplesizer and I set off with the aim of making sizers work for PythonCard while maintaining what seem to be its two key characteristics: the separation of layout and processing, and the use of visual drag-and-drop tools for layout. A secondary aim was to develop the routines in a way which did not break existing tools or code. I now have something which is firmly an alpha version and a work in progress, but it does work in several regards. I'd be happy to share my code for comment and improvement but the mailing list rejected the zip file (even if it was only 106Kb). So I'd be glad if someone could explain how to get round that. The elements are: (a) additions to the existing Layout Editor to create a visual Sizer Editor which manipulates sizers and allows components to be dropped into them and re-arranged at will; the effect of different settings can be seen immediately; (b) the final sizer details are saved into the current .rsrc.py file; (b) a short routine, called autoSizer, which processes the sizer data in the .rsrc file when a main application is initialized. The routines handle BoxSizers, GridSizers and StaticBoxSizers; FlexGridSizers are implemented but I am not 100% convinced I've got them right. The biggest omission is the ability to override manually the sizer engine's calculation of minimum dimensions for components. There is an option to ease the conversion of existing .rsrc.py layouts to a sizer-based format. A menu option creates a single vertical sizer containing all the components in the .rsrc file (effectively an on-screen list). You can then define your desired sizer configuration and drag and drop the components into the right places. Eventually the temporary vertical sizer can be deleted when it is empty. Slightly tedious but it works and it beats re-typing all your components. I have had trouble with setting minimum sizes, so I've parked that for now. I have also yet to master re-drawing the screen properly, dealing with the sizing handles when they get misplaced, and the impact of the MenuBar on the editor display. Nor have I tested the interaction of my sizer-based solutions with all the elements of Layout Editor, especially multiple selections. The GridBagSizer is a joy to come, as are global and multiple edits of sizers, drag-and-drop in the sizer tree etc, etc! Thanks, Hugh Kernohan |
From: John H. <ec...@ya...> - 2007-11-04 19:05:51
|
--- Hugh Kernohan <ma...@hu...> wrote: > I found PythonCard some time ago while looking for a > way to write 'real > programmes' for Windows. Its simplicity and logical > structure appealed > to me. Through it I have learnt a huge amount about > both Python and > wxWidgets. In particular the ability to adapt, > amend and extend the > tools is very satisfying. > Agree. > Like others I found the inability to use sizers > easily was a drawback. > Not so much of a drawback as to make me want to > learn C++ and code in > wxWidgets, or to give up PythonCard, but at the same > time I objected to > mixing programmatic generation of sizers into my > code - it is also a > hard way to learn. > Out of necessity, I've gotten pretty good in using wx sizers with Pythoncard. It's definitely usable but as you said, it's a hard way to learn. Besides, it's really hard sometimes to try to figure out why things don't turn out the way I am expecting it to. > Inspiration for a solution came with Alex Tweedly's > simplesizer and I > set off with the aim of making sizers work for > PythonCard while > maintaining what seem to be its two key > characteristics: the separation > of layout and processing, and the use of visual > drag-and-drop tools for > layout. A secondary aim was to develop the routines > in a way which did > not break existing tools or code. > Very noble goals. :-) > I now have something which is firmly an alpha > version and a work in > progress, but it does work in several regards. I'd > be happy to share my > code for comment and improvement but the mailing > list rejected the zip > file (even if it was only 106Kb). So I'd be glad if > someone could > explain how to get round that. > May be the Pythoncard developers can help, or may be we can start an eGroup at Yahoo on Pythoncard. > The elements are: > (a) additions to the existing Layout Editor to > create a visual Sizer > Editor which manipulates sizers and allows > components to be dropped into > them and re-arranged at will; the effect of > different settings can be > seen immediately; Obvious place to do it. Unfortunately it also means I have to rely on the Layout Editor more. I have reported problems with the Layout Editor long ago but there hasn't been any fix to it yet. As it stands, I can only use the Layout Editor in *very* simplistic fashion: get the basic layout done, switch to editor to edit the resource file, and switch back to layout editor to show the work and so on... We need to fix the layout editor!!! > (b) the final sizer details are saved into the > current .rsrc.py file; Of course. > (b) a short routine, called autoSizer, which > processes the sizer data in > the .rsrc file when a main application is > initialized. > > The routines handle BoxSizers, GridSizers and > StaticBoxSizers; > FlexGridSizers are implemented but I am not 100% > convinced I've got them > right. The biggest omission is the ability to > override manually the > sizer engine's calculation of minimum dimensions for > components. > > There is an option to ease the conversion of > existing .rsrc.py layouts > to a sizer-based format. A menu option creates a > single vertical sizer > containing all the components in the .rsrc file > (effectively an > on-screen list). You can then define your desired > sizer configuration > and drag and drop the components into the right > places. Eventually the > temporary vertical sizer can be deleted when it is > empty. Slightly > tedious but it works and it beats re-typing all your > components. > > I have had trouble with setting minimum sizes, so > I've parked that for > now. I have also yet to master re-drawing the > screen properly, dealing > with the sizing handles when they get misplaced, and > the impact of the > MenuBar on the editor display. Nor have I tested > the interaction of my > sizer-based solutions with all the elements of > Layout Editor, especially > multiple selections. The GridBagSizer is a joy to > come, as are global > and multiple edits of sizers, drag-and-drop in the > sizer tree etc, etc! > > Thanks, Hugh Kernohan > > I am on a tight time schedule for now but I hope I can of use beta testing the code during X'mas holidays. Thanks for the effort, though. Any improvements to PythonCard is very much welcomed. -- John Henry |
From: Alex T. <al...@tw...> - 2007-11-04 19:20:01
|
Hugh Kernohan wrote: > I found PythonCard some time ago while looking for a way to write 'real > programmes' for Windows. Its simplicity and logical structure appealed > to me. Through it I have learnt a huge amount about both Python and > wxWidgets. In particular the ability to adapt, amend and extend the > tools is very satisfying. > > Like others I found the inability to use sizers easily was a drawback. > Not so much of a drawback as to make me want to learn C++ and code in > wxWidgets, or to give up PythonCard, but at the same time I objected to > mixing programmatic generation of sizers into my code - it is also a > hard way to learn. > > Inspiration for a solution came with Alex Tweedly's simplesizer and I > set off with the aim of making sizers work for PythonCard while > maintaining what seem to be its two key characteristics: the separation > of layout and processing, and the use of visual drag-and-drop tools for > layout. A secondary aim was to develop the routines in a way which did > not break existing tools or code. > > That sounds great ! > I now have something which is firmly an alpha version and a work in > progress, but it does work in several regards. I'd be happy to share my > code for comment and improvement but the mailing list rejected the zip > file (even if it was only 106Kb). So I'd be glad if someone could > explain how to get round that. > > No easy way to get around it (as far as I know). Best thing is to put your code on a web-site from where anyone interested can download it and try it out. If you don't have a suitable place, feel free to email it direct to me (al...@tw...) and I'll put it on my site for downloads. (And I'll give it a good try-out, and look over the code, etc. :-) Thank you. -- Alex Tweedly mailto:al...@tw... www.tweedly.net |
From: Hugh K. <ma...@hu...> - 2007-11-04 21:21:40
|
Alex, Thank you. As I don't have a suitable site I'll send you the file for you to put on your website as you offer. yours, Hugh |
From: Alex T. <al...@tw...> - 2007-11-05 00:38:29
|
Hugh Kernohan wrote: > Alex, > > Thank you. As I don't have a suitable site I'll send you the file > for you to put on your website as you offer. > > Thanks Hugh. It can now be found at http://www.tweedly.org/Python/sizerEditorV1a.zip Note - I haven't yet looked at it all, so please treat it with some care. Here are Hugh's accompanying instructions ..... Alex, This is my Sizer Editor code. The zipped file is a self-standing directory tree ..\sizerEditor_version1\.. etc. The file advancedSizer.py should be copied to the PythonCard directory. My findfilestree.py is a cosmetic variation on a old favourite. I'd be happy to be corrected on anything, including points of principle and good practice. Some of the code looks clunky and inefficient, others bits quite taut. I haven't done any testing with older versions but it certainly won't work with less than wxPython 2.8.4.2 of 8 Aug 07. The bulk of the new code for the editor is in a BaseSizer class, and an all-new sizerpropertyEditor window which co-exists with the existing multipropertyEditor window. Other additions to existing code are clearly marked (and sometimes annotated) in the files. To use PythonCard.advancedsizer use the Sizer Editor to set the layout, then include the following in the on_initialize of the .py file: try: from PythonCard.advancedSizer import autoSizer self.useSizersFlag = True autoSizer(self) except: self.useSizersFlag = False This ensures that if PythonCard.advancedSizer is not available the code will still run, provided that useSizersFlag is checked before any sizer-specific routines are run. (Its use can be seen in the Sizer Editor itself). -- Alex Tweedly mailto:al...@tw... www.tweedly.net |