def remove_widget(self, widget): content = self.content if content is None: return if widget in (content, self._tab_layout): super(TabbedPanel, self).remove_widget(widget) elif isinstance(widget, TabbedPanelHeader): if not (self.do_default_tab and widget is self._default_tab): self_tabs = self._tab_strip self_tabs.width -= widget.width self_tabs.remove_widget(widget) if widget.state == 'down' and self.do_default_tab: self._default_tab.on_release() self._reposition_tabs() else: Logger.info('TabbedPanel: default tab! can\'t be removed.\n' + 'Change `default_tab` to a different tab.') else: self._childrens.pop(widget, None) <------Here if widget in content.children: content.remove_widget(widget)
For some reason when i try to use remove_widget on a ScreenManager this throws an error. I did some debugging and found this is going into the function: '((<WeakProxy to <__main__.HubTestsScreenManager object at 0x7fa07a623db8>>,), {})' as (self, widget) respectively. So does that mean when widget is used in the self._childrens.pop(widget, None) that no arg is being supplied. I don't think that is happening since it states 2 args are presented when it only accepts at most 1.
I am calling i this way: self.remove_widget(self.usb_manager) where usb_manager is a ObjectProperty from my kv
class MainPanel(TabbedPanel):
manager = ObjectProperty()
usb_manager = ObjectProperty()
hubtests_sm = ObjectProperty()
def __init__(self, *args, **kwargs):
super(MainPanel, self).__init__(*args, **kwargs)
def switch_sm(self):
self.manager = self.hubtests_sm
self.remove_widget(self.usb_manager)
self.add_widget(self.hubtests_sm)
main.kv
<MainPanel>:
id: mp
manager: usb_manager
usb_manager: usb_manager
size_hint: 1,1
tab_width: 65
do_default_tab: False
tab_pos: 'top_right'
TabbedPanelItem:
id: usb_tab
text: 'Usb'
BoxLayout:
orientation: 'vertical'
UsbScreenManager:
id: usb_manager
usb_screen_manager.kv
#:import label kivy.uix.label
#:import sla kivy.adapters.simplelistadapter
#:import hvd hub_validation_dict
#:import hvt hub_validation_test2
#:import cfg config
<UsbScreenManager>:
id: usb_manager
h2h: h2h
hvs: hvs
v9_icon: v9_icon
v9_test: v9_test
c5_icon: c5_icon
c5_test: c5_test
H2HScreen:
id:h2h
HubValidationScreen:
id:hvs
V9ValidationIconScreen
id: v9_icon
V9ValidationTestScreen:
id: v9_test
C5ValidationIconScreen:
id: c5_icon
C5ValidationTestScreen:
id: c5_test
<H2HScreen>:
id: h2h
name: 'h2h'
BoxLayout:
id:bl
orientation: 'vertical'
TestIcon:
id: h2hicon
source: 'h2h.png'
<HubValidationScreen>:
id: hvs
name: 'hvs'
BoxLayout:
id:bl
orientation: 'vertical'
TestIcon:
id: hubvicon
source: 'usb_button.png'
on_press: app.root.switch_sm()<----Attempt to switch screenmanager
File "/usr/lib/python2.7/dist-packages/kivy/lang.py", line 1465, in custom_callback
exec(__kvlang__.co_value, idmap)
File "usb_screen_manager.kv", line 53, in <module>
on_press: app.root.switch_sm()
File "sam1.py", line 211, in switch_sm
self.remove_widget(self.usb_manager)
File "/usr/lib/python2.7/dist-packages/kivy/uix/tabbedpanel.py", line 547, in remove_widget
self._childrens.pop(widget, None)
TypeError: pop() takes at most 1 argument (2 given)
Any help would be appreciated.
Thanks