Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix python autocomplete #997

Merged
merged 2 commits into from
Oct 18, 2021
Merged

Commits on Oct 13, 2021

  1. BUG: Fix autocomplete in Python console

    Autocomplete returned list of attributes for non-existing members of a class. For example: `myobj.nonexisting.a` returned all the completions for `myobj.a`.
    Fixed by clearing the list of completions if a non-existing attribute is used.
    
    Also fixed the interpreter getting stuck in an error state after invalid autocomplete (or other Python errors).
    Fixed by always resetting the error state before command execution and after failed command executions.
    lassoan committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    393bbcc View commit details
    Browse the repository at this point in the history
  2. ENH: Improve Python autocomplete list ordering

    Before this change, a strict alphabetical sorting was used, which means that order of attributes was:
    - uppercase letters: constants + internal classes + VTK methods
    - underscore: private attributes
    - lowercase letters: Python and Qt attributes and methods
    
    For example attributes of a Qt class:
    
    ```
    AllowNestedDocks
    AllowTabbedDocks
    AnimatedDocks
    DockOption()
    ...
    PdmPhysicalDpiY
    PdmWidth
    PdmWidthMM
    RenderFlag()
    RenderFlags()
    VerticalTabs
    __bool__()
    __class__()
    __delattr__()
    __dict__
    __dir__()
    __doc__
    __eq__()
    __format__()
    ...
    __setattr__()
    __sizeof__()
    __str__()
    __subclasshook__()
    __weakref__
    acceptDrops
    accessibleDescription
    accessibleName
    actionEvent()
    addToolBar()
    ...
    windowRole()
    windowState()
    windowTitle
    windowTitleChanged()
    windowType()
    x
    y
    ```
    
    This means that the user must scroll through a lot of irrelevant parts before gets to method names.
    
    After this change, attributes are grouped into the following categories and displayed in this order:
    - Python and Qt attributes and methods (starts with lowercase letter)
    - VTK methods + static classes and types (starts with uppercase letter, ends with parenthesis)
    - constants (starts with uppercase letter, does not end with parenthesis)
    - private attributes (starts with underscore)
    
    Case insensitive comparison is used within each group.
    
    Example:
    
    ```
    acceptDrops
    accessibleDescription
    accessibleName
    actionEvent()
    actions()
    activateWindow()
    addAction()
    ...
    windowType()
    winId()
    x
    y
    DockOption()
    DockOptions()
    PaintDeviceMetric()
    RenderFlag()
    RenderFlags()
    AllowNestedDocks
    AllowTabbedDocks
    AnimatedDocks
    DrawChildren
    ...
    PdmWidthMM
    VerticalTabs
    __bool__()
    __class__()
    __delattr__()
    ...
    __str__()
    __subclasshook__()
    __weakref__
    ```
    lassoan committed Oct 13, 2021
    Configuration menu
    Copy the full SHA
    eb73b22 View commit details
    Browse the repository at this point in the history