Page 1 of 1

[FIXED] SpinNumCtrl.py - problem with the "min" attribute

Posted: Wed Jan 21, 2009 10:39 am
by Pako
Build 0.3.6.1487
==================

I found another bug in the file SpinNumCtrl.py
This is my code snippet:

Code: Select all

426        periodNumCtrl = eg.SpinNumCtrl(
427            panel,
428            -1,
429            period,
430            integerWidth = 5,
431            fractionWidth = 1,
432            allowNegative = False,
433            min = 0.1,
434            increment = 0.1,
435        )
If I open the configuration dialog, it will cause the following error message:

Code: Select all

10:55:13   Error while configuring: Demo: Demo action
10:55:13   Traceback (most recent call last):
10:55:13     File "d:\Programs\E\EventGhost\eg\Classes\MainFrame\TreeCtrl.py", line 307, in OnLeftDoubleClick
10:55:13       eg.UndoHandler.Configure().Try(self.document)
10:55:13     File "d:\Programs\E\EventGhost\eg\Classes\UndoHandler\Configure.py", line 32, in Try
10:55:13       eg.Greenlet(self.Do).switch(item)
10:55:13     File "d:\Programs\E\EventGhost\eg\Classes\UndoHandler\Configure.py", line 57, in Do
10:55:13       newArgs = gr.switch(*item.GetArgs())
10:55:13     File "D:\Programs\E\EventGhost\plugins\Demo\__init__.py", line 434, in Configure
10:55:13       increment = 0.1,
10:55:13     File "D:\Programs\E\EventGhost\eg\Classes\SpinNumCtrl.py", line 85, in __init__
10:55:13       numCtrl.SetParameters(**newArgs) # to avoid bug in NumCtrl
10:55:13     File "wx\lib\masked\numctrl.pyc", line 871, in SetParameters
10:55:13     File "wx\lib\masked\numctrl.pyc", line 1585, in _toGUI
10:55:13   ValueError: value 0 is below minimum value of control
I found one possible solution.
If this part of the code:

Code: Select all

67        if "min" in kwargs:
68            if kwargs["min"] < 0:
69                newArgs["allowNegative"] = True
70                
71        newArgs.update(kwargs)
72        wx.Window.__init__(self, parent, id, pos, size, 0)
73        self.SetThemeEnabled(True)
74        numCtrl = masked.NumCtrl(
75            self, 
76            -1, 
77            0, #value, 
78            pos, 
79            size, 
80            style,
81            validator, 
82            name, 
83            #**newArgs # to avoid bug in NumCtrl
84        )
85        numCtrl.SetParameters(**newArgs) # to avoid bug in NumCtrl
86        numCtrl.SetValue(value) # to avoid bug in NumCtrl
I change as follows,

Code: Select all

        if "min" in kwargs:
            if kwargs["min"] < 0:
                newArgs["allowNegative"] = True
            tmpMin = kwargs["min"]
            kwargs["min"] = None
        else:
            tmpMin = None
                
        newArgs.update(kwargs)
        wx.Window.__init__(self, parent, id, pos, size, 0)
        self.SetThemeEnabled(True)
        numCtrl = masked.NumCtrl(
            self, 
            -1, 
            0, #value, 
            pos, 
            size, 
            style,
            validator, 
            name, 
            #**newArgs # to avoid bug in NumCtrl
        )
        numCtrl.SetParameters(**newArgs) # to avoid bug in NumCtrl
        numCtrl.SetValue(value) # to avoid bug in NumCtrl
        numCtrl.SetMin(tmpMin)
the error does not occur and everything is working properly.
Pako

Re: SpinNumCtrl.py - problem with the "min" attribute

Posted: Fri Feb 20, 2009 8:00 pm
by Pako
Release 0.3.7.r851
Unfortunately, the problem occurs even in the new version.

Pako

Re: SpinNumCtrl.py - problem with the "min" attribute

Posted: Tue May 12, 2009 11:42 am
by Pako
Release 0.3.7.r973
Unfortunately, the problem persists in the new version too. I am some time ready to some improvement, but it can not be released, until this bug will not be removed.
Now I get the following tracebak:

Code: Select all

13:23:57   Traceback (most recent call last):
13:23:57     File "EventGhost.pyw", line 31, in <module>
13:23:57     File "D:\Programs\E\EventGhost\eg\__init__.py", line 71, in Main
13:23:57       eg.Tasklet(eg.app.MainLoop)().run()
13:23:57     File "D:\Programs\E\EventGhost\eg\Classes\TaskletDialog.py", line 41, in ProcessingTask
13:23:57       self.Configure(*args, **kwargs)
13:23:57     File "D:\Programs\E\EventGhost\eg\Classes\ConfigDialog.py", line 126, in Configure
13:23:57       self.item.Configure(*args)
13:23:57     File "D:\Programs\E\EventGhost\eg\Classes\ActionItem.py", line 107, in Configure
13:23:57       return self.executable.Configure(*args)
13:23:57     File "D:\Programs\E\EventGhost\plugins\FileOperations\__init__.py", line 735, in Configure
13:23:57       increment = 0.1,
13:23:57     File "D:\Programs\E\EventGhost\eg\Classes\SpinNumCtrl.py", line 91, in __init__
13:23:57       numCtrl.SetParameters(**kwargs) # To avoid bug in NumCtrl
13:23:57     File "wx\lib\masked\numctrl.pyc", line 871, in SetParameters
13:23:57     File "wx\lib\masked\numctrl.pyc", line 1600, in _toGUI
13:23:57   ValueError: value 0 is below minimum value of control
13:23:57   Traceback (most recent call last):
13:23:57     File "wx\_misc.pyc", line 1342, in Notify
13:23:57     File "wx\_core.pyc", line 14716, in Notify
13:23:57     File "D:\Programs\E\EventGhost\eg\Classes\UndoHandler\Configure.py", line 41, in Try
13:23:57       eg.Tasklet(self.Do)(item).run()
13:23:57   TaskletExit
Code snippet:

Code: Select all

726    periodNumCtrl = eg.SpinNumCtrl(
727        panel,
728        -1,
729        period,
730        integerWidth = 5,
731        fractionWidth = 1,
732        allowNegative = False,
733        min = 0.1,
734    #    min = -1,
735        increment = 0.1,
736    )
Thanks,
Pako

Re: SpinNumCtrl.py - problem with the "min" attribute

Posted: Tue May 12, 2009 2:07 pm
by Bitmonster
=> 0.3.7.r977

Re: SpinNumCtrl.py - problem with the "min" attribute

Posted: Tue May 12, 2009 2:22 pm
by Pako
Bitmonster wrote:=> 0.3.7.r977
Thanks, fixed !
Pako