Beispiel #1
0
def test3():
    """Drawing large tables"""
    data = createData(10000)
    model = TableModel()
    model.importDict(data)
    createTable(model)
    return
Beispiel #2
0
 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()
Beispiel #5
0
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()
Beispiel #6
0
 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
Beispiel #7
0
    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
Beispiel #8
0
 def simpleCopy(self, include=None):
     """Return a simple copy of the PEAT table model, with only
        text and int fields and not using the OOBTree structure"""
     M=TableModel()
     fields = self.DB.getSimpleFields()
     if include!=None:
         fields.extend(include)
     for rec in self.reclist:
         data={}
         for f in fields:
             if self.data[rec].has_key(f):
                data[f] = self.data[rec][f]
         M.addRecord(rec,**data)        
     return M
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
Beispiel #10
0
def test1(root):
    """Setup a table and populate it with data"""
    app = App(root)
    master = app.main
    model = TableModel()
    #RM#data = createData(40)
    #import after model created
    #print data
    #RM#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
    #RM#model.deleteColumns([0])
    #RM#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')
    #RM#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
Beispiel #11
0
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
Beispiel #12
0
class App:

    def __init__(self, master):

        tframe = Frame(master)
        tframe.pack(fill=BOTH)
        
        d = {1: {'date': 1189774539.345525, 'message': 'Commiting project ', 'author': 'damien'},
             2: {'date': 1189776100.545814, 'message': 'tommytest1', 'author': 'tc'},
             3: {'date': 1189776148.873471, 'message': 'test', 'author': 'elisa'},
             4: {'date': 1189776217.082571, 'message': "barbara's wt and mutant", 'author': 'btconnolly'},
             5: {'date': 1189776969.9782951, 'message': 'Adding a column', 'author': 'nielsen'},
             6: {'date': 1189777126.719934, 'message': 'fergal_test', 'author': 'fomeara'},
             7: {'date': 1189777948.4796059, 'message': 'TEST', 'author': 'elisa'},
             8: {'date': 1189778073.3868899, 'message': 'Adding 7TLN and deleting damen wt', 'author': 'nielsen'},
             9: {'date': 1189778472.5035281, 'message': 'Adding exp. data', 'author': 'nielsen'},
             10: {'date': 1189778553.6663699, 'message': 'Adding NMR tirtaion curve', 'author': 'nielsen'},
             11: {'date': 1189778701.032536, 'message': 'blaah', 'author': 'nielsen'}}

        self.tmodel = TableModel()
        self.tmodel.importDict(d,None,columns = ['date','message','author'])
        self.table = TableCanvas(tframe, self.tmodel,upperColumnHeaders=None)
        self.table.createTableFrame()
        return
Beispiel #13
0
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
Beispiel #14
0
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
Beispiel #15
0
    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 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
Beispiel #17
0
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
Beispiel #18
0
 def setColorAt(self, rowIndex, columnIndex, color, key='bg'):
     """Override to set dirty bit"""
     TableModel.setColorAt(self, rowIndex, columnIndex, color, key=key)
     self.meta._p_changed = 1
     return
Beispiel #19
0
 def moveColumn(self, oldcolumnIndex, newcolumnIndex):
     TableModel.moveColumn(self, oldcolumnIndex, newcolumnIndex)        
     self.meta['table']['columnorder'] = self.columnOrder = self.getColOrder()
     self.meta._p_changed = 1     
     return
Beispiel #20
0
 def __init__(self, newdict=None, rows=None, columns=None):
     TableModel.__init__(self, newdict, rows, columns)
     #default types for this model
     self.defaulttypes = ['text', 'number', 'File', 'Table', 'Ekin']
     return
Beispiel #21
0
 def getSheet(self, name):
     """Get a sheet - returns a tablemodel"""
     return TableModel(self.data[name])