Quantcast

FloatCtrl?

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

FloatCtrl?

Qiangning Hong
Is there a FloatCtrl which can be used to input float numbers as
wx.lib.intctrl.IntCtrl for integer?

--
Qiangning Hong

 ___________________________________________________
( You are the only person to ever get this message. )
 ---------------------------------------------------
        o  ^___^
         o (===)\_______
           (___)\       )\/\
                ||----w |
                ||     ||


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FloatCtrl?

Jens Petersen-5
Hi,

I think you'r searching something like

wx.lib.masked.numctrl.NumCrtl()

!


--
Jens Petersen


Geschenkt: 3 Monate GMX ProMail gratis + 3 Ausgaben stern gratis
++ Jetzt anmelden & testen ++ http://www.gmx.net/de/go/promail ++


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FloatCtrl?

Qiangning Hong
Jens Petersen wrote:
> Hi,
>
> I think you'r searching something like
>
> wx.lib.masked.numctrl.NumCrtl()
>

I played around for a while with the NumCtrl demo, It seems that I must
specify the fraction width to allow input float numbers.  Can it be
configured to allow input both "3.1" and "3.1415926" without the
annoying trailing zeros like "3.10000000"?

--
Qiangning Hong

 ____________________________________________________________
/ "Our nation must come together to unite."                  \
|                                                            |
\ George W. Bush June 4, 2001 Remark made in Tampa, Florida. /
 ------------------------------------------------------------
        \  ^___^
         \ (xxx)\_______
           (___)\       )\/\
            U   ||----w |
                ||     ||


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FloatCtrl?

Nikos Papagrigoriou-3
Hi,

I have programmed an Integer and Float Validator a long time ago (year
2001), adopting some ideas from PMW (python mega widgets). I created a
small statistical tool (only in greek -
http://www.food.teithe.gr/Members/papagr/multicomp/). It was one of my
first programs.

I hope you find the attached code usefull. Just execute the code to
see a small demo.

Nikos.

On 6/21/05, Qiangning Hong <[hidden email]> wrote:

> Jens Petersen wrote:
> > Hi,
> >
> > I think you'r searching something like
> >
> > wx.lib.masked.numctrl.NumCrtl()
> >
>
> I played around for a while with the NumCtrl demo, It seems that I must
> specify the fraction width to allow input float numbers.  Can it be
> configured to allow input both "3.1" and "3.1415926" without the
> annoying trailing zeros like "3.10000000"?
>
> --
> Qiangning Hong
>
>  ____________________________________________________________
> / "Our nation must come together to unite."                  \
> |                                                            |
> \ George W. Bush June 4, 2001 Remark made in Tampa, Florida. /
>  ------------------------------------------------------------
>         \  ^___^
>          \ (xxx)\_______
>            (___)\       )\/\
>             U   ||----w |
>                 ||     ||
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

--
Nikos Papagrigoriou <[hidden email]>
http://www.papagrigoriou.gr

validators.py (21K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: FloatCtrl?

Will Sadkin-2
In reply to this post by Qiangning Hong
Qiangning Hong wrote:

> Jens Petersen wrote:
>> Hi,
>>
>> I think you'r searching something like
>>
>> wx.lib.masked.numctrl.NumCrtl()
>>
>
> I played around for a while with the NumCtrl demo, It seems that I
> must specify the fraction width to allow input float numbers.  Can it
> be configured to allow input both "3.1" and "3.1415926" without the
> annoying trailing zeros like "3.10000000"?
 
All the masked controls are designed to have fixed width, and the
numeric formats are currently designed to fill in the fractional
part with zeros.  This is because there needs to be enough room in
the control to hold as many significant digits as allowed, with the
decimal point located at a fixed point in the control.  I did not want
the the decimal point to be "floating in the middle" of the control,
so I chose to right-pad the fractional part with zeros; this also
simplified problems of justification and conversion.  So I'm afraid
you can't get rid of the "annoying trailing zeros" with the NumCtrl.

(I wrote both the IntCtrl and the NumCtrl, both entirely in Python.  
I wrote IntCtrl first, and then made NumCtrl, which is a more complicated,
but more sophisticated control, given it does grouping, multiple
numeric formats, right-insert, etc.  However, you could always look
at IntCtrl and use it as a model for a simpler float control that
is more to your liking!)

Regrets,
/Will Sadkin
Author, lib.masked, IntCtrl
Parlance Corporation
www.parlancecorp.com


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FloatCtrl?

Qiangning Hong
In reply to this post by Nikos Papagrigoriou-3
The attached code is exactly what I am looking for!
Thank you very much!

Nikos Papagrigoriou wrote:

> Hi,
>
> I have programmed an Integer and Float Validator a long time ago (year
> 2001), adopting some ideas from PMW (python mega widgets). I created a
> small statistical tool (only in greek -
> http://www.food.teithe.gr/Members/papagr/multicomp/). It was one of my
> first programs.
>
> I hope you find the attached code usefull. Just execute the code to
> see a small demo.
>
> Nikos.
>
> On 6/21/05, Qiangning Hong <[hidden email]> wrote:
>
>>Jens Petersen wrote:
>>
>>>Hi,
>>>
>>>I think you'r searching something like
>>>
>>>wx.lib.masked.numctrl.NumCrtl()
>>>
>>
>>I played around for a while with the NumCtrl demo, It seems that I must
>>specify the fraction width to allow input float numbers.  Can it be
>>configured to allow input both "3.1" and "3.1415926" without the
>>annoying trailing zeros like "3.10000000"?
>>
>>--
>>Qiangning Hong
>>
>> ____________________________________________________________
>>/ "Our nation must come together to unite."                  \
>>|                                                            |
>>\ George W. Bush June 4, 2001 Remark made in Tampa, Florida. /
>> ------------------------------------------------------------
>>        \  ^___^
>>         \ (xxx)\_______
>>           (___)\       )\/\
>>            U   ||----w |
>>                ||     ||
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [hidden email]
>>For additional commands, e-mail: [hidden email]
>>
>>
>
>
>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]


--
Qiangning Hong

 _________________________________________________________
/ Heuristics are bug ridden by definition. If they didn't \
\ have bugs, then they'd be algorithms.                   /
 ---------------------------------------------------------
  \
   \ ,   _ ___.--'''`--''//-,-_--_.
      \`"' ` || \\ \ \\/ / // / ,-\\`,_
     /'`  \ \ || Y  | \|/ / // / - |__ `-,
    /@"\  ` \ `\ |  | ||/ // | \/  \  `-._`-,_.,
   /  _.-. `.-\,___/\ _/|_/_\_\/|_/ |     `-._._)
   `-'``/  /  |  // \__/\__  /  \__/ \
        `-'  /-\/  | -|   \__ \   |-' |
          __/\ / _/ \/ __,-'   ) ,' _|'
         (((__/(((_.' ((___..-'((__,'


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FloatCtrl?

MURADI OZSOYLER
In reply to this post by Will Sadkin-2
Hi Will,

As I mentioned on the list several weeks ago, NumCtrl  uses '.' key to
jump to decimal part even if the decimalChar is ','. It separates the
decimal part with ',' though, which is correct.

Is there a patch/workaround for this?

Thanks in advance,

Murat

Will Sadkin wrote:

>Qiangning Hong wrote:
>  
>
>>Jens Petersen wrote:
>>    
>>
>>>Hi,
>>>
>>>I think you'r searching something like
>>>
>>>wx.lib.masked.numctrl.NumCrtl()
>>>
>>>      
>>>
>>I played around for a while with the NumCtrl demo, It seems that I
>>must specify the fraction width to allow input float numbers.  Can it
>>be configured to allow input both "3.1" and "3.1415926" without the
>>annoying trailing zeros like "3.10000000"?
>>    
>>
>
>All the masked controls are designed to have fixed width, and the
>numeric formats are currently designed to fill in the fractional
>part with zeros.  This is because there needs to be enough room in
>the control to hold as many significant digits as allowed, with the
>decimal point located at a fixed point in the control.  I did not want
>the the decimal point to be "floating in the middle" of the control,
>so I chose to right-pad the fractional part with zeros; this also
>simplified problems of justification and conversion.  So I'm afraid
>you can't get rid of the "annoying trailing zeros" with the NumCtrl.
>
>(I wrote both the IntCtrl and the NumCtrl, both entirely in Python.  
>I wrote IntCtrl first, and then made NumCtrl, which is a more complicated,
>but more sophisticated control, given it does grouping, multiple
>numeric formats, right-insert, etc.  However, you could always look
>at IntCtrl and use it as a model for a simpler float control that
>is more to your liking!)
>
>Regrets,
>/Will Sadkin
>Author, lib.masked, IntCtrl
>Parlance Corporation
>www.parlancecorp.com
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]
>
>
>
>  
>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: FloatCtrl?

Will Sadkin-2
In reply to this post by Qiangning Hong
MURADI OZSOYLER wrote:

> Hi Will,
>
> As I mentioned on the list several weeks ago, NumCtrl  uses '.' key to
> jump to decimal part even if the decimalChar is ','. It separates the
> decimal part with ',' though, which is correct.
>
> Is there a patch/workaround for this?
>
> Thanks in advance,
>
> Murat
>

Oops; Sorry, I must have missed your posting...  

This has been broken for a while, and is is due to an overeager attempt
on my part to make the code efficient.  I will submit the patch to Robin
directly, but for now, the fix is:

diff -u -1 -0 -r1.16 maskededit.py
--- maskededit.py 2005/04/08 21:31:25 1.16
+++ maskededit.py 2005/06/21 19:42:47
@@ -2667,28 +2667,29 @@
             # Replace up/down arrow default handling:
             # make down act like tab, up act like shift-tab:
 
 ####            dbg('Registering numeric navigation and control handlers
(if not already set)')
             if not self._keyhandlers.has_key(wx.WXK_DOWN):
                 self._SetKeycodeHandler(wx.WXK_DOWN, self._OnChangeField)
             if not self._keyhandlers.has_key(wx.WXK_UP):
                 self._SetKeycodeHandler(wx.WXK_UP, self._OnUpNumeric)  #
(adds "shift" to up arrow, and calls _OnChangeField)
 
             # On ., truncate contents right of cursor to decimal point (if
any)
-            # leaves cusor after decimal point if floating point, otherwise
at 0.
-            if not self._keyhandlers.has_key(ord(self._decimalChar)):
+            # leaves cursor after decimal point if floating point,
otherwise at 0.
+            if not self._keyhandlers.has_key(ord(self._decimalChar)) or
self._keyhandlers[ord(self._decimalChar)] != self._OnDecimalPoint:
                 self._SetKeyHandler(self._decimalChar,
self._OnDecimalPoint)
-            if not self._keyhandlers.has_key(ord(self._shiftDecimalChar)):
+    
+            if not self._keyhandlers.has_key(ord(self._shiftDecimalChar))
or self._keyhandlers[ord(self._shiftDecimalChar)] != self._OnChangeField:
                 self._SetKeyHandler(self._shiftDecimalChar,
self._OnChangeField)   # (Shift-'.' == '>' on US keyboards)
 
             # Allow selective insert of groupchar in numbers:
-            if not
self._keyhandlers.has_key(ord(self._fields[0]._groupChar)):
+            if not
self._keyhandlers.has_key(ord(self._fields[0]._groupChar)) or
self._keyhandlers[ord(self._fields[0]._groupChar)] != self._OnGroupChar:
                 self._SetKeyHandler(self._fields[0]._groupChar,
self._OnGroupChar)
 
 ##        dbg(indent=0, suspend=0)
 
 
     def _SetInitialValue(self, value=""):
         """
         fills the control with the generated or supplied default value.
         It will also set/reset the font if necessary and apply
         formatting to the control at this time.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: FloatCtrl?

MURADI OZSOYLER
Hi Will,

After applying the patch it works just as expected. Thank you.

Regards,

Murat Özsöyler

Will Sadkin wrote:

>MURADI OZSOYLER wrote:
>  
>
>>Hi Will,
>>
>>As I mentioned on the list several weeks ago, NumCtrl  uses '.' key to
>>jump to decimal part even if the decimalChar is ','. It separates the
>>decimal part with ',' though, which is correct.
>>
>>Is there a patch/workaround for this?
>>
>>Thanks in advance,
>>
>>Murat
>>
>>    
>>
>
>Oops; Sorry, I must have missed your posting...  
>
>This has been broken for a while, and is is due to an overeager attempt
>on my part to make the code efficient.  I will submit the patch to Robin
>directly, but for now, the fix is:
>
>diff -u -1 -0 -r1.16 maskededit.py
>--- maskededit.py 2005/04/08 21:31:25 1.16
>+++ maskededit.py 2005/06/21 19:42:47
>@@ -2667,28 +2667,29 @@
>             # Replace up/down arrow default handling:
>             # make down act like tab, up act like shift-tab:
>
> ####            dbg('Registering numeric navigation and control handlers
>(if not already set)')
>             if not self._keyhandlers.has_key(wx.WXK_DOWN):
>                 self._SetKeycodeHandler(wx.WXK_DOWN, self._OnChangeField)
>             if not self._keyhandlers.has_key(wx.WXK_UP):
>                 self._SetKeycodeHandler(wx.WXK_UP, self._OnUpNumeric)  #
>(adds "shift" to up arrow, and calls _OnChangeField)
>
>             # On ., truncate contents right of cursor to decimal point (if
>any)
>-            # leaves cusor after decimal point if floating point, otherwise
>at 0.
>-            if not self._keyhandlers.has_key(ord(self._decimalChar)):
>+            # leaves cursor after decimal point if floating point,
>otherwise at 0.
>+            if not self._keyhandlers.has_key(ord(self._decimalChar)) or
>self._keyhandlers[ord(self._decimalChar)] != self._OnDecimalPoint:
>                 self._SetKeyHandler(self._decimalChar,
>self._OnDecimalPoint)
>-            if not self._keyhandlers.has_key(ord(self._shiftDecimalChar)):
>+    
>+            if not self._keyhandlers.has_key(ord(self._shiftDecimalChar))
>or self._keyhandlers[ord(self._shiftDecimalChar)] != self._OnChangeField:
>                 self._SetKeyHandler(self._shiftDecimalChar,
>self._OnChangeField)   # (Shift-'.' == '>' on US keyboards)
>
>             # Allow selective insert of groupchar in numbers:
>-            if not
>self._keyhandlers.has_key(ord(self._fields[0]._groupChar)):
>+            if not
>self._keyhandlers.has_key(ord(self._fields[0]._groupChar)) or
>self._keyhandlers[ord(self._fields[0]._groupChar)] != self._OnGroupChar:
>                 self._SetKeyHandler(self._fields[0]._groupChar,
>self._OnGroupChar)
>
> ##        dbg(indent=0, suspend=0)
>
>
>     def _SetInitialValue(self, value=""):
>         """
>         fills the control with the generated or supplied default value.
>         It will also set/reset the font if necessary and apply
>         formatting to the control at this time.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]
>
>
>
>  
>



Loading...