Skip to content

Tkinter message box and the debugger #1161

Backlog

Description

@duaneellissd

I have what I think is a rather simple use case of the tkinter.messagebox.askokcancel

First - the application is NOT - a PythonTK application. The application is a test procedure we are trying to automate.

There are many steps in the procedure where we must stop the test, and ask the user to "do something" we cannot automate. For example, the human might need to turn the power switch on some equipment. ON or OFF.

We do that via: tkinter.messagebox.askokcancel - if there is/was another recommendation that would be great. Please recommend.

out side of VSCODE the message box appears, the human can click ok/cancel and the test moves on.
In our use case; "OK means continue" - "CANCEL" means stop/fail" the procedure.

PROBLEM STATEMENT:
Inside VSCODE - (A) Nothing pops up, (B) The application is sort of "DEAD" to the world.

The application is NOT stopped at a break point - it is running. We do not have a 'mainloop' - like thing for TK - I would understand the UI freezing if we had a main loop - but - we do not, and running the script from the console does not require one.

I do understand the idea about the TK main loop - and its purpose (it basically handles the window messages) but our existing app does not use the main loop, and the messagebox works.

So my question is:
How can I debug pythonTK applications in VSCODE? Or is this an unsupported solution?

Activity

  1. added
    triage-needed
    on Dec 1, 2026
  2. rchiodo commented on Dec 1, 2026

    @rchiodo
    Contributor

    I tried a minimal example on Windows with Python 3.11.9 and Tk 8.6, without an explicit Tk main loop:

    from tkinter import messagebox
    
    print("Before")
    print(messagebox.askokcancel("Test", "Continue?"))
    print("After")

    The dialog appeared and the script continued after dismissal both without a debugger and with debugpy attached. I also launched it through the debug adapter using the VS Code Python Debugger extension's bundled debugpy 1.8.21; the dialog appeared, Cancel returned False, and the script exited normally.

    I couldn't reproduce the reported hang with this example. The debug launch used a DAP client rather than the VS Code UI, so it doesn't rule out a VS Code-specific or environment-specific issue. Could you share your OS, Python and debugger extension versions, launch configuration, and a minimal example that reproduces it?

  3. added
    question
    and removed
    triage-needed
    on Dec 1, 2026
  4. duaneellissd commented on Dec 1, 2026

    @duaneellissd
    Author

    First - Thanks for trying this - and yes, that is basically all that we am doing in VSCODE.. it is purposely very simple.

    Agh.. that is where this becomes very hard on my end. the work is (A) in another building (B) I have no external network access when I am in that building, no cellphone either, aka: developing in an "air gapped network" environment.

    GRRR!!! security, security, security .. grr grr and grr. it just makes it hard - your US tax dollars at work here.

    I am using Python 3.12 - and what ever TK version that comes with that.
    I am running on Windows 11 - under VSCODE - an older one - I do not know the details,
    Not sure about the debugy.py version -
    Launch config - nothing special - just open the file in VSCODE and click: "RUN" or click "DEBUG".

    I'll try to get more details when I can get into the lab.

    DAP client? I presume that means PYCHARM? - I like that tool but sadly - because of various internal rules, all things IntellaJ are forbidden. Another set of GRR and GRR and more GRR... sounds.

  5. rchiodo commented on Dec 1, 2026

    @rchiodo
    Contributor

    No DAP client just means it was tested with a command line tool. I also tested that code with VS code itself and it worked fine. The dialog did show up.

    It doesn't steal the focus though. I had to alt+tab to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    question

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions