Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tkinter: tksheet

836 views
Skip to first unread message

Rich Shepard

unread,
Jun 16, 2021, 12:31:56 PM6/16/21
to
Reading the doc for tksheet tells me that it allows me to modify cells (or
entire rows) as well as display them. What I don't see is whether I can add
a new row using tksheet and change the column used for sorting (e.g.,
sorting by company number or company name).

If you have experience with tksheet perhaps you can answer my questions
about it's capabilities.

Rich

Terry Reedy

unread,
Jun 16, 2021, 4:05:18 PM6/16/21
to
On 6/16/2021 12:31 PM, Rich Shepard wrote:
> Reading the doc for tksheet tells me that it allows me to modify cells (or
> entire rows) as well as display them. What I don't see is whether I can add
> a new row using tksheet

Somewhat sparse doc at
https://github.com/ragardner/tksheet/blob/master/DOCUMENTATION.md#5-modifying-table-data

insert_row()

and change the column used for sorting (e.g.,
> sorting by company number or company name).

I did not see anything about sorting. tksheet is generic 'table', not a
database viewer

--
Terry Jan Reedy

Rich Shepard

unread,
Jun 16, 2021, 4:46:11 PM6/16/21
to
On Wed, 16 Jun 2021, Terry Reedy wrote:

> Somewhat sparse doc at
> https://github.com/ragardner/tksheet/blob/master/DOCUMENTATION.md#5-modifying-table-data
> insert_row()

Terry,

I'm reading this now and saw that.

> and change the column used for sorting (e.g.,
>> sorting by company number or company name).
>
> I did not see anything about sorting. tksheet is generic 'table', not a
> database viewer

The two applications I'm building are both database applications. If
tksheet() is not the most appropriate widget to display database tables what
alternative would be better?

Thanks,

Rich

dn

unread,
Jun 16, 2021, 5:49:13 PM6/16/21
to
Use the DBMS by retrieving the data in the desired sequence?
--
Regards,
=dn

Alan Gauld

unread,
Jun 16, 2021, 6:37:12 PM6/16/21
to
On 16/06/2021 21:45, Rich Shepard wrote:

> The two applications I'm building are both database applications. If
> tksheet() is not the most appropriate widget to display database tables what
> alternative would be better?

I've not used tksheet but it sounds like it might be worth investigating.

There is a grid in Tix but its quite hard to use and Tix is now
deprecated. It was also a bit unreliable when used from
Python (that's euphemistic for "I couldn't get it to work!" :-)

But there is nothing I know of for Tkinter that provides views
of database tables in the way that Delphi or VB or C# do, for
example. You have to extract the data using SQL and populate
the table and manage all changes (of both view and data) yourself.

A good grid component would be a huge boon for tkinter, its one
of the most commonly used widgets in VB/Delphi etc

A DB-API linked grid would be the height of luxury...

If you do a lot of that kind of desktop apps then you could
look at Dabo which is built on wxPython but has links to databases.
Unfortunately it looks like work ground to a halt about 5 years ago.

--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos


Rich Shepard

unread,
Jun 16, 2021, 7:07:16 PM6/16/21
to
On Wed, 16 Jun 2021, Dennis Lee Bieber wrote:

> Scroll further down to "bindings"... rc_insert_row -- a <right-click>
> menu binding

Dennis,

Yes, I saw that one, too.

> As for sorting, I don't see anything that allows one to add custom
> events to the bindings... best I can come up with is that if a header
> column is selected you sort the data and reload the table.

My naive idea is to use two queries, one selects * from the company table
ordered by nunber, the other by name. The UI offers two radiobuttons when
viewing the results, one for each sort column.

Thanks,

Rich

Rich Shepard

unread,
Jun 16, 2021, 7:08:30 PM6/16/21
to
On Thu, 17 Jun 2021, dn via Python-list wrote:

> Use the DBMS by retrieving the data in the desired sequence?

dn,

Yep. That's what I thought would be the best approach.

Thanks,

Rich

Rich Shepard

unread,
Jun 16, 2021, 7:16:03 PM6/16/21
to
On Wed, 16 Jun 2021, Alan Gauld via Python-list wrote:

> But there is nothing I know of for Tkinter that provides views of database
> tables in the way that Delphi or VB or C# do, for example.

Alan,

These are all Microsoft tools. I run linux only.

> You have to extract the data using SQL and populate the table and manage
> all changes (of both view and data) yourself.

>From an incomplete reading of the tksheet() doc it looks to be the best way
to display tables returned by a SQL query. PyQt5 has a QTableView() that
does the job, and it works great for a single table, but apparently not so
well with complex joins on multiple tables.

When I view my contacts table it needs to includes attributes from the
company, people, and contacts tables so I can view all prior contacts with
that person.

> If you do a lot of that kind of desktop apps then you could look at Dabo
> which is built on wxPython but has links to databases. Unfortunately it
> looks like work ground to a halt about 5 years ago.

Many years ago I used wxPython. For several reasons I decided to learn and
use tkinter from now one. One reason is that the application for my clients
will run mostly on windows hosts and I want to limit the software they need
to install and maintain in order to run it.

Regards,

Rich

Alan Gauld

unread,
Jun 17, 2021, 12:13:51 PM6/17/21
to
On 17/06/2021 00:15, Rich Shepard wrote:

> When I view my contacts table it needs to includes attributes from the
> company, people, and contacts tables so I can view all prior contacts with
> that person.

Sounds like a job for a database view.
Can you modify the database schema? Could you create a
view - even a temporary one just while your app is running?

Alternatively, and I've done this trick myself, create an
in-memory SqlLite database with a table that holds all the
columns you want then fetch the data from the master and
manipulate/view it from Sqlite - this makes sorting by
different columns fast and simple.

The downside is you have to refresh it periodically or
you will miss all changes in the master.

> Many years ago I used wxPython. For several reasons I decided to learn and
> use tkinter from now one. One reason is that the application for my clients
> will run mostly on windows hosts and I want to limit the software they need
> to install and maintain in order to run it.

Sure, that's the main reason I use tkinter too.

Rich Shepard

unread,
Jun 17, 2021, 12:29:28 PM6/17/21
to
On Thu, 17 Jun 2021, Dennis Lee Bieber wrote:

>> My naive idea is to use two queries, one selects * from the company table
>> ordered by nunber, the other by name. The UI offers two radiobuttons when
>> viewing the results, one for each sort column.
>>
> Presuming all the data fits in memory, it may be faster to just define
> the key structure for Python's internal sort() function than to go back out
> to the database server, wait for it to gather the desired fields and sort
> them, then transfer all the data back to your script.

Dennis,

That's a possibility.

Thanks,

Rich

Rich Shepard

unread,
Jun 17, 2021, 12:31:51 PM6/17/21
to
On Thu, 17 Jun 2021, Alan Gauld via Python-list wrote:

> Sounds like a job for a database view. Can you modify the database schema?
> Could you create a view - even a temporary one just while your app is
> running?

Alan,

Yes, created views work well with postgres. Building one for complex,
multitable queries is always a good idea.

Thanks,

Rich

Rich Shepard

unread,
Jun 17, 2021, 12:33:55 PM6/17/21
to
On Thu, 17 Jun 2021, Dennis Lee Bieber wrote:

> FreePascal/Lazarus is supposed to be similar to Delphi, and does
> have Linux installs -- but I don't know what it provides for database
> linkages. I do have it installed on my Windows box (the Linux install is
> HUGE; takes up over 1/4 of the space on BeagleBone Black so I didn't
> install it there).

Dennis,

In the 1980s I looked closely at Pascal. More recently I did so again
because the local linux/UNIX group had a presentation on its use. Decided
another language was not for me.

Thanks,

Rich
0 new messages