johnf wrote:
> On Tuesday 04 November 2008 11:38:25 am Paul McNett wrote:
>> johnf wrote:
>>> It took a long time to figure out find the root cause.  Even now I'm
>>> unsure that we are going about this correctly.  But this function is
>>> required - somehow we need to be able to change the screen view from
>>> pounds to kilos.
>> In my app the user can choose millimeters or inches for unit_of_measure.
>> They make the choice from a dropdown list, and immediately all length/width
>> fields recalculate and update. I don't recall this being difficult, so if
>> you are still struggling getting this updating to happen, perhaps you
>> should post some code to show us what you've tried?
>>
>> The biggest issue for me is the rounding errors that occur when converting
>> from 1-31/32 to millimeters, when they only want millimeters to the tenth
>> place. Converting back to inches can make it round to 2 or 1-15/16. But I
>> don't have any screen update issues like you seem to be struggling with.
>>
>> Paul
> 
> The math is not even an issue.  That is always right.  It's the display that 
> is causing us grief.  Could you post your code that changes the screen.  Our 
> code is this long winded thing.  I should tell you that our code actually 
> does three things. 
> 
> 1. displays pounds and oz in two text boxes one for pounds and one for oz
> 2. displays kilos if greater than 1000g
> 3. displays grams if not a kilo.
> 
> Maybe not the code but the approach?

Here's the relevant code:
{{{
      62 class DrpUOM(dabo.ui.dDropdownList):
      63   def initProperties(self):
      64     self.ValueMode = "Key"
      65     self.Choices = ['Inches', 'Millimeters']
      66     self.Keys = {"inches":0, "millimeters":1}
      67
      68   def onHit(self, evt):
      69     biz = self.Form.Bizobj
      70     uom_opening = biz.Record.unit_of_measure
      71     if self.Value == uom_opening:
      72       return
      73
      74     def okay(first, second):
      75       return dabo.ui.areYouSure("You need to review the opening 
carefully 
after converting the unit "
      76           "of measure. Are you sure you want to convert this opening 
from %s 
to %s at this time?"
      77           % (first, second), cancelButton=False)
      78
      79     if self.Value == "inches" and uom_opening == "millimeters":
      80       convert_from, convert_to = "millimeters", "inches"
      81     elif self.Value == "millimeters" and uom_opening in ("inches", ""):
      82       convert_from, convert_to = "inches", "millimeters"
      83
      84     if okay(convert_from, convert_to):
      85       biz.convert_uom(convert_to)
      86       self.Form.update_sizes()
      87       self.Form.setUnitOfMeasure()

     477   def update_sizes(self):
     478     biz = self.Bizobj
     479     if not getattr(self, "txtWidth", None) or not biz or biz.RowCount 
< 1:
     480       return
     481
     482     self.txtWidth.update()
     483     self.txtHeight.update()
     484
     485     biz.updateNetSize()
     486     self.update_calculator()

Paul


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

Reply via email to