{"action":"opened","issue":{"url":"https://api.github.com/repos/kivy/kivy/issues/3737","labels_url":"https://api.github.com/repos/kivy/kivy/issues/3737/labels{/name}","comments_url":"https://api.github.com/repos/kivy/kivy/issues/3737/comments","events_url":"https://api.github.com/repos/kivy/kivy/issues/3737/events","html_url":"https://github.com/kivy/kivy/issues/3737","id":114270739,"number":3737,"title":"'Cannot add kivy.uix.actionbar.ActionSeparator - it already has a parent'","user":{"login":"DavidA2014","id":7724321,"avatar_url":"https://avatars.githubusercontent.com/u/7724321?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidA2014","html_url":"https://github.com/DavidA2014","followers_url":"https://api.github.com/users/DavidA2014/followers","following_url":"https://api.github.com/users/DavidA2014/following{/other_user}","gists_url":"https://api.github.com/users/DavidA2014/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidA2014/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidA2014/subscriptions","organizations_url":"https://api.github.com/users/DavidA2014/orgs","repos_url":"https://api.github.com/users/DavidA2014/repos","events_url":"https://api.github.com/users/DavidA2014/events{/privacy}","received_events_url":"https://api.github.com/users/DavidA2014/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-30T13:34:50Z","updated_at":"2015-10-30T13:34:50Z","closed_at":null,"body":"Working with Kivy 1.9.1 on Windows 8.1, I get an exception with a certain widget tree when working with garden.matplotlib, which uses actionbar.  I'm told that this is a generic Kivy issue, not an issue with garden.matplotlib.\r\n\r\nHere are files that demo the problem. Sorry they are long but I did my best to cut them down.\r\n\r\n# main.py:\r\n```\r\n#!/usr/bin/python3\r\n\r\nimport sys\r\nfrom kivy.app import App\r\nfrom kivy.config import Config\r\n\r\nConfig.set('graphics', 'width', '800')\r\nConfig.set('graphics', 'height', '600')\r\n\r\nfrom mygraph import CMplGraph\r\n\r\nclass GuiApp(App):\r\n\r\n    def __init__(self, **kwargs):\r\n        super(GuiApp, self).__init__(**kwargs)\r\n\r\n\r\nif __name__ == '__main__':\r\n\r\n    GuiApp().run()\r\n```\r\n\r\n# mygraph.py\r\n```\r\nimport matplotlib\r\nmatplotlib.use('module://kivy.garden.matplotlib.backend_kivy')\r\nfrom matplotlib.figure import Figure\r\nfrom numpy import arange, sin, pi\r\nfrom kivy.app import App\r\nimport numpy as np\r\nfrom kivy.garden.matplotlib.backend_kivyagg import FigureCanvas,\\\r\n                                                NavigationToolbar2Kivy\r\nfrom matplotlib.transforms import Bbox\r\nimport matplotlib.pyplot as plt\r\nfrom kivy.uix.boxlayout import BoxLayout\r\n\r\nlistA=[(0xBE14, 0x3408), (0xC65E, 0x3ABE)]\r\n\r\nlistB = [( 13322,  -16873), ( 15038,  -14751)]\r\n\r\ndef press(event):\r\n    print('press released from test', event.x, event.y, event.button)\r\n\r\n\r\ndef release(event):\r\n    print('release released from test', event.x, event.y, event.button)\r\n\r\n\r\ndef keypress(event):\r\n    print('key down', event.key)\r\n\r\n\r\ndef keyup(event):\r\n    print('key up', event.key)\r\n\r\n\r\ndef motionnotify(event):\r\n    print('mouse move to ', event.x, event.y)\r\n\r\n\r\ndef resize(event):\r\n    print('resize from mpl ', event)\r\n\r\n\r\ndef scroll(event):\r\n    print('scroll event from mpl ', event.x, event.y, event.step)\r\n\r\n\r\ndef figure_enter(event):\r\n    print('figure enter mpl')\r\n\r\n\r\ndef figure_leave(event):\r\n    print('figure leaving mpl')\r\n\r\n\r\ndef close(event):\r\n    print('closing figure')\r\n\r\ndef autolabel(rects):\r\n    # attach some text labels\r\n    for rect in rects:\r\n        height = rect.get_height()\r\n        ax.text(rect.get_x() + rect.get_width() / 2., 1.05 * height,\r\n                '%d' % int(height), ha='center', va='bottom')\r\n\r\ndef callback(instance):\r\n    autolabel(rects1)\r\n    autolabel(rects2)\r\n    canvas.draw()\r\n\r\nclass CMplGraph(BoxLayout):\r\n    \"\"\"This class presents an example graphical plot using MatPlotLib\r\n    \"\"\"\r\n    pass\r\n\r\n    def __init__(self, **kwargs):\r\n        super(CMplGraph, self).__init__(**kwargs)\r\n        self.create_plot()\r\n\r\n    def create_plot(self):\r\n        N = 5\r\n        menMeans = (20, 35, 30, 35, 27)\r\n        menStd = (2, 3, 4, 1, 2)\r\n\r\n        ind = np.arange(N)  # the x locations for the groups\r\n        width = 0.35       # the width of the bars\r\n\r\n        fig, ax = plt.subplots()\r\n\r\n        for i in range(len(listA)):\r\n            x = listA[i][0]\r\n            y = listA[i][1]\r\n            if x > 32767:\r\n                x = x - pow(2,16)\r\n            if y > 32767:\r\n                y = y - pow(2,16)\r\n            x = x / pow(2,14)\r\n            listA[i] = (i,x)\r\n\r\n        xCoords = [ t[0] for t in listA ]\r\n        yCoords = [ t[1] for t in listA ]\r\n\r\n        lineA = ax.plot(xCoords, yCoords, color='blue', marker='o', markerfacecolor='blue', markersize=6)\r\n\r\n        for i in range(len(listB)):\r\n            x = listB[i][0]\r\n            y = listB[i][1]\r\n            if x > 32767:\r\n                x = x - pow(2,16)\r\n            if y > 32767:\r\n                y = y - pow(2,16)\r\n            x = x / pow(2,14)\r\n            listB[i] = (i,x)\r\n\r\n        xCoords = [ t[0] for t in listB ]\r\n        yCoords = [ t[1] for t in listB ]\r\n\r\n        lineB = ax.plot(xCoords, yCoords, color='red', marker='o', markerfacecolor='red', markersize=6)\r\n\r\n        ax.set_xlabel('RB')\r\n        ax.set_ylabel('Magnitude')\r\n        ax.set_title('Data')\r\n        ax.set_ylim([-2, 2])\r\n        ax.legend((lineA[0], lineB[0]), ('Real', 'Imag'))\r\n\r\n        fig.canvas.mpl_connect('button_press_event', press)\r\n        fig.canvas.mpl_connect('button_release_event', release)\r\n        fig.canvas.mpl_connect('key_press_event', keypress)\r\n        fig.canvas.mpl_connect('key_release_event', keyup)\r\n        fig.canvas.mpl_connect('motion_notify_event', motionnotify)\r\n        fig.canvas.mpl_connect('resize_event', resize)\r\n        fig.canvas.mpl_connect('scroll_event', scroll)\r\n        fig.canvas.mpl_connect('figure_enter_event', figure_enter)\r\n        fig.canvas.mpl_connect('figure_leave_event', figure_leave)\r\n        fig.canvas.mpl_connect('close_event', close)\r\n\r\n        canvas = fig.canvas\r\n\r\n        nav1 = NavigationToolbar2Kivy(canvas)\r\n\r\n        self.add_widget(nav1.actionbar)\r\n        self.add_widget(canvas)\r\n```\r\n\r\n# gui.kv\r\n```\r\n<CMplGraph>:\r\n    id: my_graph\r\n    orientation: 'vertical'\r\n\r\nTabbedPanel:\r\n    id: tab_panel\r\n    do_default_tab: False\r\n\r\n    TabbedPanelItem:\r\n        id: tab_graph\r\n        text: 'Graph'\r\n\r\n        BoxLayout:\r\n            id: CalBoxLayout\r\n            orientation: 'horizontal'\r\n\r\n            CMplGraph:\r\n```\r\n\r\n# The problem\r\n\r\nIf I run the code as is, all is fine:\r\n\r\npython main.py\r\n\r\nIf, in gui.kv, I replace the last line ( CMplGraph: ) with:\r\n\r\n```\r\n            BoxLayout:\r\n                id: CalButtons\r\n                orientation: 'vertical'\r\n                size_hint_x: .25\r\n\r\n                Button:\r\n                    text: '1'\r\n\r\n            BoxLayout:\r\n                id: MyGraph\r\n\r\n                CMplGraph:\r\n```\r\n\r\nI get an exception:\r\n\r\n```\r\nC:\\>python main.py\r\n Traceback (most recent call last):\r\n   File \"main.py\", line 20, in <module>\r\n     GuiApp().run()\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\app.py\", line 828, in run\r\n     runTouchApp()\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\base.py\", line 487, in runTouchApp\r\n     EventLoop.window.mainloop()\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\core\\window\\window_sdl2.py\", line 606, in mainloo\r\np\r\n     self._mainloop()\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\core\\window\\window_sdl2.py\", line 361, in _mainlo\r\nop\r\n     EventLoop.idle()\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\base.py\", line 336, in idle\r\n     Clock.tick_draw()\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\clock.py\", line 490, in tick_draw\r\n     self._process_events_before_frame()\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\clock.py\", line 640, in _process_events_before_fr\r\name\r\n     event.tick(self._last_tick, remove)\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\clock.py\", line 374, in tick\r\n     ret = callback(self._dt)\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\uix\\boxlayout.py\", line 175, in do_layout\r\n     c.width = w\r\n   File \"kivy\\properties.pyx\", line 408, in kivy.properties.Property.__set__ (kivy\\properties.c:4967)\r\n   File \"kivy\\properties.pyx\", line 446, in kivy.properties.Property.set (kivy\\properties.c:5665)\r\n   File \"kivy\\properties.pyx\", line 501, in kivy.properties.Property.dispatch (kivy\\properties.c:6314)\r\n   File \"kivy\\_event.pyx\", line 1223, in kivy._event.EventObservers.dispatch (kivy\\_event.c:12615)\r\n   File \"kivy\\_event.pyx\", line 1129, in kivy._event.EventObservers._dispatch (kivy\\_event.c:11914)\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\uix\\actionbar.py\", line 617, in on_width\r\n     self._layout_random()\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\uix\\actionbar.py\", line 567, in _layout_random\r\n     super_add(child, group_index)\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\uix\\boxlayout.py\", line 213, in add_widget\r\n     return super(BoxLayout, self).add_widget(widget, index)\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\uix\\layout.py\", line 87, in add_widget\r\n     return super(Layout, self).add_widget(widget, index)\r\n   File \"C:\\Kivy-1.9.0-py3.4-win32-x64\\Python34\\lib\\site-packages\\kivy\\uix\\widget.py\", line 509, in add_widget\r\n     % (widget, parent))\r\n kivy.uix.widget.WidgetException: Cannot add <kivy.uix.actionbar.ActionSeparator object at 0x00000000086EF9A8>, it alrea\r\ndy has a parent <kivy.uix.actionbar.ActionOverflow object at 0x00000000086A1708>\r\n```\r\n\r\n\r\n"}}