question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TabbedPanel.switch_to() does not appear to work

See original GitHub issue

Hi,

first of all I would like to congratulate on the great work that kivy is, keep it up!! I really hope that it will grow further and become the natural choise for python and gui’s.

Using the code below, when the code has run, “tab1” is not selected. I’m running windows portable installation Kivy-1.9.0-py3.4-win32-x64 and have w8.1 It works fine to select the tab manually. Maybe .switch_to is not meant to make the tab active, but at least I would assume that this is what it does. I also made some smaller attempts to see if I could make it selected/active with some of the other methods in TabbedPanel, but could not get it to work.

I decided to skip the “default_tab” (which by the way is preselected also on my computer), since I did not want different ways to assign the tabs.

Is this a bug, or can I get the tab selected another way (not using default tab)?

from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelHeader

class mainw(TabbedPanel):
    def __init__(self, **kwargs):
        super(mainw, self).__init__(**kwargs)

        self.do_default_tab = False
        self.tab_width = 150

        # create the tabs
        tab1 = TabbedPanelHeader(text='tab1')
        self.add_widget(tab1)

        tab2 = TabbedPanelHeader(text='tab2')
        self.add_widget(tab2)

        self.switch_to(tab1) # does not work and also does not throw error...


class tbpApp(App):
     def build(self):
        return mainw()

if __name__ == '__main__':
    tbpApp().run()

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
janssencommented, Jun 10, 2016

How would we know this by reading the documentation? And why close this? It’s still broken for some indeterminate time after you’ve initialized it, and there’s no way to tell when it’s “not broken”.

1reaction
dessantcommented, Jul 15, 2015

@ahed87 this is one way:

from functools import partial

from kivy.app import App
from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelHeader
from kivy.clock import Clock


class mainw(TabbedPanel):
    def __init__(self, **kwargs):
        super(mainw, self).__init__(**kwargs)

        self.do_default_tab = False
        self.tab_width = 150

        # create the tabs
        tab1 = TabbedPanelHeader(text='tab1')
        self.add_widget(tab1)

        tab2 = TabbedPanelHeader(text='tab2')
        self.add_widget(tab2)

        Clock.schedule_once(partial(self.switch, tab1), 0)

    def switch(self, tab, *args):
        self.switch_to(tab)

class tbpApp(App):
     def build(self):
        return mainw()

if __name__ == '__main__':
    tbpApp().run()

If you have further questions, visit our support channels: https://github.com/kivy/kivy#support.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kivy TabbedPanel switch_to work inconsistently
I am writing a code which starts the frontend, runs the backend and then loads the frontend. The frontend consists of TabbedPanel, and...
Read more >
Working with windows and tabs - WebDriver - Selenium
Creates a new window (or) tab and will focus the new window or tab on screen. You don't need to switch to work...
Read more >
TabbedPanel — Kivy 2.1.0 documentation
Your app is responsible for adding the content of individual tabs and for managing them, but it's not responsible for content switching. The...
Read more >
Switching back to last *used* tab on Chrome - Super User
Chrome has no native keyboard shortcut for this, but there's an extension you can use: Recent Tabs (Chrome Web Store). Features.
Read more >
Clicking Icon on Taskbar Does Not Switch to Program
This behavior can occur if the Always On Top check box is not selected in the Taskbar Properties dialog box. ... Press ALT+TAB...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found