Skip to content
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

ZMT zurich med tech

  1. Home
  2. Sim4Life
  3. Python API
  4. Creating a Custom Menu with Actions

Creating a Custom Menu with Actions

Scheduled Pinned Locked Moved Python API
1 Posts 1 Posters 264 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael
    wrote on last edited by
    #1

    I have been in the process of adding a custom menu with actions to the menubar in Sim4Life 4.2.1.3581.
    The problem now is, that the custom Menu does not seem to properly add the action.
    Not only does the action not appear in the menu, but the "Menu" property of the action is none-type.
    Strangely enough, the "Actions"-property of the menu itself does list the test-action.
    My code is this:

    import XCoreUI
    import XCore
    import testblock
    
    
    App = XCore.GetApp()
    ChildList = App.Frame.Children
    for i in range(len(ChildList)):
    	test = ChildList.__getitem__(i)
    	if test.Name == 'menu':
    		
    		break		
    Menubar = ChildList.__getitem__(i)
    Menu = XCoreUI.Menu('test')
    subMenu = XCoreUI.Menu('subMenu')
    
    Menu.AddMenu(subMenu)
    Menubar.AddMenu(Menu)
    TestAktion = XCoreUI.Action('Test')
    TestAktion.Label = "Test"
    TestAktion.Name = "Name"
    TestAktion.Enabled = True
    Verbindung = TestAktion.OnTriggered.Connect(testblock.main)
    
    Menu.AddAction(TestAktion)
    

    If anyone has any ideas, i would be gratefull.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Search