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

Tkinter - cannot import tklib

357 views
Skip to first unread message

Wolfgang Grafen

unread,
Jun 20, 2022, 6:43:45 PM6/20/22
to
Hello all,

I am an experienced Python user and struggle with following statement:

>>> from tklib import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tklib'

I tried to import tklib as shown above on following of my Python installations: Anaconda Python 3.8.3, Portable Python 3.9, Python 3.10.1, Python 2.7.10 with the same negative result.

I also tried to find help by googling - without success. Also I did not find a python module called tklib to install. Tkinter, ttk is working fine.

There are numerous examples using "from tklib import *" so I assume it works for most. In the tk-tutorial below tklib is used without special explanation, so I assume it should be installed by default with every python installation which has Tkinter integrated.

https://tk-tutorial.readthedocs.io/en/latest/intro/intro.html?highlight=app#

First time that I cannot help myself. Please help, what do I do wrong?

Greetings
Wolfgang

MRAB

unread,
Jun 20, 2022, 8:06:39 PM6/20/22
to
I'm thinking that maybe that tutorial is about writing a module (called
"tklib") to make it easier to write tkinter applications.

The tkinter "Text" widget, for example, doesn't have its own scrollbars
(you have to add them separately and link them to the widget), so
writing a module that defines a text-with-scrollbars widget is a good idea.

Dennis Lee Bieber

unread,
Jun 20, 2022, 8:43:42 PM6/20/22
to
On Mon, 20 Jun 2022 15:43:26 -0700 (PDT), Wolfgang Grafen
<wolfgan...@gmail.com> declaimed the following:

>
>There are numerous examples using "from tklib import *" so I assume it works for most. In the tk-tutorial below tklib is used without special explanation, so I assume it should be installed by default with every python installation which has Tkinter integrated.
>
>https://tk-tutorial.readthedocs.io/en/latest/intro/intro.html?highlight=app#
>
>First time that I cannot help myself. Please help, what do I do wrong?
>

From what I can see, you haven't /written/ a tklib module.

That tutorial assumes you will create a module containing a number of
simplified interfaces to tk widgets. cf:
https://tk-tutorial.readthedocs.io/en/latest/radio/radio.html#a-better-radiobutton-class
tklib.py will contain the definition of the Radiobutton class. The same
probably applies everywhere that you see tklib imported -- whatever classes
are used to create widgets need to be defined in that file.

https://tk-tutorial.readthedocs.io/en/latest/intro/intro.html?highlight=app#
"""
In the following section we are going to redefine the tk and ttk objects.
To make it easier to use them, we follow these design principles:

we keep the excact same class names
the parent object is chosen automatically
all keyword arguments are forwarded

The first widget to consider is the Label which just places static text.
Where it makes sense, a label will be combined with a button or entry
widget.
"""

https://tk-tutorial.readthedocs.io/en/latest/check/check.html#a-better-checkbutton-class
etc.


--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

David

unread,
Jun 21, 2022, 6:33:50 AM6/21/22
to
On Tue, 21 Jun 2022 at 09:22, Wolfgang Grafen <wolfgan...@gmail.com> wrote:

> I am an experienced Python user and struggle with following statement:
>
> >>> from tklib import *
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ModuleNotFoundError: No module named 'tklib'

[...]

> I did not find a python module called tklib to install.

Ok, see below for how to find that file.

[...]

> I assume it should be installed by default with every python installation

It appears that your assumption is wrong. It appears to me that the
missing file is part of the tk-tutorial project.

> https://tk-tutorial.readthedocs.io/en/latest/intro/intro.html?highlight=app#

> First time that I cannot help myself. Please help, what do I do wrong?

Hi, here is a description how I found the file you seek:

Go to https://tk-tutorial.readthedocs.io/en/latest/intro/intro.html

At the top right of the page, see hyperlink "Edit on GitHub".
Click hyperlink takes you to
https://github.com/rasql/tk-tutorial/blob/master/docs/intro/intro.rst
which is the same content rendered from 'rst' format I assume.

At top left of that page, see hyperlinks "tk-tutorial"/"docs"/"intro"
and "rasql"/"tk-tutorial".

Click one of the "tk-tutorial" hyperlinks to go to the top directory
of the project at:
https://github.com/rasql/tk-tutorial

On that page near the very top, see a list of hyperlinks to
directories and files of the project. One of those hyperlinks
is labelled "tklib.py". Click that link to see the file at
https://github.com/rasql/tk-tutorial/blob/master/tklib.py

On that page, click the "Raw" button. Then you can use "save as"
in your browser. Or you can just download it by some other
method from the link given in the previous paragraph.
0 new messages