From 2c0adab0112b78b838d443426b2e9b4e0fa6b7ff Mon Sep 17 00:00:00 2001 From: Qua-non Date: Mon, 22 Oct 2012 00:03:40 +0530 Subject: [PATCH] TabbedPanel: disable default tab functionality by default --- examples/widgets/tabbed_panel_showcase.py | 3 ++- examples/widgets/tabbedpanel.py | 1 - kivy/uix/tabbedpanel.py | 13 +++++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/examples/widgets/tabbed_panel_showcase.py b/examples/widgets/tabbed_panel_showcase.py index 81002948f..494a494bd 100644 --- a/examples/widgets/tabbed_panel_showcase.py +++ b/examples/widgets/tabbed_panel_showcase.py @@ -54,7 +54,8 @@ Builder.load_string(''' size_hint: (.45, .45) pos_hint: {'center_x': .25, 'y': .55} - #replace the default tab with our custom tab + #replace the default tab with our custom tab class + do_default_tab: True default_tab_cls: sh.__class__ default_tab_content: default_content tab_width: 40 diff --git a/examples/widgets/tabbedpanel.py b/examples/widgets/tabbedpanel.py index 832d8de4c..099d1536a 100644 --- a/examples/widgets/tabbedpanel.py +++ b/examples/widgets/tabbedpanel.py @@ -15,7 +15,6 @@ Builder.load_string(""" : size_hint: .5, .5 pos_hint: {'center_x': .5, 'center_y': .5} - do_default_tab: False TabbedPanelItem: text: 'first tab' diff --git a/kivy/uix/tabbedpanel.py b/kivy/uix/tabbedpanel.py index 497b08e74..5afd0bbdf 100644 --- a/kivy/uix/tabbedpanel.py +++ b/kivy/uix/tabbedpanel.py @@ -57,6 +57,10 @@ the tabs. Your app is responsible for adding the content of individual tabs, and for managing it, but not for doing the content switching. The tabbed panel handles switching of the main content object, per user action. +.. note:: + The default_tab functionality is turned off by default since 1.5.0 to + turn it back on set `do_default_tab` = True. + There is a default tab added when the tabbed panel is instantiated. Tabs that you add individually as above, are added in addition to the default tab. Thus, depending on your needs and design, you will want to customize the @@ -294,13 +298,13 @@ class TabbedPanel(GridLayout): default to 100. ''' - do_default_tab = BooleanProperty(True) + do_default_tab = BooleanProperty(False) '''Specifies weather a default_tab head is provided. .. versionadded:: 1.5.0 :data:`do_default_tab` is a :class:`~kivy.properties.BooleanProperty`, - defaults to 'True'. + defaults to 'False'. ''' default_tab_text = StringProperty('Default tab') @@ -441,6 +445,11 @@ class TabbedPanel(GridLayout): self._default_tab = None self.remove_widget(dft) self._switch_to_first_tab() + else: + self.default_tab = self.tab_list[-1] + Logger.info( + 'TabbedPanel: setting `{0}` as `default_tab`'.format( + self.default_tab.text)) def _switch_to_first_tab(self, *l): ltl = len(self.tab_list) - 1