Git Product home page Git Product logo

tkintertable's Introduction

ABOUT

Python uses a GUI library called Tkinter as default. This set of classes allows interactive spreadsheet-style tables to be added into an application.
Tkinter is the standard GUI toolkit for python. It is old but still quite popular. There are various libraries that extend Tkinter functionality, such as Pmw, but there is currently no extendable table class for Tkinter.
A sample application using these classes is included in the distribution.

HOMEPAGE

http://code.google.com/p/tkintertable/

INSTALLATION

easy_install tkintertable
or
Download packages at http://code.google.com/p/tkintertable/downloads/list

SUBVERSION

You can checkout the current svn version using

svn co http://tkintertable.googlecode.com/svn/trunk/ tkintertable

USAGE

see http://code.google.com/p/tkintertable/wiki/Usage

CHANGES

------
1.1.2
------

* removed defunct code for filtering in model
* can now filter properly from model class
* changed autoaddrows to make much faster for large number of rows
* added notequals operator for filtering

------
1.1.1
------

* changed importdict method to make more efficient for large amounts of data
* added more tests
* fix to autoaddrows
* changes to sort behaviour so that current order is kept when adding/deleting rows
* fix to draw visible multiple row selection only

------
1.1
------

* table now renders large amounts of data by only drawing visible frame
* fixes to filtering bar
* removed paged view
* removed 'name' as a special field
* adding rows from GUI no longer requires rec names
* can now set row header width
* can now show record keys in row header instead of numbers
* row header drawn with same alignment as cells
* renamed most remaining Table.py methods to camel case

------
1.0.3
------

* added new, load and save methods to table directly
* added ImportTable method to table for interactive use
* fixed clicking outside column header bug
* fix to update selected col when redrawing
* added Dialog.py module
* removed simpletabledialog
* tidied up popupmenu

------
1.0.2
------

* restored Filtering.py, filtering works ok
* more improvement to auto resize cols, now checks currrent col sizes
* fixed model.save() method
* added ability to save table, add rows to popup menu
* fixed delete cells button binding
* cell font preferences now uses available fonts from os
* removed unused prefs from dialog

------
1.0.1
------

* add_Column method fixed
* Added ability to align cells left right or center
* Fixed problem of sort order lost when deleting rows
* Sort in descending order works correctly
* Fixes to plotting, but needs reworking or removal
* Added setSelectedCells method so a block of cells can be selected
* Improved text fitting in cells
* Automatic resizing of columns improved



tkintertable's People

Watchers

 avatar  avatar

tkintertable's Issues

bug in handle_arrow_keys()

What steps will reproduce the problem?
1. create a default TableCanvas
2. press left arrow key until the current cell moves to the first column of any 
rows different from the first row
3. the selection disappear and could not move to the previous role, exception 
of IndexError is throwed

What version of the product are you using? On what operating system?
Latest version on Linux

Suggestions:

Please modify in handle_arrow_keys():

        elif event.keysym == 'Left':
            if self.currentcol == 0:
                if self.currentrow == 0:
                    return
                else:
                    self.currentcol = self.cols-1
                    self.currentrow = self.currentrow - 1
            else:
                self.currentcol  = self.currentcol -1



Original issue reported on code.google.com by [email protected] on 29 Aug 2013 at 8:25

No support for Python 3

There is no support for Python 3, even if

pip install tkintertable

only puts out some warnings.
Code crashes for some

print '...'

statements.

Original issue reported on code.google.com by [email protected] on 18 Dec 2013 at 3:28

some bugs in python 3 version of the program and solutions to it

first thanks for this great program 
second i am beginner in python and tkinter i faced with this bugs when trying 
to use the python 3 version of tkintertable and this my try 
to fix them so if there is something wrong i am sorry for any misunderstanding  
i use python 3.4.2 , windows xp  
--------------------------------------------------
1-
in the first after loading the table in it's parent frame i got this error in 
File Tables.py line 2143, in checkOSType

    ostyp=string.lower(os.environ[var])
AttributeError: 'module' object has no attribute 'lower'

i fix it by make change from using srting to str

in line 2143 in Tables.py change the line from:

ostyp=string.lower(os.environ[var])

to:

ostyp=str.lower(os.environ[var])

-----------------------------------------
2- 

the reason of this bug is moving the mouse over an empty place on the table it 
raise TypeError in the handle_motion function in Table.py module in line 1032 

if 0 <= row < int(self.rows) and 0 <= col < self.cols:

this happen if i move the mouse over an empty place that have no 
columns in it and if we use python 2 it did't give me this error the reason
for that is in python 2 when we compare two value one of them is None like 
1 < None it will give us the result of comparison False but in python 3 it
raise a TypeError so if i move the mouse over an empty place on the table
it make one of the event coordinate None so it make comparison with None type 
and integer type 
to fix this error i catch it through try except statement like this:

try:
    if 0 <= row < int(self.rows) and 0 <= col < self.cols:
        self.drawTooltip(row, col)
except TypeError:
    return 
return 
-----------------------------------------------------------

3-

this bug raise if i specified column label bigger than 12 characters

Traceback (most recent call last):
  File "F:\4\test\python\3\test.py", line 28, in <module>
    set_income_table()
  File "F:\4\test\python\3\test.py", line 24, in set_income_table
    table.createTableFrame()
  File "F:\4\test\python\3\tkintertable\Tables.py", line 218, in createTableFrame
    self.redrawTable(callback=callback)
  File "F:\4\test\python\3\tkintertable\Tables.py", line 330, in redrawTable
    self.redrawVisible(event, callback)
  File "F:\4\test\python\3\tkintertable\Tables.py", line 316, in redrawVisible
    self.tablecolheader.redraw()
  File "F:\4\test\python\3\tkintertable\Tables.py", line 2222, in redraw
    collabel=collabel[0:int(w)/12]+'.'
TypeError: slice indices must be integers or None or have an __index__ method

in Tables.py file in line 2222 in the redraw function if the column label 
is bigger than 12 character it will give me the former error the reason for 
that is the division section in this line 

collable=collabel[0:int(w)/12]+'.'

because the result of the division int(w)/12 will be float number in python 3 
and this raise the former error so the fix to this error to change the division 
to floor division or integer 
division so the line will be like this:

collable=collable[0:int(w)//12]+'.'

---------------------------------------------------------------

4-

this error raise if i left click any empty space to the right of the table but 
it will not appear if this empty place was down the last row it only appear if 
i click the empty space to the right of table rows in the none columns space it 
will raise type error like the one appear in the one i mention in number 2 and 
appear like this

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__
    return self.func(*args)
  File "F:\4\test\python\3\tkintertable\Tables.py", line 863, in handle_left_click
    if 0 <= rowclicked < self.rows and 0 <= colclicked < self.cols:
TypeError: unorderable types: int() <= NoneType()

and the reason for this bug is the way python 3 handle the comparisons if i 
compare None with integer it will not return with false but raise a TypeError 
and i fixed it by use try catch statement with the if block in code from line 
862 to 871 like this:

i change it from:

        if 0 <= rowclicked < self.rows and 0 <= colclicked < self.cols:
            self.setSelectedRow(rowclicked)
            self.setSelectedCol(colclicked)
            self.drawSelectedRect(self.currentrow, self.currentcol)
            self.drawSelectedRow()
            self.tablerowheader.drawSelectedRows(rowclicked)
            coltype = self.model.getColumnType(colclicked)
            if coltype == 'text' or coltype == 'number':
                self.drawCellEntry(rowclicked, colclicked)
        return

to be like this:

        try:
            if 0 <= rowclicked < self.rows and 0 <= colclicked < self.cols:
                self.setSelectedRow(rowclicked)
                self.setSelectedCol(colclicked)
                self.drawSelectedRect(self.currentrow, self.currentcol)
                self.drawSelectedRow()
                self.tablerowheader.drawSelectedRows(rowclicked)
                coltype = self.model.getColumnType(colclicked)
                if coltype == 'text' or coltype == 'number':
                    self.drawCellEntry(rowclicked, colclicked)
        except TypeError:
            return

        return

------------------------------------------------------------------------------
5-

this bug appear if i click of Preferences menu item to show the preferences 
window it will not show
the window and raise _tkinter.TclError like this:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__
    return self.func(*args)
  File "F:\4\test\python\3\tkintertable\Tables.py", line 1802, in showtablePrefs
    self.prefswindow.geometry('+%s+%s' %(x+w/2,y+h/2))
  File "C:\Python34\lib\tkinter\__init__.py", line 1669, in wm_geometry
    return self.tk.call('wm', 'geometry', self._w, newGeometry)
_tkinter.TclError: bad geometry specifier "+418.0+301.5"

and this one also like bug number three the reason for it is the way python 3 
handle division so in showtablPrefs in Tables.py module in line 1802 

self.prefswindow.geometry('+%s+%s' %(x+w/2,y+h/2))

to fix it i change the divison from float divison to floor or integer division 
like this

self.prefswindow.geometry('+%s+%s' %(x+w//2,y+h//2))
-----------------------------------------------------------------------
6-

this bug present if i call the File-->New context menu it will raise this 
NameError 

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python34\lib\tkinter\__init__.py", line 1533, in __call__
    return self.func(*args)
  File "F:\4\test\python\3\tkintertable\Tables.py", line 2086, in new
    parent=self.parentframe)
  File "F:\4\test\python\3\tkintertable\Dialogs.py", line 97, in __init__
    if labels != None and types != NoneType:
NameError: name 'NoneType' is not defined


the reason for it that in python 2 you use the Tkinter.NoneType that present in 
the Tkinter library but and that already inhered from the type library but this 
NoneType no longer exist in python 3 and also in tkinter so i fix it by calling 
type(None) instead of explicit NoneType so i change line 97 in Dialogs.py 
module in the __init__ method from this:

if labels != None and types != NoneType

into this:

if labels != None and types != type(None)

i got this from dive into python 3 book appendix a. Porting Code to Python 3 
with 2to3

---------------------------------------------------------

and i upload the two files Tables.py and Dialogs.py after fixing this error on 
them may be if you like to add them to the program for any future release and 
thanks again for this great tool...

Karim Reefat


Original issue reported on code.google.com by [email protected] on 17 Feb 2015 at 2:41

Attachments:

Specifiy the order of columns

Hi,

I am trying to use your module to import some stored data and programmatically 
add rows as new information comes in.  I am having trouble specifying the order 
of the columns as they are created.  

I have modified your createData() function as:

def createData():

    data = {}
    serials = [ '3456', '2343', '2345' ]
    colnames = [ 'Serial', 'IP', 'Name' ]

    for sn in serials:
        data[sn] = {}

    ips = ['172.26.2.1', '172.26.2.2', '172.26.2.3']
    names = ['Test1', 'Test2', 'Test3']

    i=0
    for sn in serials:
        data[sn][colnames[0]] = serials[i]
        data[sn][colnames[1]] = ips[i]
        data[sn][colnames[2]] = names[i]
        i+=1

    return data

The problem I am finding is that the IP column is the first column, rather than 
the serial number.  How can I switch the order of these columns at the start of 
the program?

Thanks,

Patrick


Original issue reported on code.google.com by [email protected] on 3 Mar 2013 at 4:31

tkintertables should open csv file for output in binary mode

What steps will reproduce the problem?
1. use tkintertable on Windows
2. try to export as csv
3. open the csv file in excel

What is the expected output? What do you see instead?

Expected output:
A csv file without empty lines interspersed

What happens:
An empty line follows every intended line due to an extra carriage return.

What version of the product are you using? On what operating system?
Windows 7, tkintertable v 1.1.2


Please provide any additional information below.
You should change line 147 in Tables_IO.py from 
>writer = csv.writer(file(filename, "w"), delimiter=sep)
to
>writer = csv.writer(file(filename, "wb"), delimiter=sep)
Opening the file in text mode on Windows inserts an extra carriage return.  See 
here:
http://stackoverflow.com/questions/3348460/python-getting-rid-of-extra-line

Original issue reported on code.google.com by ballaban on 10 Sep 2014 at 9:13

Wrong default extension when opening saved file in example app

Code responsible for opening files:

filename=tkFileDialog.askopenfilename(defaultextension='.tbleprj"',
                                                      initialdir=os.getcwd(),
                                                      filetypes=[("Pickle file","*.tbleprj"),
                                                                 ("All files","*.*")],
                                                      parent=self.tablesapp_win)


despite file default extension should be .tblprj

Original issue reported on code.google.com by [email protected] on 29 Jan 2013 at 8:52

Access violation. Double clicking records outside the list.

What steps will reproduce the problem?
1. Create a table with records
2. Have a window that's larger than the list of records so there is open area
3. Double click the area.
4. Exception occurs: list index of of range. name=self.reclist[rowindex]

What is the expected output? What do you see instead?

Nothing should happen when you double click somewhere without a row/column.


Original issue reported on code.google.com by [email protected] on 17 Nov 2014 at 5:57

Table not redrawn when embodying window is maximized

What steps will reproduce the problem?
1. Create a normal TableCanvas with rows and height set to larger values (say 
30*20)
2. Click window maximize button
3. The contents of TableCanvas outside the initial window range are not 
properly displayed in the maximized window.

What is the expected output? What do you see instead?
All the contents should be properly displayed.

What version of the product are you using? On what operating system?
Latest. Linux

Please provide any additional information below.
Suggestions: in TableCanvas.createTableFrame() add:

        # Fix the bug of not being properly redrawn during maximizing
        # the default behavior only bind <Configure> event for
        # the parent frame BUT NOT for the inherited Canvas class.
        self.bind('<Configure>', lambda event: self.redrawTable())



Original issue reported on code.google.com by [email protected] on 29 Aug 2013 at 3:13

All entries doesnt get deleted on delete

What steps will reproduce the problem?
1. ran testing.py that came with the package.
2. deleted all rows except the last one from the table. Then removed the last 
one.
3. Last one doesnt get deleted. It remain in the table. Once you add new row it 
gets cleared from the view.

What is the expected output? What do you see instead?
the last entry should be delete. last entry doesnt get deleted.


What version of the product are you using? On what operating system?
tkintertable (1.1.2) ( windows 7 64 bit


Please provide any additional information below.


Original issue reported on code.google.com by [email protected] on 19 Mar 2014 at 4:39

Problem with deleteRows when deleting all the rows in table

What steps will reproduce the problem?

Let's say you have a TableModel called tableModel with 10 rows:
-call tableModel.deleteRows(0,10)
or
- select all the rows with GUI and delete them through the popup dialog 
clicking on "Delete Row(s)"

What is the expected output? What do you see instead?

I would expect the rows not to be visible anymore, but they are still visible, 
even if unresponsive to user action, like clicking on them.

What version of the product are you using? On what operating system?

tkintertable-1.1.2, Linux Mint 15 (Ubuntu 13.04)

Please provide any additional information below.

If new rows are inserted, the content of the table is displayed correctly.
The problem appears only if you delete all the rows, not just one or a subset 
of the total rows.


Original issue reported on code.google.com by [email protected] on 18 Mar 2014 at 8:18

prints debug message

Always prints "loading prefs from [filename]" at startup. This should be 
suppressed by default.

Original issue reported on code.google.com by ddruckerccn on 25 Nov 2013 at 6:08

bug in handle_double_click()

What steps will reproduce the problem?
1. Create a TableCanvas with default settings
2. Double click in area beyond the rows or columns
3. IndexError is throwed

What version of the product are you using? On what operating system?
Latest version on Linux

Suggestion: Please modify code in handle_double_click as follows:

        row = self.get_row_clicked(event)
        col = self.get_col_clicked(event)
        if row not in range(0, self.rows) or col not in range(0, self.cols):
            return



Original issue reported on code.google.com by [email protected] on 29 Aug 2013 at 8:27

Support for multi-line entries?

What steps will reproduce the problem?
1. Create a table
2. Add data with a new line
3. Data trails off the bottom edge.

What is the expected output? What do you see instead?

I expected row height to be increased when specific rows need it. That is, rows 
with three lines of data in an entry will be three times as tall, while the 
remaining rows will still be only one line tall.

Sorry if this isn't the right venue, I couldn't find a better way to e-mail you 
guys.

Original issue reported on code.google.com by [email protected] on 17 Nov 2014 at 5:41

requires pmw

What steps will reproduce the problem?
1. go to usage
2. copy and paste imports
3. traceback says no pmw

What is the expected output? What do you see instead?
is it supposed to depend on pmw? I didn't see that in the documentation.

What version of the product are you using? On what operating system?
1.1.2

Please provide any additional information below.
I used pip install tkintertable

Original issue reported on code.google.com by [email protected] on 27 Jun 2013 at 8:55

Install / first use problem

What steps will reproduce the problem?
1. Just use the first 2 import statements
2.
3.

What is the expected output? What do you see instead?
Expect:   Goodness
Actual:
Traceback (most recent call last):
  File "C:\Python32\tbvpython\tkintertable_test1.py", line 5, in <module>
    from tkintertable.Tables import TableCanvas
  File "C:\Python32\lib\site-packages\tkintertable-1.1.2-py3.2-win32.egg\tkintertable\Tables.py", line 560
    print 'found in',row,col
                   ^
SyntaxError: invalid syntax


What version of the product are you using? On what operating system?  1.1.2 
against Python32 on windows XP machine


Please provide any additional information below.
tkinter works with no problem


Original issue reported on code.google.com by [email protected] on 23 Oct 2013 at 12:45

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.