View Full Version : Inserting an image into a UI
01 January 2004, 04:44 AM
Im using a UI builder to create a UI with a picture in the Background of my window. Here is the code:
//--created with uiDesigner_v0.1--//
formLayout myUIFormLayout ;
picture -image "C:\Documents and Settings\Administrator\My Documents\maya\4.5\prefs\icons\swUser2.bmp" -w 100 -h 32 "picture1" ;
-af "picture1" "left" 222
-af "picture1" "top" 124
And here is the error:
// Error: Image open failed: C:Documents and SettingsAdministratorMy Documentsmaya4.5prefsiconsswUser2.bmp //
The \ slashes are being lost somehow I guess.... Anyone know why this is happening, or better yet, how to fix it?
This error happens on both Maya 4.5 and Maya 5.
01 January 2004, 06:24 AM
hmmm, i've never used an image as a background for a UI before, BUT i've found that the image command is the best to use because it doesn't crash the script when it can't find the image you want to display.
on a bit of a tangent, i use the image command with popupMenu's attached, in place of an imageButton for that very reason.
the reason your command isn't working tho, is because you're using the wrong slashes. you have to use the / slash, even on windows.
the \ slash is the escape character, so if you REALLY want to use it, you have to double slash: \\
so you could use this:
the / slashes are easiest to read tho...
you can use the toNativePath and fromNativePath commands to help you change between the different path formats as well. :)
01 January 2004, 09:56 AM
I use pictures myself for some of my UI.
It appears that I dont need the full path for my picture when it is in the "C:\Documents and Settings\.......\prefs\icons" directory.
This way the script works on different computers even if they dont have the same path for maya pref path, I mean in case you are not logged as administrator.
01 January 2004, 10:22 PM
I think that the problem is that you use backslashes in your path, which is correct for Windows, but in a mel-script one is supposed to use the forward ones, so try this:
C:/Documents and Settings/Administrator/andsoon ...
I hope this helps
01 January 2004, 05:41 PM
It works perfectly now... Thanks for the help with the syntax!
01 January 2006, 08:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.