Skip to content

tkinter.OptionMenu command types say requires StringVar but gets str put in at runtime. #16657

Closed

Description

@VectorZeroAI

In python version 3.14.8

Example

def c_print(input: StringVar) -> None:
    print(input.get())

tk.OptionMenu(..., command=c_print)

Gives RuntimeError with string has no attribute get.

But when I do

def c_print(input: str) -> None:
    print(input)

tk.OptionMenu(..., command=c_print)

It works.

So I guess its just wrong? Sorry if I wrote something wrong here.

Activity

  1. Akuli commented on Nov 1, 2026

    @Akuli
    Collaborator

    Thanks for reporting this! Your code is correct, our stubs are wrong. @chiliec already submitted a fix.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions