[Python] How can I determine dynamically the expected types for a widget options in tkinter?...

Discussão em 'Python' iniciado por Stack, Maio 11, 2025.

  1. Stack

    Stack Membro Participativo

    I know that I can get all valid options for a tkinter widget calling the configure method, but I wonder if there is a way to get the expected types for those attributes.

    Pylance can give me every all expected parameter types for a specific __init__ method, as follows:

    def __init__(
    self: Frame,
    master: Misc | None = None,
    *,
    border: _ScreenUnits = ...,
    borderwidth: _ScreenUnits = ...,
    class_: str = "",
    cursor: _Cursor = "",
    height: _ScreenUnits = 0,
    name: str = ...,
    padding: _Padding = ...,
    relief: _Relief = ...,
    style: str = "",
    takefocus: _TakeFocusValue = "",
    width: _ScreenUnits = 0
    ) -> None


    I want to do this for every option of every tk/ttk widget, and it would be really annoying and time-consuming to copy and paste everything.

    Is there any way to get them dynamically?

    Continue reading...

Compartilhe esta Página