kivy-garden.navigationdrawer


Namekivy-garden.navigationdrawer JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/Tungsteno74/navigationdrawer
SummaryAndroid Side Panel like widget.
upload_time2023-04-05 07:51:22
maintainer
docs_urlNone
authorKivy
requires_python
license
keywords kivy kivy-garden
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # NavigationDrawer

The NavigationDrawer widget provides a hidden panel view designed to
duplicate the popular Android layout.  The user views one main widget
but can slide from the left of the screen to view a second, previously
hidden widget. The transition between open/closed is smoothly
animated, with the parameters (anim time, panel width, touch
detection) all user configurable. If the panel is released without
being fully open or closed, it animates to an appropriate
configuration.

NavigationDrawer supports many different animation properties,
including moving one or both of the side/main panels, darkening
either/both widgets, changing side panel opacity, and changing which
widget is on top. The user can edit these individually to taste (this
is enough rope to hang oneself, it's easy to make a useless or silly
configuration!), or use one of a few preset animations.

The hidden panel might normally a set of navigation buttons (e.g. in a
GridLayout), but the implementation lets the user use any widget(s).

The first widget added to the NavigationDrawer is automatically used
as the side panel, and the second widget as the main panel. No further
widgets can be added, further changes are left to the user via editing
the panel widgets.

# Usage summary

- The first widget added to a NavigationDrawer is used as the hidden
  side panel.
- The second widget added is used as the main panel.
- Both widgets can be removed with remove_widget, or alternatively
  set/removed with set_main_panel and set_side_panel.
- The hidden side panel can be revealed by dragging from the left of
  the NavigationDrawer. The touch detection width is the
  touch_accept_width property.
- Every animation property is user-editable, or default animations
  can be chosen by setting anim_type.

See the example and docstrings for information on individual properties.

# Install
```sh
pip install kivy-garden.navigationdrawer
```

# Example

    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()




            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Tungsteno74/navigationdrawer",
    "name": "kivy-garden.navigationdrawer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Kivy kivy-garden",
    "author": "Kivy",
    "author_email": "kivy@kivy.org",
    "download_url": "https://files.pythonhosted.org/packages/c1/7c/c9be159d682d1e2e13ff29e42695114b1ab6dbb9b10d9946d1440d42418b/kivy_garden.navigationdrawer-1.0.2.tar.gz",
    "platform": null,
    "description": "# NavigationDrawer\r\n\r\nThe NavigationDrawer widget provides a hidden panel view designed to\r\nduplicate the popular Android layout.  The user views one main widget\r\nbut can slide from the left of the screen to view a second, previously\r\nhidden widget. The transition between open/closed is smoothly\r\nanimated, with the parameters (anim time, panel width, touch\r\ndetection) all user configurable. If the panel is released without\r\nbeing fully open or closed, it animates to an appropriate\r\nconfiguration.\r\n\r\nNavigationDrawer supports many different animation properties,\r\nincluding moving one or both of the side/main panels, darkening\r\neither/both widgets, changing side panel opacity, and changing which\r\nwidget is on top. The user can edit these individually to taste (this\r\nis enough rope to hang oneself, it's easy to make a useless or silly\r\nconfiguration!), or use one of a few preset animations.\r\n\r\nThe hidden panel might normally a set of navigation buttons (e.g. in a\r\nGridLayout), but the implementation lets the user use any widget(s).\r\n\r\nThe first widget added to the NavigationDrawer is automatically used\r\nas the side panel, and the second widget as the main panel. No further\r\nwidgets can be added, further changes are left to the user via editing\r\nthe panel widgets.\r\n\r\n# Usage summary\r\n\r\n- The first widget added to a NavigationDrawer is used as the hidden\r\n  side panel.\r\n- The second widget added is used as the main panel.\r\n- Both widgets can be removed with remove_widget, or alternatively\r\n  set/removed with set_main_panel and set_side_panel.\r\n- The hidden side panel can be revealed by dragging from the left of\r\n  the NavigationDrawer. The touch detection width is the\r\n  touch_accept_width property.\r\n- Every animation property is user-editable, or default animations\r\n  can be chosen by setting anim_type.\r\n\r\nSee the example and docstrings for information on individual properties.\r\n\r\n# Install\r\n```sh\r\npip install kivy-garden.navigationdrawer\r\n```\r\n\r\n# Example\r\n\r\n    from kivy.app import App\r\n    from kivy.base import runTouchApp\r\n    from kivy.uix.boxlayout import BoxLayout\r\n    from kivy.uix.label import Label\r\n    from kivy.uix.button import Button\r\n    from kivy.uix.image import Image\r\n    from kivy.uix.widget import Widget\r\n    from kivy.core.window import Window\r\n    from kivy.metrics import dp\r\n\r\n    from kivy.garden.navigationdrawer import NavigationDrawer\r\n\r\n    class ExampleApp(App):\r\n\r\n        def build(self):\r\n            navigationdrawer = NavigationDrawer()\r\n\r\n            side_panel = BoxLayout(orientation='vertical')\r\n            side_panel.add_widget(Label(text='Panel label'))\r\n            side_panel.add_widget(Button(text='A button'))\r\n            side_panel.add_widget(Button(text='Another button'))\r\n            navigationdrawer.add_widget(side_panel)\r\n\r\n            label_head = (\r\n                '[b]Example label filling main panel[/b]\\n\\n[color=ff0000](p'\r\n                'ull from left to right!)[/color]\\n\\nIn this example, the le'\r\n                'ft panel is a simple boxlayout menu, and this main panel is'\r\n                ' a BoxLayout with a label and example image.\\n\\nSeveral pre'\r\n                'set layouts are available (see buttons below), but users ma'\r\n                'y edit every parameter for much more customisation.')\r\n            main_panel = BoxLayout(orientation='vertical')\r\n            label_bl = BoxLayout(orientation='horizontal')\r\n            label = Label(text=label_head, font_size='15sp',\r\n                          markup=True, valign='top')\r\n            label_bl.add_widget(Widget(size_hint_x=None, width=dp(10)))\r\n            label_bl.add_widget(label)\r\n            label_bl.add_widget(Widget(size_hint_x=None, width=dp(10)))\r\n            main_panel.add_widget(Widget(size_hint_y=None, height=dp(10)))\r\n            main_panel.add_widget(label_bl)\r\n            main_panel.add_widget(Widget(size_hint_y=None, height=dp(10)))\r\n            main_panel.add_widget(Image(source='red_pixel.png', allow_stretch=True,\r\n                                        keep_ratio=False, size_hint_y=0.2))\r\n            navigationdrawer.add_widget(main_panel)\r\n            label.bind(size=label.setter('text_size'))\r\n\r\n            def set_anim_type(name):\r\n                navigationdrawer.anim_type = name\r\n            modes_layout = BoxLayout(orientation='horizontal')\r\n            modes_layout.add_widget(Label(text='preset\\nanims:'))\r\n            slide_an = Button(text='slide_\\nabove_\\nanim')\r\n            slide_an.bind(on_press=lambda j: set_anim_type('slide_above_anim'))\r\n            slide_sim = Button(text='slide_\\nabove_\\nsimple')\r\n            slide_sim.bind(on_press=lambda j: set_anim_type('slide_above_simple'))\r\n            fade_in_button = Button(text='fade_in')\r\n            fade_in_button.bind(on_press=lambda j: set_anim_type('fade_in'))\r\n            reveal_button = Button(text='reveal_\\nbelow_\\nanim')\r\n            reveal_button.bind(on_press=\r\n                               lambda j: set_anim_type('reveal_below_anim'))\r\n            slide_button = Button(text='reveal_\\nbelow_\\nsimple')\r\n            slide_button.bind(on_press=\r\n                              lambda j: set_anim_type('reveal_below_simple'))\r\n            modes_layout.add_widget(slide_an)\r\n            modes_layout.add_widget(slide_sim)\r\n            modes_layout.add_widget(fade_in_button)\r\n            modes_layout.add_widget(reveal_button)\r\n            modes_layout.add_widget(slide_button)\r\n            main_panel.add_widget(modes_layout)\r\n\r\n            button = Button(text='toggle NavigationDrawer state (animate)',\r\n                            size_hint_y=0.2)\r\n            button.bind(on_press=lambda j: navigationdrawer.toggle_state())\r\n            button2 = Button(text='toggle NavigationDrawer state (jump)',\r\n                             size_hint_y=0.2)\r\n            button2.bind(on_press=lambda j: navigationdrawer.toggle_state(False))\r\n            button3 = Button(text='toggle _main_above', size_hint_y=0.2)\r\n            button3.bind(on_press=navigationdrawer.toggle_main_above)\r\n            main_panel.add_widget(button)\r\n            main_panel.add_widget(button2)\r\n            main_panel.add_widget(button3)\r\n\r\n            return navigationdrawer\r\n\r\n        ExampleApp().run()\r\n\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Android Side Panel like widget.",
    "version": "1.0.2",
    "split_keywords": [
        "kivy",
        "kivy-garden"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8319dd8eeb7f462e60c2c5bcf29dac52b623b77bb72f8e81376bf86de77b38f6",
                "md5": "72dd7e2d2d029c4802db09257b581c18",
                "sha256": "59db8147a61fdfc3b2e6b75aecc7af901533433d91c4390966aace40461c7a15"
            },
            "downloads": -1,
            "filename": "kivy_garden.navigationdrawer-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "72dd7e2d2d029c4802db09257b581c18",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 13786,
            "upload_time": "2023-04-05T07:51:20",
            "upload_time_iso_8601": "2023-04-05T07:51:20.712780Z",
            "url": "https://files.pythonhosted.org/packages/83/19/dd8eeb7f462e60c2c5bcf29dac52b623b77bb72f8e81376bf86de77b38f6/kivy_garden.navigationdrawer-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c17cc9be159d682d1e2e13ff29e42695114b1ab6dbb9b10d9946d1440d42418b",
                "md5": "5a1bc6f8d511c72ee72aeab48c677bb8",
                "sha256": "925eb1f7d58a6edf43d20f281ecf3573401405077e390dc9e43ee770fd1cc761"
            },
            "downloads": -1,
            "filename": "kivy_garden.navigationdrawer-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "5a1bc6f8d511c72ee72aeab48c677bb8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13489,
            "upload_time": "2023-04-05T07:51:22",
            "upload_time_iso_8601": "2023-04-05T07:51:22.260436Z",
            "url": "https://files.pythonhosted.org/packages/c1/7c/c9be159d682d1e2e13ff29e42695114b1ab6dbb9b10d9946d1440d42418b/kivy_garden.navigationdrawer-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-05 07:51:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "Tungsteno74",
    "github_project": "navigationdrawer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "kivy-garden.navigationdrawer"
}
        
Elapsed time: 0.05043s