diff --git a/README.md b/README.md index 0ff33d1..8da8dec 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,12 @@ the panel widgets. See the example and docstrings for information on individual properties. +# Install +```sh +pip install kivy-garden.navigationdrawer +``` -# Example:: +# Example from kivy.app import App from kivy.base import runTouchApp diff --git a/examples/example.py b/examples/example.py new file mode 100644 index 0000000..00657c6 --- /dev/null +++ b/examples/example.py @@ -0,0 +1,83 @@ +from kivy.app import App +from kivy.base import runTouchApp +from kivy.uix.boxlayout import BoxLayout +from kivy.uix.label import Label +from kivy.uix.button import Button +from kivy.uix.image import Image +from kivy.uix.widget import Widget +from kivy.core.window import Window +from kivy.metrics import dp + +from kivy_garden.navigationdrawer import NavigationDrawer + +class ExampleApp(App): + + def build(self): + navigationdrawer = NavigationDrawer() + + side_panel = BoxLayout(orientation='vertical') + side_panel.add_widget(Label(text='Panel label')) + side_panel.add_widget(Button(text='A button')) + side_panel.add_widget(Button(text='Another button')) + navigationdrawer.add_widget(side_panel) + + label_head = ( + '[b]Example label filling main panel[/b]\n\n[color=ff0000](p' + 'ull from left to right!)[/color]\n\nIn this example, the le' + 'ft panel is a simple boxlayout menu, and this main panel is' + ' a BoxLayout with a label and example image.\n\nSeveral pre' + 'set layouts are available (see buttons below), but users ma' + 'y edit every parameter for much more customisation.') + main_panel = BoxLayout(orientation='vertical') + label_bl = BoxLayout(orientation='horizontal') + label = Label(text=label_head, font_size='15sp', + markup=True, valign='top') + label_bl.add_widget(Widget(size_hint_x=None, width=dp(10))) + label_bl.add_widget(label) + label_bl.add_widget(Widget(size_hint_x=None, width=dp(10))) + main_panel.add_widget(Widget(size_hint_y=None, height=dp(10))) + main_panel.add_widget(label_bl) + main_panel.add_widget(Widget(size_hint_y=None, height=dp(10))) + main_panel.add_widget(Image(source='red_pixel.png', allow_stretch=True, + keep_ratio=False, size_hint_y=0.2)) + navigationdrawer.add_widget(main_panel) + label.bind(size=label.setter('text_size')) + + def set_anim_type(name): + navigationdrawer.anim_type = name + modes_layout = BoxLayout(orientation='horizontal') + modes_layout.add_widget(Label(text='preset\nanims:')) + slide_an = Button(text='slide_\nabove_\nanim') + slide_an.bind(on_press=lambda j: set_anim_type('slide_above_anim')) + slide_sim = Button(text='slide_\nabove_\nsimple') + slide_sim.bind(on_press=lambda j: set_anim_type('slide_above_simple')) + fade_in_button = Button(text='fade_in') + fade_in_button.bind(on_press=lambda j: set_anim_type('fade_in')) + reveal_button = Button(text='reveal_\nbelow_\nanim') + reveal_button.bind(on_press= + lambda j: set_anim_type('reveal_below_anim')) + slide_button = Button(text='reveal_\nbelow_\nsimple') + slide_button.bind(on_press= + lambda j: set_anim_type('reveal_below_simple')) + modes_layout.add_widget(slide_an) + modes_layout.add_widget(slide_sim) + modes_layout.add_widget(fade_in_button) + modes_layout.add_widget(reveal_button) + modes_layout.add_widget(slide_button) + main_panel.add_widget(modes_layout) + + button = Button(text='toggle NavigationDrawer state (animate)', + size_hint_y=0.2) + button.bind(on_press=lambda j: navigationdrawer.toggle_state()) + button2 = Button(text='toggle NavigationDrawer state (jump)', + size_hint_y=0.2) + button2.bind(on_press=lambda j: navigationdrawer.toggle_state(False)) + button3 = Button(text='toggle _main_above', size_hint_y=0.2) + button3.bind(on_press=navigationdrawer.toggle_main_above) + main_panel.add_widget(button) + main_panel.add_widget(button2) + main_panel.add_widget(button3) + + return navigationdrawer + +ExampleApp().run() diff --git a/navigationdrawer_closed.png b/examples/navigationdrawer_closed.png similarity index 100% rename from navigationdrawer_closed.png rename to examples/navigationdrawer_closed.png diff --git a/navigationdrawer_open_example1.png b/examples/navigationdrawer_open_example1.png similarity index 100% rename from navigationdrawer_open_example1.png rename to examples/navigationdrawer_open_example1.png diff --git a/navigationdrawer_open_example2.png b/examples/navigationdrawer_open_example2.png similarity index 100% rename from navigationdrawer_open_example2.png rename to examples/navigationdrawer_open_example2.png diff --git a/screenshot.png b/examples/screenshot.png similarity index 100% rename from screenshot.png rename to examples/screenshot.png diff --git a/__init__.py b/kivy_garden/navigationdrawer/__init__.py similarity index 100% rename from __init__.py rename to kivy_garden/navigationdrawer/__init__.py diff --git a/kivy_garden/navigationdrawer/_version.py b/kivy_garden/navigationdrawer/_version.py new file mode 100644 index 0000000..cd7ca49 --- /dev/null +++ b/kivy_garden/navigationdrawer/_version.py @@ -0,0 +1 @@ +__version__ = '1.0.1' diff --git a/navigationdrawer_gradient_ltor.png b/kivy_garden/navigationdrawer/navigationdrawer_gradient_ltor.png similarity index 100% rename from navigationdrawer_gradient_ltor.png rename to kivy_garden/navigationdrawer/navigationdrawer_gradient_ltor.png diff --git a/navigationdrawer_gradient_rtol.png b/kivy_garden/navigationdrawer/navigationdrawer_gradient_rtol.png similarity index 100% rename from navigationdrawer_gradient_rtol.png rename to kivy_garden/navigationdrawer/navigationdrawer_gradient_rtol.png diff --git a/kivy_garden/navigationdrawer/tests/test_import.py b/kivy_garden/navigationdrawer/tests/test_import.py new file mode 100644 index 0000000..9bbe60d --- /dev/null +++ b/kivy_garden/navigationdrawer/tests/test_import.py @@ -0,0 +1,6 @@ +import pytest + + +def test_flower(): + from kivy_garden.navigationdrawer import NavigationDrawer + widget = NavigationDrawer() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..97fba05 --- /dev/null +++ b/setup.py @@ -0,0 +1,56 @@ +"""See README.md for package documentation.""" + +from setuptools import setup, find_namespace_packages + +from io import open +from os import path + +here = path.abspath(path.dirname(__file__)) + +filename = path.join(here, 'kivy_garden', 'navigationdrawer', '_version.py') +locals = {} +with open(filename, "rb") as fh: + exec(compile(fh.read(), filename, 'exec'), globals(), locals) +__version__ = locals['__version__'] + +with open(path.join(here, 'README.md'), encoding='utf-8') as f: + long_description = f.read() + +URL = 'https://github.com/Tungsteno74/navigationdrawer' + +setup( + name='kivy_garden.navigationdrawer', + version=__version__, + description='Android Side Panel like widget.', + long_description=long_description, + long_description_content_type='text/markdown', + url=URL, + author='Kivy', + author_email='kivy@kivy.org', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Topic :: Software Development :: Libraries', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + ], + keywords='Kivy kivy-garden', + + packages=find_namespace_packages(include=['kivy_garden.*']), + install_requires=[], + extras_require={ + 'dev': ['pytest>=3.6', 'pytest-cov', 'pytest-asyncio', + 'sphinx_rtd_theme'], + 'ci': ['coveralls', 'pycodestyle'], + }, + package_data={'':['navigationdrawer_gradient_ltor.png', 'navigationdrawer_gradient_rtol.png']}, + data_files=[], + entry_points={}, + project_urls={ + 'Bug Reports': URL + '/issues', + 'Source': URL, + }, +)