Tkinter Wiki   SimpleTable UserPreferences
 
HelpContents FindPage Diffs Info Edit Subscribe XML Print View

SimpleTable defines a basic (rather memory intensive) table widget, used for display of unchanging data.

  1 
  2 
  3 
  4 
  5 
  6 
  7 
  8 
  9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
 19 
 20 
 21 
 22 
 23 
 24 
 25 
 26 
    from GuiAppD import GuiAppD
    class SimpleTableTest(GuiAppD):
        appname='SimpleTable Test Application'
        def createInterface(self):
            table = self.createcomponent(
                'testtable',
                (), None,
                SimpleTable,
                (self.interior(),),
                )
            table.pack(
                side=TOP,
                expand=YES,
                fill=BOTH,
                )
            text = open('/etc/passwd', 'rt').read()
            table.setfromtext(text, ':', '\n')
            #add some arbitrary text
            for i in range(0, 15):
                table.component('tabletext').insert(
                    'end',
                    'Before%d\tMiddle%d\tNext%d\tEnd%d\n' \
                    % (i, i, i, i))
            table.component('tabletext').insert('end', 'A lot of text before the first tab.\tThen a lot of text in the middle.\tNow a lot of text at the end.')
            return
    SimpleTableTest().run()

Screenshot:

simpletable.png

PythonPowered