I am kinda new to wxPython (but not to python), so please bear with me.
I have inherited the maintenance for a wxPython app that was written
in 2004 (so I'm sure it's not using anything close to the latest and
greatest). There's a field that is displaying values rounded to 5
decimal places, and I've been asked to make it display 7 - seems
simple enough, but I can't seem to find how this is working. Here is a
snippet of what the code does;
from wxgui.widgets import pcwx
from wxgui.widgets.TableSizer import TableSizer
LF = pcwx.LabelledField
self.price = LF(panel, "Fill Price ( )")
sizer = TableSizer(4, 12)
add = sizer.add
add(self.price.label, 2, 6, sticky="e")
add(self.price.field, 3, 6)
Then later on it does:
self.price.field.SetValue(str(self._fill.fillPrice))
From the debugger I can see that the value is 120.9765625 and that's
what gets put in the field:
(Pdb) print self._fill.fillPrice
120.9765625
(Pdb) print self.price.field.GetValue()
120.9765625
On the screen 120.97656 is shown, but if I select that field it
changes to 120.9765625. Not sure why it changes when I select it, but
how can I get it to display the fill precision without me having to
select it?
TIA!
-larry
Larry Martell wrote:
...There's a field that is displaying values rounded to 5
decimal places, and I've been asked to make it display 7 - seems
simple enough, but I can't seem to find how this is working. Here is a
snippet of what the code does;
from wxgui.widgets import pcwx
from wxgui.widgets.TableSizer import TableSizer
LF = pcwx.LabelledField
wxgui is not part of wxPython. Do you know where it came from?
Then later on it does:
self.price.field.SetValue(str(self._fill.fillPrice))
Please remember that the field value here is a string, not a float.
There cannot possibly be any rounding going on.
From the debugger I can see that the value is 120.9765625 and that's
what gets put in the field:
(Pdb) print self._fill.fillPrice
120.9765625
That's a float.
(Pdb) print self.price.field.GetValue()
120.9765625
That's a string.
On the screen 120.97656 is shown, but if I select that field it
changes to 120.9765625. Not sure why it changes when I select it, but
how can I get it to display the fill precision without me having to
select it?
Is the field large enough? Maybe there's only room for 9 characters and
the rest are being truncated. That's the only explanation I can come up
with.
···
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
Larry Martell wrote:
...There's a field that is displaying values rounded to 5
decimal places, and I've been asked to make it display 7 - seems
simple enough, but I can't seem to find how this is working. Here is a
snippet of what the code does;
from wxgui.widgets import pcwx
from wxgui.widgets.TableSizer import TableSizer
LF = pcwx.LabelledField
wxgui is not part of wxPython.
No wonder I couldn't find anything on it when I googled.
Do you know where it came from?
Turns out it's a local package.
Then later on it does:
self.price.field.SetValue(str(self._fill.fillPrice))
Please remember that the field value here is a string, not a float.
There cannot possibly be any rounding going on.
From the debugger I can see that the value is 120.9765625 and that's
what gets put in the field:
(Pdb) print self._fill.fillPrice
120.9765625
That's a float.
(Pdb) print self.price.field.GetValue()
120.9765625
That's a string.
On the screen 120.97656 is shown, but if I select that field it
changes to 120.9765625. Not sure why it changes when I select it, but
how can I get it to display the fill precision without me having to
select it?
Is the field large enough? Maybe there's only room for 9 characters and
the rest are being truncated. That's the only explanation I can come up
with.
Yeah, the field is plenty large enough. It's doing some padding and
all the digits are there, but off to the right of the displayable
size. It's rounding on the display, but when I click on it I get the
entire string. Still not sure what's going on, but at least I know
it's not wxPython.
Thanks much!
-larry
···
On Thu, Jun 27, 2013 at 2:37 PM, Tim Roberts <timr@probo.com> wrote: