Hi Chris,
I hope interspersing my comments works for you - if bottom post would be easier let us know.
I am no expert, wx and programming is just a hobby of mine, so take my comments with a grain of salt.
Hi all,
I am a new comer to both WX and this mailing list, so please let me start off by saying how much I appreciate WX! I think it's great that I can make simple and accessible GUIs on multiple platforms.
Welcome to the wxPython community - I am sure you will enjoy it.
Now for my question. The attached code is part of my first project, for which I want to be able to generate dynamic configuration screens, with a view to detaching the config stuff at a later date, and making it into a stand alone class that other folks cane use.
Anyways, the eventual goal is to have 2 controls per line, 1 label, and 1 control, which can be maniuplated to fill out the form with options.
I have no idea what my screen looks like, but from an accessibility standpoint, the controls aren't getting labeled right.
The controls are not visible, this has to do with the way they are added to the sizer. I would suggest using the wx.lib.sized_controls instead, they do a lot of the sizer work for you with sensible defaults and the UI will comply with platform (MAC, Linux, Windows) HIG's (Human_Interface_Guidelines).
The 'labels' are after the actual control, could that be the problem that they are not labelled right for you? Anyhow standard UI's will most of the time put the labels to the left of the control.
You can use the included test script to make the GUI do something useful.
Has anyone got any suggestions on how I can improve this? Any suggestions for stylistic improvements are gladly accepted too!
I attached a modified version using sized_controls and doing some of the suggestions I make below.
Here some other suggestions and remarks.
- instead of having a second file to test things you can use "if __name__ == "__main__":", whatever follows that will only be executed when you run this module and will be ignored if you import that module into another one
- I would not size the Frame with wx.DisplaySize but let the sizers do their thing to size it correctly
- I would break down the code into more methods in ConfEditor
- I would probably replace 'eval' as I believe it is a potential security whole
Stylistic comments:
- do not mix tabs and spaces for indentation (especially in view of Python 3 - this will be an error)
- maybe use an IDE which assists with PEP8 - PEP 8 -- Style Guide for Python Code
- to correct existing code there is e.g. autopep8 - autopep8 · PyPI
- I like naming my methods using camelCase, i.e. start with a lower case letter, which makes it very easy to distinguish them from e.g. wxPython methods
Hope this is useful.
Werner
confeditor-changed.py (4.72 KB)
···
On 9/26/2014 18:45, Chris Norman wrote: