[wingide-users] Getting the User Settings Directory programatically

Wingware Support support at wingware.com
Fri Feb 22 13:33:03 EST 2013

Martin Fiers wrote:
> 1) In some cases, the user settings directory did not exist? After 
> clicking the snippets button in the IDE, it created the snippets 
> directory. That is very strange? Does that mean that when I copy my 
> snippets initially to the {USD}/snippets/py folder, they would be 
> overwritten when someone opens Wing for the first time?

No, the directory is only created and populated w/ the defaults if it 
does not already exist.

> 2) Is there a way to programatically get the user settings directory 
> from within Python? http://wingware.com/doc/install/user-settings-dir
> Apparently, even on Windows 7, it sometimes uses AppData, sometimes it 
> uses Application Data... We are all running Windows 7 here.
> In other words, what is the Wing get_user_settings_dir function. If I 
> could use that one, I'm all set ;)

You can get this in an extension script written for Wing's API.  For 

import wingapi

# This would get called every time the script is loaded or reloaded so 
would have to handle multiple calls
user_dir = wingapi.gApplication.GetUserSettingsDir()
# do something w/ user_dir

# Alternative method that defines a command setup-snippets-folder that 
the user can execute
def setup_snippets_folder():
   user_dir = wingapi.gApplication.GetUserSettingsDir()
   # do something w/ user_dir

If you drop that script into 'scripts' within the Wing IDE installation 
then it should be automatically loaded by Wing.  If Wing is already 
running, use Reload All Scripts in the Edit menu the first time.  Then 
if you open it in Wing and edit and save, it gets automatically reloaded 
with each save.

The scripting docs are here:



Stephan Deibel
Wingware | Python IDE
Advancing Software Development


More information about the wingide-users mailing list