You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
first of all thanks for your work, it's really useful :).
I use contextmenu to create dynamic menus in my application. While it's working alright when building it in kv, the ContextMenu was displayed and in a bad position with a dynamically created menu.
After some debugging, I realised that I need to call context_menu._on_visible(False) just after ContextMenu parent is set to fix it.
below is a code that reproduce the problem/workaround:
fromkivy.appimportAppfromkivy.uix.boxlayoutimportBoxLayoutfromkivy.uix.labelimportLabelfromkivy.garden.contextmenuimportAppMenu, AppMenuTextItem, ContextMenu, ContextMenuTextItemclassMyApp(App):
defbuild(self):
self.title='Simple app menu example'main=BoxLayout(orientation='vertical')
app_menu=AppMenu(size_hint=(1, None), height=30)
fornamein ['test1', 'test2', 'test3']:
app_menu_text_item=AppMenuTextItem(text=name)
app_menu.add_widget(app_menu_text_item)
context_menu=ContextMenu()
foritemin ['menu1', 'menu2', 'menu3']:
wid=ContextMenuTextItem(text=item)
context_menu.add_widget(wid)
app_menu_text_item.add_widget(context_menu)
# if I don't put the next line, context_menu appear in the bottom# on first launch, then disappear when the app_menu is usedcontext_menu._on_visible(False)
main.add_widget(app_menu)
main.add_widget(Label(text='test'))
returnmainif__name__=='__main__':
MyApp().run()
This should be done somewhere in the code, when the parent is set for the first time.
Thanks
The text was updated successfully, but these errors were encountered:
I think I understand where the problem is. The visibility is in the examples set directly in .kv. This isn't necessary for app menus but for context menus it's required which isn't ideal.
I'll have a look at it.
Hello,
first of all thanks for your work, it's really useful :).
I use contextmenu to create dynamic menus in my application. While it's working alright when building it in kv, the ContextMenu was displayed and in a bad position with a dynamically created menu.
After some debugging, I realised that I need to call context_menu._on_visible(False) just after ContextMenu parent is set to fix it.
below is a code that reproduce the problem/workaround:
This should be done somewhere in the code, when the parent is set for the first time.
Thanks
The text was updated successfully, but these errors were encountered: