Set Layout using Python

Set Layout using Python

Oli.Cooke
Enthusiast Enthusiast
1,208 Views
2 Replies
Message 1 of 3

Set Layout using Python

Oli.Cooke
Enthusiast
Enthusiast

Hello all!

 

Very basic question which is giving me a lot of frustration. 

Does anyone know a way to access the layout information for the app, as well as being able to set it.

 

An example, I want to change my layout from 'Editing' to 'Scripting', purely in code.

 

I'm still digging myself so if I find it I will post it up. MoBu gold to the lucky winner 😄

0 Likes
Accepted solutions (2)
1,209 Views
2 Replies
Replies (2)
Message 2 of 3

Mocappy
Advocate
Advocate
Accepted solution

Hello Oli,

 

Think you want FBMenuManger()...

 

Something like this should do what you've described below...

 

from pyfbsdk import FBMenuManager

menuManager = FBMenuManager()
menuName = "Layout"
menuItemName = "&Scripting" # MoBu menu items start with'&'
# menuItemName = "New_Layout" # Custom Menu item doesn't
keyboardShortCut = "\tCtrl+Shift+2" # Keyboard shortcuts are tabbed. If none, set to ""

menuItemFullPath = "{}/{}{}".format(menuName, menuItemName, keyboardShortCut)
print menuManager.ExecuteMenuItemFromFullPath( menuItemFullPath )

 

I've broken the code up to try and make it easier to see what's happening, but you could probably just type the full path in 😉

 

Hope this helps,

0 Likes
Message 3 of 3

Oli.Cooke
Enthusiast
Enthusiast
Accepted solution

Thanks Simon! I should have thought about FBManager, you saved the day!

Great code breakdown, very easy to read