This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Make python -m tkinter run tkinter demo
Type: enhancement Stage: resolved
Components: Tkinter Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: belopolsky Nosy List: belopolsky, benjamin.peterson, eric.araujo, michael.foord
Priority: normal Keywords: easy, needs review, patch

Created on 2010-07-26 17:46 by belopolsky, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tkinter-m.py belopolsky, 2010-07-26 17:46
issue9387a.diff belopolsky, 2010-07-27 00:13
Messages (9)
msg111654 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-26 17:46
Since tkinter is a package, it requires __main__.py in order to be runnable using -m option.  Attached tkinter-m.patch fixes this.
msg111664 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-07-26 20:16
I lack context: Why is being able to run “python -m tkinter” useful? Tests can be run directly or via regrtest, and I recall Guido saying that using modules as scripts was an anti-pattern to him, i.e. sometimes useful but not always necessary.
msg111672 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-26 23:10
On Mon, Jul 26, 2010 at 4:16 PM, Éric Araujo <report@bugs.python.org> wrote:
..
> I lack context: Why is being able to run “python -m tkinter” useful?

The missing context is in issue 9384.  I discovered that  python -m
tkinter did not work when I was looking for a simple way to
demonstrate the tkinter pop-under bug.  The demo code was already in
the package but would not run using -m option.

> Tests can be run directly or via regrtest, and I recall Guido saying that using modules as scripts
> was an anti-pattern to him, i.e. sometimes useful but not always necessary.

I have not heard it from Guido, but I agree with one exception.  If
the module contains doctests, it is useful to have doctest run
boilerplate in the file.   While regrtest runs most of the existing
doctests, it does not discover them and there is no option to run
doctests separately from unit tests as far as I know.

Note that tkinter._test() is not really a test, it is a tiny demo
program.  (I am changing the title accordingly.)   I think exposing it
as python -m tkinter would provide one obvious way for users to see if
they have working tkinter and what its widgets look like.
msg111674 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-07-26 23:37
Thanks for explaining. +1 on the patch. Maybe add a note in library/tkinter to explain this way of checking if the installation is right.
msg111675 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-27 00:13
issue9387a.diff includes a note in library/tkinter.rst.  The note can probably be improved.
msg111692 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-07-27 09:48
The note seems fine to me. I’d used a semicolon, not a period, but that’s just me.

You want to use `` to mark up code, not `.

Aside: I’ve been told before not to do wrapping or whitespace changes unrelated to the object of my patch, to ease review.
msg111697 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-27 14:16
Committed with changes suggested by Éric in r83177.
msg111699 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-07-27 14:44
BTW, why is the sys.argv hackery necessary? Does import or runpy or something force us to jump through hoops?
msg111701 - (view) Author: Alexander Belopolsky (belopolsky) * (Python committer) Date: 2010-07-27 15:10
On Tue, Jul 27, 2010 at 10:44 AM, Éric Araujo <report@bugs.python.org> wrote:
>
> Éric Araujo <merwok@netwok.org> added the comment:
>
> BTW, why is the sys.argv hackery necessary?
> Does import or runpy or something force us to jump through hoops?

I guess we need to ask benjamin.peterson or michael.foord.  I just
copied the hack from unittest/__main__.py.   I believe this is done in
order to convince optparse to print "python -m modname" rather than
"modname.py" in the python -m modname -h output.  Of course, tkinter
does not support -h (yet?), but I thought it would be better to
maintain consistency in how __main__.py is written.
History
Date User Action Args
2022-04-11 14:57:04adminsetgithub: 53633
2010-07-27 15:11:24belopolskysetnosy: + benjamin.peterson, michael.foord
2010-07-27 15:10:53belopolskysetmessages: + msg111701
2010-07-27 14:44:49eric.araujosetmessages: + msg111699
2010-07-27 14:16:53belopolskysetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg111697

stage: commit review -> resolved
2010-07-27 09:48:43eric.araujosetmessages: + msg111692
2010-07-27 00:13:46belopolskysetresolution: accepted
stage: patch review -> commit review
2010-07-27 00:13:12belopolskysetfiles: + issue9387a.diff
keywords: + patch
messages: + msg111675
2010-07-26 23:37:51eric.araujosetmessages: + msg111674
2010-07-26 23:10:00belopolskysetmessages: + msg111672
title: Make python -m tkinter run tkinter test -> Make python -m tkinter run tkinter demo
2010-07-26 20:16:53eric.araujosetnosy: + eric.araujo
messages: + msg111664
2010-07-26 17:47:25belopolskysetkeywords: + needs review
stage: patch review
versions: + Python 3.2
2010-07-26 17:46:21belopolskycreate