def repl(match, self=self): "return the eval of a found expression, for replacement" expr = self.preproc(match.group(1), 'eval') try: return common.strorunicode(eval(expr, self.globals, self.locals)) except: return common.strorunicode(self.handle(expr))
def repl(match, self=self): "return the eval of a found expression, for replacement" # uncomment for debug: print '!!! replacing',match.group(1) expr = self.preproc(match.group(1), 'eval') try: return common.strorunicode( eval(expr, self.globals, self.locals)) except: return common.strorunicode(self.handle(expr))
g.SetColLabelSize(0) g.SetRowLabelSize(0) g.SetMargins(1,0) g.BeginBatch() attr=wx.grid.GridCellAttr() attr.SetBackgroundColour(wx.GREEN) attr.SetFont(wx.Font(10,wx.SWISS, wx.NORMAL, wx.BOLD)) attr.SetReadOnly(True) for k in range(len(keys)): g.SetCellValue(0, k, keys[k]) g.SetRowAttr(0,attr) oddattr=wx.grid.GridCellAttr() oddattr.SetBackgroundColour("OLDLACE") oddattr.SetReadOnly(True) evenattr=wx.grid.GridCellAttr() evenattr.SetBackgroundColour("ALICE BLUE") evenattr.SetReadOnly(True) for row in range(len(contacts)): item=contacts[row] for col in range(len(keys)): key=keys[col] v=item.get(key, "") v=common.strorunicode(v) g.SetCellValue(row+1, col, v) g.SetRowAttr(row+1, (evenattr,oddattr)[row%2]) g.AutoSizeColumns() g.AutoSizeRows() g.EndBatch() f.Show(True) app.MainLoop()
g.BeginBatch() attr = wx.grid.GridCellAttr() attr.SetBackgroundColour(wx.GREEN) attr.SetFont(wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)) attr.SetReadOnly(True) for k in range(len(keys)): g.SetCellValue(0, k, keys[k]) g.SetRowAttr(0, attr) # row attributes oddattr = wx.grid.GridCellAttr() oddattr.SetBackgroundColour("OLDLACE") oddattr.SetReadOnly(True) evenattr = wx.grid.GridCellAttr() evenattr.SetBackgroundColour("ALICE BLUE") evenattr.SetReadOnly(True) for row in range(len(contacts)): item = contacts[row] for col in range(len(keys)): key = keys[col] v = item.get(key, "") v = common.strorunicode(v) g.SetCellValue(row + 1, col, v) g.SetRowAttr(row + 1, (evenattr, oddattr)[row % 2]) g.AutoSizeColumns() g.AutoSizeRows() g.EndBatch() f.Show(True) app.MainLoop()