1616from ._vector_import_helper import (vector , mag , norm , cross , dot , adjust_up ,
1717 adjust_axis , object_rotate )
1818
19+ def Exit ():
20+ zero = 0.
21+ print ('exit' )
22+ a = 1.0 / zero
23+
24+ import atexit
25+ atexit .register (Exit )
26+
1927# List of names that will be imported from this file with import *
2028__all__ = ['Camera' , 'GlowWidget' , 'version' , 'GSversion' , 'Mouse' , 'arrow' , 'attach_arrow' ,
2129 'attach_light' , 'attach_trail' , 'baseObj' , 'box' , 'bumpmaps' , 'button' ,
@@ -389,7 +397,7 @@ def handle_msg(self, msg):
389397 elif evt ['widget' ] == 'checkbox' :
390398 obj ._checked = evt ['value' ]
391399 elif evt ['widget' ] == 'radio' :
392- obj ._checked = evt ['value' ]
400+ obj .checked = evt ['value' ]
393401 elif evt ['widget' ] == 'winput' :
394402 obj ._text = evt ['text' ]
395403 obj ._number = evt ['value' ]
@@ -3591,6 +3599,7 @@ def __init__(self, **args):
35913599 args ['_objName' ] = 'checkbox'
35923600 self ._checked = False
35933601 self ._text = ''
3602+ self ._name = ''
35943603 super (checkbox , self ).setup (args )
35953604
35963605 @property
@@ -3611,12 +3620,22 @@ def checked(self, value):
36113620 if not self ._constructing :
36123621 self .addattr ('checked' )
36133622
3623+ _radio_groups = {} # radio buttons grouped by name
3624+
36143625class radio (controls ):
36153626 def __init__ (self , ** args ):
36163627 args ['_objName' ] = 'radio'
36173628 self ._checked = False
36183629 self ._text = ''
3630+ self ._name = ''
36193631 super (radio , self ).setup (args )
3632+ if type (self ._name ) != str :
3633+ raise AttributeError ("A radio group name must be a string." )
3634+ if self ._name != '' :
3635+ if self ._name in _radio_groups :
3636+ _radio_groups [self ._name ].append (self )
3637+ else :
3638+ _radio_groups [self ._name ] = [self ]
36203639
36213640 @property
36223641 def text (self ):
@@ -3632,6 +3651,10 @@ def checked(self):
36323651 return self ._checked
36333652 @checked .setter
36343653 def checked (self , value ):
3654+ if self ._checked == value : return
3655+ if len (self ._name ) > 0 :
3656+ for r in _radio_groups [self .name ]:
3657+ r ._checked = False
36353658 self ._checked = value
36363659 if not self ._constructing :
36373660 self .addattr ('checked' )
0 commit comments