Getting a grid with the options I need

I am new to wxPython, and pretty new to Python – have done a lot of Java and other programming.

I want to create a display for a small touch screen in a grid where columns may be different sizes. I will display some text and some numbers. I would like to be able to:

set alignment attributes on columns and/or cells
set background color on cells
have borders on cells
detect clicking on cells

I’ve seen an example program that use wx.grid.Grid; it appears looking like a spreadsheet, with row and column headers. I don’t want that, though it’s pretty. If it has enough flexibility to remove things, it might work for what I want. I haven’t found API documentation on it yet.

I’ve seen examples using a GridBagSizer; I can get that to work, but haven’t found any way to put borders on the cells. I suppose I might put some kind of label(s) in the cells and create a border for the label(s).

So I would like someone to explain an overall approach that is worth going into. I don’t have the background to know whether I’m even in the right ballpark for choosing widgets to use.

I suppose one other thing I should mention that I prefer is an API for the widgets I’m using. I like to have a reference that explains what the widget does instead of ONLY one or more examples. Examples are great, but they aren’t explanations, and lead to more trial-and-error. Half of the google results I get are references to something called “Phoenix” which seems to have dropped out of existence.

Surely someone else has needed a grid with borders from wPython.

There’s a lot of questions there, but I’ll try to unpack it all… :smiley:

  • In wx.grid.Grid you can use SetColLabelSize and SetRowLabelSize to set the label widget sizes to zero, effectively removing them.

  • The Grid docs are at https://docs.wxpython.org/wx.grid.Grid.html

  • There are methods and events in the Grid family of classes that should help you get the rest of the functionality you are looking for.

  • I think you understand this, but just to be sure, the GridBagSizer is just a layout manager, it has no widget of its own, so it can’t do things like draw lines. OTOH, you can give the owner of the sizer a EVT_PAINT handler that uses the sizer (iterating through its collection of wx.SizerItems) to find out where those lines should be drawn.

  • As implied above, the API docs for wxPython are located at https://docs.wxpython.org/. If you ever forget that it can be reached from the Documentation menu at https://wxpython.org. Much of the docs are generated starting with the C++ docs as the source, so there are sometimes statements and implications that do not make as much sense for Python, but once you use the docs for a while those are not too hard to recognise and ignore.

  • Phoenix is the name that was used for the current version of wxPython while it was in development and going through alpha releases. This name was used to differentiate it from Classic wxPython (version <= 3.0) because it was a very different implementation technology. You will likely still see references to Phoenix here and there because the current development branch (currently 4.1.0) still uses the Phoenix name for the snapshot builds, docs, etc.

Also, the 404s you were getting were because the cronjob I have that updates the Phoenix docs after each build failed and so the folder was missing on the server. That’s fixed now, but you should probably be using the other docs (without “Phoenix” in the URL) anyway.

Thank you, that was helpful. I now have a grid that is closer to what I want, and am struggling with more mundane things.

Is it common in Python documentation that it isn’t explicit what a constructor looks like? None of the classes seem to have a list of the possible constructors, with meaning for the various parameters.