How do I load an image using pixmap, where the path of it's location has spaces ?
Thanks
How do I load an image using pixmap, where the path of it's location has spaces ?
Thanks
Hello, not sure what your code looks like but I imagine that you are trying to define the pixmap location in the form definition (setup form / exit) instead of defining the pixmap location in the form constructor method. Defining Pixmap File path with spaces does not work in the form definition.
To further illustrate what I am mentioning, here is an example from AVEVA TM-1881 PML Form Design manual where the pixmap location is defined in the form definition.
setup form !!traExampleParagraphs
!this.formTitle = |Paragraphs|
para .para1 text |Normal paragraph gadget| width 25
!t = |A coloured paragraph gadget|
para .para2 at x0 ymax.para1 backg 157 text |$!t| width 25
para .para3 at x0 ymax.para2 pixmap /c:\Temp\AVEVA_E3D_Graphic.png width 30 height 75
para .para4 at x0 ymax.para3 + 0.5 text || wid 25 hei 2
exit
define method .traExampleParagraphs()
-- Update the displayed text using CONSTRUCTOR method
!this.para4.val = |Above was a PIXMAP, while this is
split onto two lines|
endmethod
The pixmap location is defined in the line: para .para3 at x0 ymax.para2 pixmap /c:\Temp\AVEVA_E3D_Graphic.png width 30 height 75
Syntax in the form definition is somewhat very strict. File path with spaces will not work even if it is enclosed as a string. If we were to change the code above to a path with spaces, it will no longer work. para .para3 at x0 ymax.para2
pixmap '/c:\Temp\New folder\AVEVA_E3D_Graphic.png' width 30 height 75
To avoid the syntax restriction, we can define the pixmap location in the form constructor method.
setup form !!traExampleParagraphs
!this.formTitle = |Paragraphs|
para .para1 text |Normal paragraph gadget| width 25
!t = |A coloured paragraph gadget|
para .para2 at x0 ymax.para1 backg 157 text |$!t| width 25
-- para .para3 at x0 ymax.para2 pixmap /c:\Temp\AVEVA_E3D_Graphic.png width 30 height 75 Commented out
para .para3 at x0 ymax.para2 pixmap width 30 height 75
para .para4 at x0 ymax.para3 + 0.5 text || wid 25 hei 2
exit
define method .traExampleParagraphs()
-- Update the displayed text using CONSTRUCTOR method
!this.para4.val = |Above was a PIXMAP, while this is
split onto two lines|
!this.para3.addPixmap('/c:\Temp\New folder\AVEVA_E3D_Graphic.png')
endmethod
The .addpixmap() method allows spaces in the file path. This .addpixmap() method is also available in other gadgets.
!this.para3.addPixmap('/c:\Temp\New folder\AVEVA_E3D_Graphic.png')
In addition, based on what I have seen so far, the common practice of handling pixmaps is saving them together with your pmlfrm files in the PMLIB folder. With this you can use the !!pml.getPathName() method so you no longer have to specify the full path everytime.
!this.para3.addPixmap(!!pml.getpathname('AVEVA_E3D_Graphic.png'))
I should have said here that I managed to get it working. I had to use the "addpixmap" and "pixmap" exactly how you showed above.
What I tried orginally and didn't work for some reason
setup form !!traExampleParagraphs
para .para3 at x0 ymax.para2 pixmap /c:\Temp\AVEVA_E3D_Graphic.png width 30 height 75
exit
What did work :setup form !!traExampleParagraphs
para .para3 at x0 ymax.para2 pixmap width 30 height 75
exitdefine method .traExampleParagraphs()
!this.para3.addPixmap('/c:\Temp\New folder\AVEVA_E3D_Graphic.png')
endmethod
Thanks for your help !
You're welcome.