def add_Sheet(self, sheetname=None, sheetdata=None): """Add a new sheet - handles all the table creation stuff""" def checksheet_name(name): if name == '': tkMessageBox.showwarning("Whoops", "Name should not be blank.") return 0 if self.sheets.has_key(name): tkMessageBox.showwarning("Name exists", "Sheet name already exists!") return 0 noshts = len(self.notebook.pagenames()) if sheetname == None: sheetname = tkSimpleDialog.askstring("New sheet name?", "Enter sheet name:", initialvalue='sheet'+str(noshts+1)) checksheet_name(sheetname) page = self.notebook.add(sheetname) #Create the table and model if sheetdata !=None: model = TableModel(sheetdata) else: model = TableModel() #create the table self.currenttable = MyTable(page, model) #Add some empty data if no data if sheetdata == None: self.currenttable.autoAdd_Columns(1) self.currenttable.autoAdd_Rows(1) #Load preferences into table self.currenttable.loadPrefs(self.preferences) #This handles all the canvas and header in the frame passed to constructor self.currenttable.createTableFrame() #add the table to the sheet dict self.sheets[sheetname] = self.currenttable self.saved = 0 return sheetname
def test3(): """Drawing large tables""" data = createData(10000) model = TableModel() model.importDict(data) createTable(model) return
def test(root): data = Testing.createData(2000, 20) model = TableModel() model.importDict(data) app = App(root) master = app.main table = LargeTable(master, model) #table.load('large.table') table.createTableFrame()
def import_csv(self): importer = TableImporter() # just use the dialog to load and import the file importdialog = importer.import_Dialog(self.tablesapp_win) self.tablesapp_win.wait_window(importdialog) model = TableModel() model.importDict(importer.data) sheetdata = {} sheetdata['sheet1'] = model.getData() self.new_project(sheetdata) return
def test1(root): """Setup a table and populate it with data""" app = App(root) master = app.main model = TableModel() data = createData(40) #import after model created #print data model.importDict(data) table = TableCanvas(master, model, cellwidth=60, cellbackgr='#e3f698', thefont=('Arial', 12), rowheight=18, rowheaderwidth=30, rowselectedcolor='yellow', editable=True) table.createTableFrame() #table.sortTable(columnName='label') #remove cols model.deleteColumns([0]) model.deleteRows(range(0, 2)) #table.redrawTable() #add rows and cols table.addRow(1, label='aaazzz') table.addRow(label='bbb') table.addRow(**{'label': 'www'}) table.addColumn('col6') model.data[1]['col6'] = 'TEST' #table.redrawTable() #change col labels model.columnlabels['col6'] = 'new label' #set and get selections table.setSelectedRow(2) table.setSelectedCol(1) table.setSelectedCells(1, 80, 2, 4) #print table.getSelectionValues() #table.plotSelected(graphtype='XY') #save data #table.addRows(50000) model.save('test.table') #load new data table.load('test.table') #root.after(2000, root.quit) return
def test4(): """Filtering/searching""" model = TableModel() data = createData(100) model.importDict(data) model.addColumn('comment') for i in model.reclist: val = random.sample(['a', 'b', 'c'], 1)[0] model.data[i]['comment'] = val #searchterms = [('label', 'aa', 'contains', 'AND'), # ('label', 'bb', 'contains', 'OR')] searchterms = [('comment', 'a', '!=', 'AND'), ('comment', 'b', '!=', 'AND')] vals = model.getColumnData(columnIndex=0, filters=searchterms) #model.getColumns(model.columnNames, filters=searchterms) #model.getDict(model.columnNames, filters=searchterms) print '%s found' % len(vals) #createTable(model) return
def test2(): """Multuple tables in one window""" t = Toplevel() app = App(t) master = app.main c = 0 r = 1 for i in range(12): model = TableModel() data = createData(50) model.importDict(data) fr = Frame(master) if c % 3 == 0: c = 0 r += 1 fr.grid(row=r, column=c, sticky='nws') table = TableCanvas(fr, model, width=250, height=150, rowheaderwidth=0) table.createTableFrame() c += 1 return
def add_Sheet(self, sheetname=None, sheetdata=None): """Add a new sheet - handles all the table creation stuff""" def checksheet_name(name): if name == '': tk.messagebox.showwarning('Whoops', 'Name should not be blank.') return 0 if name in self.sheets: tk.messagebox.showwarning('Name exists', 'Sheet name already exists!') return 0 noshts = len(self.notebook.pagenames()) if sheetname is None: sheetname = tk.simpledialog.askstring('New sheet name?', 'Enter sheet name:', initialvalue='sheet' + str(noshts + 1)) checksheet_name(sheetname) page = self.notebook.add(sheetname) # Create the table and model if data present if sheetdata is not None: model = TableModel(sheetdata) self.currenttable = MyTable(page, model) else: self.currenttable = MyTable(page) # Load preferences into table self.currenttable.loadPrefs(self.preferences) # This handles all the canvas and header in # the frame passed to constructor self.currenttable.createTableFrame() # add the table to the sheet dict self.sheets[sheetname] = self.currenttable self.saved = 0 return sheetname
def getSheet(self, name): """Get a sheet - returns a tablemodel""" return TableModel(self.data[name])