def addRow(self, row, rowLabel=None): """Add one row of info, either header (col names) or normal data Adds items sequentially; FlexGridSizer moves to next row automatically """ labelBox = wx.BoxSizer(wx.HORIZONTAL) if not rowLabel: if sys.platform == 'darwin': self.SetWindowVariant(variant=wx.WINDOW_VARIANT_SMALL) label = _translate('cond %s:') % str(row + 1 - int(self.hasHeader)).zfill(2) rowLabel = wx.StaticText(self, -1, label=label) rowLabel.SetForegroundColour(darkgrey) if sys.platform == 'darwin': self.SetWindowVariant(variant=wx.WINDOW_VARIANT_NORMAL) labelBox.Add(rowLabel, 1, flag=wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM) self.sizer.Add(labelBox, 1, flag=wx.ALIGN_CENTER) lastRow = [] for col in range(self.cols): # get the item, as unicode for display purposes: if len(str(self.grid[row][col])): # want 0, for example item = str(self.grid[row][col]) else: item = u'' # make a textbox: field = ExpandoTextCtrl(self, -1, item, size=(self.colSizes[col], 20)) field.Bind(EVT_ETC_LAYOUT_NEEDED, self.onNeedsResize) field.SetMaxHeight(100) # ~ 5 lines if self.hasHeader and row == 0: # add a default column name (header) if none provided header = self.grid[0] if item.strip() == '': c = col while self.colName(c) in header: c += 1 field.SetValue(self.colName(c)) field.SetForegroundColour(darkblue) # dark blue # or (self.parent and if not valid_var_re.match(field.GetValue()): # self.parent.exp.namespace.exists(field.GetValue()) ): # was always red when preview .xlsx file -- in # namespace already is fine if self.fixed: field.SetForegroundColour("Red") field.SetToolTip( wx.ToolTip( _translate( 'Should be legal as a variable name (alphanumeric)' ))) field.Bind(wx.EVT_TEXT, self.checkName) elif self.fixed: field.SetForegroundColour(darkgrey) field.SetBackgroundColour(white) # warn about whitespace unless will be auto-removed. invisible, # probably spurious: if (self.fixed or not self.clean) and item != item.strip(): field.SetForegroundColour('Red') # also used in show(): self.warning = _translate('extra white-space') field.SetToolTip(wx.ToolTip(self.warning)) if self.fixed: field.Disable() lastRow.append(field) self.sizer.Add(field, 1) self.inputFields.append(lastRow) if self.hasHeader and row == 0: self.header = lastRow