Not quire sure what kind of information you are storing as your selection. If it is Maya nodes then I would rely on its tools to get what you're after. For example you could create a selection set or an array attribute prior to processing your scenes that each UI can then reference.
If you're using Qt you could use QSettings to store your data. You could also write out a temp file to disk and read it back in yourself if you want more control. Note, I strongly discourage the use of this last technique unless you are well aware of what you are doing. There's almost always a better way of achieving similar results (see above), however, I have run into a few cases where I could not solve a particular problem any other way. You can import the __builtin__ module and store your data there: *import __builtin__* *__builtin__.myVar = "test" **print myVar* *# test* It will then be available to every module in the same python session. Since builtin is at the bottom of the list when it comes to attribute look-up local module variables will take precedent. Cheers! On Tue, Oct 23, 2012 at 1:05 AM, Mike Malinowski (LIONHEAD) < [email protected]> wrote: > Create a module and expose variables within that module. Because Maya's > python session is continuos any on-the-fly changes to those variables will > remain throughout the maya session…. An example…. > > MyConfig.py: > # Expose a variable > some_variable = True > # End of config.py > > Import that config module into the python interpreter in maya and run > the following… > import MyConfig > MyConfig.some_variable = False > > > Ok, now run this… > import MyConfig > Print MyConfig.some_variable > > You'll notice that it prints False ( at least until you force it to > reload ) even though we hit run two times. We do this for some of our tools > here, and then wrap insert save and initialisation code to store the data > between separate maya sessions. > > Another option is to use Maya's optionVar dictionary and store your data > in there, but that is less flexible with complex data types > > Mike > > > From: Panupat Chongstitwattana <[email protected]> > Reply-To: "[email protected]" < > [email protected]> > Date: Tuesday, 23 October 2012 06:08 > To: "[email protected]" < > [email protected]> > Subject: [Maya-Python] global variable accessible for all modules? > > Hi. > > I have a couple Python UI for opening/saving scenes in our pipeline. Most > of them share some common selection list. > > client > project > episode > a few more hierarchy > > I'm wondering if there's a way to store those information globally, so > when I launch other UI they can pick up the value? I want to set the > selection automatically to match the user's current working scene. > Currently the users have to select everything from the ground up again. > > Thanks. > > -- > view archives: http://groups.google.com/group/python_inside_maya > change your subscription settings: > http://groups.google.com/group/python_inside_maya/subscribe > > -- > view archives: http://groups.google.com/group/python_inside_maya > change your subscription settings: > http://groups.google.com/group/python_inside_maya/subscribe > -- Technical Director @ DreamWorks Animation -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe
