diff --git a/pyface/action/api.pyi b/pyface/action/api.pyi new file mode 100644 index 000000000..397cdf76b --- /dev/null +++ b/pyface/action/api.pyi @@ -0,0 +1,23 @@ +# (C) Copyright 2005-2023 Enthought, Inc., Austin, TX +# All rights reserved. +# +# This software is provided without warranty under the terms of the BSD +# license included in LICENSE.txt and may be redistributed only under +# the conditions described in the aforementioned license. The license +# is also available online at http://www.enthought.com/licenses/BSD.txt +# +# Thanks for using Enthought open source! + +from typing import Type + +from .i_menu_bar_manager import IMenuBarManager +from .i_menu_manager import IMenuManager +from .i_status_bar_manager import IStatusBarManager +from .i_tool_bar_manager import IToolBarManager + + +# we know these are importable and implement the interfaces +MenuBarManager: Type[IMenuBarManager] +MenuManager: Type[IMenuManager] +StatusBarManager: Type[IStatusBarManager] +ToolBarManager: Type[IToolBarManager] diff --git a/pyface/i_image_resource.py b/pyface/i_image_resource.py index 5df954c05..e0df4a6cd 100644 --- a/pyface/i_image_resource.py +++ b/pyface/i_image_resource.py @@ -11,7 +11,7 @@ from collections.abc import Sequence -from traits.api import HasTraits, List, Str +from traits.api import Directory, HasTraits, List, Str from pyface.i_image import IImage from pyface.resource.resource_path import resource_module, resource_path @@ -34,7 +34,7 @@ class IImageResource(IImage): #: A list of directories, classes or instances that will be used to search #: for the image (see the resource manager for more details). - search_path = List() + search_path = List(Directory()) @classmethod def image_size(cls, image): diff --git a/pyface/resource/resource_manager.py b/pyface/resource/resource_manager.py index 9feacc21b..97d063f4a 100644 --- a/pyface/resource/resource_manager.py +++ b/pyface/resource/resource_manager.py @@ -29,7 +29,7 @@ except ImportError: from importlib_resources import files -from traits.api import HasTraits, Instance, List +from traits.api import Directory, HasTraits, Instance, List from traits.util.resource import get_path from pyface.resource.resource_factory import ResourceFactory @@ -48,7 +48,7 @@ class ResourceManager(HasTraits): # A list of additional search paths. These paths are fallbacks, and hence # have lower priority than the paths provided by resource objects. - extra_paths = List() + extra_paths = List(Directory) # The resource factory is responsible for actually creating resources. # This is used so that (for example) different GUI toolkits can create diff --git a/pyface/ui_traits.pyi b/pyface/ui_traits.pyi new file mode 100644 index 000000000..e4fecdbb1 --- /dev/null +++ b/pyface/ui_traits.pyi @@ -0,0 +1,96 @@ +# (C) Copyright 2005-2023 Enthought, Inc., Austin, TX +# All rights reserved. +# +# This software is provided without warranty under the terms of the BSD +# license included in LICENSE.txt and may be redistributed only under +# the conditions described in the aforementioned license. The license +# is also available online at http://www.enthought.com/licenses/BSD.txt +# +# Thanks for using Enthought open source! + +from collections.abc import Sequence +from typing import Any, Callable, Dict, Optional, Union + +from traits.api import ABCHasStrictTraits, Enum, Range +from traits.trait_type import _TraitType + +from pyface.util.font_parser import simple_parser +from .color import Color +from .font import Font +from .i_image import IImage + + +class Image(_TraitType[Union[IImage, str], Optional[IImage]]): + + def __init__(self, value: Union[IImage, str, None] = None, **metadata) -> None: + ... + + +class PyfaceColor(_TraitType[Union[Color, str, Sequence], Color]): + + def __init__( + self, + value: Union[Color, str, Sequence, None] = None, + **metadata, + ) -> None: + ... + + +class PyfaceFont(_TraitType[Union[Font, str], Font]): + + def __init__( + self, + value: Union[Font, str, None] = None, + parser: Callable[[str], Dict[str, Any]] = simple_parser, + **metadata, + ) -> None: + ... + + +class BaseMB(ABCHasStrictTraits): + ... + + +class Margin(BaseMB): + + # The amount of padding/margin at the top: + top = Range(-32, 32, 0) + + # The amount of padding/margin at the bottom: + bottom = Range(-32, 32, 0) + + # The amount of padding/margin on the left: + left = Range(-32, 32, 0) + + # The amount of padding/margin on the right: + right = Range(-32, 32, 0) + + +class HasMargin(_TraitType[Union[int, tuple, Margin], Margin]): + ... + + +class Border(BaseMB): + + # The amount of border at the top: + top = Range(0, 32, 0) + + # The amount of border at the bottom: + bottom = Range(0, 32, 0) + + # The amount of border on the left: + left = Range(0, 32, 0) + + # The amount of border on the right: + right = Range(0, 32, 0) + + +class HasBorder(_TraitType[Union[int, tuple, Border], Border]): + ... + +Position = Enum("left", "right", "above", "below") + +Alignment = Enum("default", "left", "center", "right") + +Orientation = Enum("vertical", "horizontal") +