I'm trying to make a fairly basic panel for adding/editing users in a database. To make this happen, I want to have a number of labels for different fields on the left, and the appropriate controls for that field on the right. (So, the left might say something like "Username", "User Type", "Expiration Date", etc, and the associated right-hand side would have a text panel, a drop down, and a calendar widget.)
The problem I'm running into is that I want these to both line up horizontally (a label and it's associated "control areas" should start at the same line), and vertically (all labels should start along the same vertical line, and all control areas should start on the same vertical line.) Some control areas are larger or smaller than others, though; many consist of only a single text panel, while others have things like radio buttons, calendar widgets, etc, associated with them.
Furthermore, the types of fields needed are changing frequently, and depending on context (such as whether a new user is being created or an old one edited, and the permissions level of the controlling user), some of these fields may be excluded. So, I want something that will largely arrange itself - if I have to set positions very manually, I expect things to break as parts are excluded.
What I'd like to see is a layout manager that will basically let me set coordinates on a flexible grid, and then size the grid automatically to provide minimum space to each element, while still keeping the grid lines straight. That way I could simply keep a list of controls and their associated labels, and build the panel programmatically so that labels/controls are always assigned to the same rows.
I haven't figured out how to do this with any of the layout managers though: GridLayout
seems to require that everything be the same size, and BoxLayout
wants to arrange things either vertically or horizontally but not both. So, I keep finding that either my rows line up but are not aligned neatly vertically, or the wrong labels line up with the wrong controls.
Any advice?