Adds a single row of elements to a window's self.Rows variables. Generally speaking this is NOT how users should be building Window layouts. Users, create a single layout (a list of lists) and pass as a parameter to Window object, or call Window.Layout(layout) :para
(self, *args)
| 10226 | |
| 10227 | # ------------------------- Add ONE Row to Form ------------------------- # |
| 10228 | def add_row(self, *args): |
| 10229 | """ |
| 10230 | Adds a single row of elements to a window's self.Rows variables. |
| 10231 | Generally speaking this is NOT how users should be building Window layouts. |
| 10232 | Users, create a single layout (a list of lists) and pass as a parameter to Window object, or call Window.Layout(layout) |
| 10233 | |
| 10234 | :param *args: List[Elements] |
| 10235 | :type *args: |
| 10236 | """ |
| 10237 | NumRows = len(self.Rows) # number of existing rows is our row number |
| 10238 | CurrentRowNumber = NumRows # this row's number |
| 10239 | CurrentRow = [] # start with a blank row and build up |
| 10240 | # ------------------------- Add the elements to a row ------------------------- # |
| 10241 | for i, element in enumerate(args): # Loop through list of elements and add them to the row |
| 10242 | |
| 10243 | if isinstance(element, tuple) or isinstance(element, list): |
| 10244 | self.add_row(*element) |
| 10245 | continue |
| 10246 | _error_popup_with_traceback('Error creating Window layout', |
| 10247 | 'Layout has a LIST instead of an ELEMENT', |
| 10248 | 'This sometimes means you have a badly placed ]', |
| 10249 | 'The offensive list is:', |
| 10250 | element, |
| 10251 | 'This list will be stripped from your layout' |
| 10252 | ) |
| 10253 | continue |
| 10254 | elif callable(element) and not isinstance(element, Element): |
| 10255 | _error_popup_with_traceback('Error creating Window layout', |
| 10256 | 'Layout has a FUNCTION instead of an ELEMENT', |
| 10257 | 'This likely means you are missing () from your layout', |
| 10258 | 'The offensive list is:', |
| 10259 | element, |
| 10260 | 'This item will be stripped from your layout') |
| 10261 | continue |
| 10262 | if element.ParentContainer is not None: |
| 10263 | warnings.warn( |
| 10264 | '*** YOU ARE ATTEMPTING TO REUSE AN ELEMENT IN YOUR LAYOUT! Once placed in a layout, an element cannot be used in another layout. ***', |
| 10265 | UserWarning) |
| 10266 | _error_popup_with_traceback('Error detected in layout - Contains an element that has already been used.', |
| 10267 | 'You have attempted to reuse an element in your layout.', |
| 10268 | "The layout specified has an element that's already been used.", |
| 10269 | 'You MUST start with a "clean", unused layout every time you create a window', |
| 10270 | 'The offensive Element = ', |
| 10271 | element, |
| 10272 | 'and has a key = ', element.Key, |
| 10273 | 'This item will be stripped from your layout', |
| 10274 | 'Hint - try printing your layout and matching the IDs "print(layout)"') |
| 10275 | continue |
| 10276 | element.Position = (CurrentRowNumber, i) |
| 10277 | element.ParentContainer = self |
| 10278 | CurrentRow.append(element) |
| 10279 | # if this element is a titlebar, then automatically set the window margins to (0,0) and turn off normal titlebar |
| 10280 | if element.metadata == TITLEBAR_METADATA_MARKER: |
| 10281 | self.Margins = (0, 0) |
| 10282 | self.NoTitleBar = True |
| 10283 | # ------------------------- Append the row to list of Rows ------------------------- # |
| 10284 | self.Rows.append(CurrentRow) |
| 10285 |
no test coverage detected