Paul McNary wrote:
> Hello
> 
> The database I am using has a filename for an image file in it.
> So I have a field in a biz object with the image file name in it.
> 
> How do I get that into the Picture property of the image control?
> 
> I can't seem to find the correct way to qualify the field name so that 
> it takes it from the biz object.

Since dImage isn't a data-aware control[1], you can't just fill in 
img.DataSource and img.DataField like you can with your text controls. 
What you can do is catch the form's RowNumChanged event, and then 
interact with the biz to fill in the Picture property. Pseudocode example:

"""
import os
import dabo
import dabo.dEvents as dEvents

class MyImageControl(dabo.ui.dImage):
   def afterInit(self):
     self.Form.bind(dEvents.RowNumChanged, self.onRowNumChanged)

   def onRowNumChanged(self, evt):
     self.refreshImage()

   def refreshImage(self):
     ## Define a getImagePath() method in your form to return the
     ## absolute path to the image files.
     imagePath = self.Form.getImagePath()
     imageFile = self.Form.PrimaryBizobj.Record.<image_field_name>
     self.Picture = os.path.join(imagePath, imageFile)
"""

An alternate (better?) way would be to override the image's update() 
method, as update() gets called when the form knows that the row number 
has changed (and other places, too):

"""
import os
import dabo

class MyImageControl(dabo.ui.dImage):
   def update(self):
     self.super()
     self.refreshImage()

   def refreshImage(self):
     ## Define a getImagePath() method in your form to return the
     ## absolute path to the image files.
     imagePath = self.Form.getImagePath()
     imageFile = self.Form.PrimaryBizobj.Record.<image_field_name>
     self.Picture = os.path.join(imagePath, imageFile)
"""

[1] It doesn't derive from dDataControlMixin, so it doesn't have 
DataSource and DataField properties. Perhaps dImage *should* be 
data-aware so it can get the image to display directly from the bizobj, 
but that wouldn't help your case because you have image file names in 
your database and you'd need some extra processing anyway to resolve 
that to the correct path.


Paul


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]

Reply via email to