Subject: 27.2; Inferior Python/ M-x run-python problem with Tk on Windows

From: Robert Thorpe <[email-masked]>
Date: Tue, 26 Apr 2022 05:03:58 +0100

I have a problem with M-x run-python on Windows 10 enterprise.

The python code I'm working on uses Tk.  Unfortunately, after Tk is used
the inferior python no longer responds to inputs.  I see one more
prompt, then nothing at all.

Type the following into an inferior python process.  Or alternatively,
put it in a file and import it.

import tkinter as tk
from tkinter import ttk
window = tk.Tk()

This pops up a Tk window with nothing in it.  It also gives another
python prompt.  But after that communication between Emacs and the
inferior python process seems to be lost.

It seems that someone had the same problem 20 years ago.  I can't find
anyone having this problem recently though.
https://python-list.python.narkive.com/miSHgA8U/problems-with-tkinter-based-scripts-under-emacs

If it helps I'm using Python 3.9.11 64-bit and Tcl/Tk 8.6.

(I am sending this from Emacs 27.2 on Arch but I've copied over the
debug text below from the PC with the issue).

BR,
Robert Thorpe

In GNU Emacs 28.1 (build 52, x86_64-w64-mingw32)
 of 2022-04-04 built on AVALON
Repository revision: 5a223c7f2ef4c31abbd46367b6ea83cd19d30aa7
Repository branch: heads/emacs-28.1
Windowing system distributor 'Microsoft Corp.', version 10.0.19042
System Description: Microsoft Windows 10 Enterprise (v10.0.2009.19042.1586)

Configured using:
 'configure --without-dbus --with-native-compilation
 --without-compress-install CFLAGS=-O2'

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
XPM ZLIB

(NATIVE_COMP present but libgccjit not available)

Important settings:
  value of $LANG: ENI
  locale-coding-system: cp1252

Major mode: Inferior Python

Minor modes in effect:
  compilation-shell-minor-mode: t
  shell-dirtrack-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa
derived epg rfc6068 epg-config gnus-util rmail rmail-loaddefs mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
mule-util compile text-property-search python tramp-sh tramp
tramp-loaddefs trampver tramp-integration files-x tramp-compat shell
pcomplete parse-time iso8601 time-date format-spec auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json subr-x map
comint ring ansi-color cl-extra seq byte-opt gv bytecomp byte-compile
cconv help-mode novice dired-aux cl-loaddefs cl-lib dired dired-loaddefs
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel dos-w32 ls-lisp disp-table
term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu
timer select scroll-bar mouse jit-lock font-lock syntax font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice
button loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads w32notify w32 lcms2 multi-tty
make-network-process native-compile emacs)

Memory information:
((conses 16 79959 6409)
 (symbols 48 9143 1)
 (strings 32 29136 1864)
 (string-bytes 1 996338)
 (vectors 16 18266)
 (vector-slots 8 255188 8970)
 (floats 8 46 170)
 (intervals 56 562 0)
 (buffers 992 17))