[Emc-users] Regression in pyvcp's radiobutton from 2.5 to 2.6.5, nothing selected in the hal layer on startup

2015-01-18 Thread Maximilian Heise
Hello,

I tried to change versions from 2.5 master to 2.6.5 on an linuxcnc
installation and noticed a regression. The radiobutton does not select its
iniital value on startup. I have not yet looked into the other pyvcp
widgets to check if the same problem exists with them too.

I am using a pvcp based side panel. Please have a look at this small pyvcp
example which I ripped out of my larger real world side panel to reproduce
the regression:


  

  "Material Thickness Selection"
  RIDGE
  3
  

  
["1mm", "2mm", "3mm"]
"choice"
2
  

  

  


With 2.6.5:
$ halrun
halcmd: loadusr pyvcp -c radio_button_test radio_button_test.xml
halcmd: show pin
Component Pins:
Owner   Type  Dir Value  Name
 5  bit   OUT FALSE  radio_button_test.choice.1mm
 5  bit   OUT FALSE  radio_button_test.choice.2mm
 5  bit   OUT FALSE  radio_button_test.choice.3mm

No pin is selected on startup at all, even though I specified an initval of
2, i.e. I expected that the 3mm material should have been selected. I
believe this is an error.

With 2.5:
$ halrun
halcmd: loadusr pyvcp -c radio_button_test radio_button_test.xml
halcmd: show pin
Component Pins:
Owner   Type  Dir Value  Name
 5  bit   OUT FALSE  radio_button_test.choice.1mm
 5  bit   OUT FALSE  radio_button_test.choice.2mm
 5  bit   OUT  TRUE  radio_button_test.choice.3mm

Here the initval's choice in the radiobutton is selected as I expected on
startup.

Or am I missing something here on the upgrade from 2.5 to 2.6 ?

BR
Max.
--
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Regression in pyvcp's radiobutton from 2.5 to 2.6.5, nothing selected in the hal layer on startup

2015-01-19 Thread schoone...@btinternet.com
Hi

I have tested your code on 2.6.3, 2.7 and 2.8
All of them produce a pyVCP panel with button 3 selected

But no, the respective pin is not selected, I think I may know why.

When I made a lot of alterations a while back to pyVCP, I changed the 
update code, so that it did not keep cycling through updates every call 
unless there was a change.
This will have suppressed the first update.

I expect no-one has noticed until now, because the initval will 
generally reflect the default setting rather than actually set it.
Thereafter all clicks upon radio buttons will work as anticipated

I have written a fix,  which seems to work OK.
Will do a bit more testing and submit a patch to correct this

regards

--
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Regression in pyvcp's radiobutton from 2.5 to 2.6.5, nothing selected in the hal layer on startup

2015-01-19 Thread schoone...@btinternet.com
Further to below

If you want an immediate fix

/usr/share/pyshared/pyvcp_widgets.py
line 617
below
self.selected = initval

insert
pycomp[self.halpins[initval]]=1

at same indentation

That will force an update of the initval selected pin or defaults
setting pin 0 if initval is not set, which is the default radio button
setting at initialisation

regards



 >Hi

 >I have tested your code on 2.6.3, 2.7 and 2.8
 >All of them produce a pyVCP panel with button 3 selected

 >But no, the respective pin is not selected, I think I may know why.

 >When I made a lot of alterations a while back to pyVCP, I changed the 
 >update code, so that it did not keep cycling through updates every 
 >call unless there was a change.
 >This will have suppressed the first update.

 >I expect no-one has noticed until now, because the initval will 
 >generally reflect the default setting rather than actually set it.
 >Thereafter all clicks upon radio buttons will work as anticipated

 >I have written a fix,  which seems to work OK.
 >Will do a bit more testing and submit a patch to correct this

 >regards

--
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users


Re: [Emc-users] Regression in pyvcp's radiobutton from 2.5 to 2.6.5, nothing selected in the hal layer on startup

2015-01-19 Thread MH

Hello Schooner30,

thanks for your reply. I had a look at it too today and came up with 
with this working code:

 n=0
 for c in choices:
 b=Radiobutton(self,f, text=str(c),variable=self.v, 
value=pow(2,n))
 b.pack()
 c_halpin=halpin+"."+str(c)
 pycomp.newpin(c_halpin, HAL_BIT, HAL_OUT)
 self.halpins.append(c_halpin)
 if n==initval:
 b.select()
 pycomp[self.halpins[-1]]=1
 n+=1

But I like your solution better, because your:
pycomp[self.halpins[initval]]=1
is more readable than my:
pycomp[self.halpins[-1]]=1

So please do submit your patch.

@cradek:
Since Schonner30 has a better/more readable fix I will not persue this 
with my own patch anymore. But thank you for your informations on how to 
submit a patch anyway on the irc channel.

BR
Max.

> Further to below
>
> If you want an immediate fix
>
> /usr/share/pyshared/pyvcp_widgets.py
> line 617
> below
> self.selected = initval
>
> insert
> pycomp[self.halpins[initval]]=1
>
> at same indentation
>
> That will force an update of the initval selected pin or defaults
> setting pin 0 if initval is not set, which is the default radio button
> setting at initialisation
>
> regards
>
>
>
>  >Hi
>
>  >I have tested your code on 2.6.3, 2.7 and 2.8
>  >All of them produce a pyVCP panel with button 3 selected
>
>  >But no, the respective pin is not selected, I think I may know why.
>
>  >When I made a lot of alterations a while back to pyVCP, I changed the
>  >update code, so that it did not keep cycling through updates every
>  >call unless there was a change.
>  >This will have suppressed the first update.
>
>  >I expect no-one has noticed until now, because the initval will
>  >generally reflect the default setting rather than actually set it.
>  >Thereafter all clicks upon radio buttons will work as anticipated
>
>  >I have written a fix,  which seems to work OK.
>  >Will do a bit more testing and submit a patch to correct this
>
>  >regards

--
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
___
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users