16
16
from ._vector_import_helper import (vector , mag , norm , cross , dot , adjust_up ,
17
17
adjust_axis , object_rotate )
18
18
19
+ def Exit ():
20
+ zero = 0.
21
+ print ('exit' )
22
+ a = 1.0 / zero
23
+
24
+ import atexit
25
+ atexit .register (Exit )
26
+
19
27
# List of names that will be imported from this file with import *
20
28
__all__ = ['Camera' , 'GlowWidget' , 'version' , 'GSversion' , 'Mouse' , 'arrow' , 'attach_arrow' ,
21
29
'attach_light' , 'attach_trail' , 'baseObj' , 'box' , 'bumpmaps' , 'button' ,
@@ -389,7 +397,7 @@ def handle_msg(self, msg):
389
397
elif evt ['widget' ] == 'checkbox' :
390
398
obj ._checked = evt ['value' ]
391
399
elif evt ['widget' ] == 'radio' :
392
- obj ._checked = evt ['value' ]
400
+ obj .checked = evt ['value' ]
393
401
elif evt ['widget' ] == 'winput' :
394
402
obj ._text = evt ['text' ]
395
403
obj ._number = evt ['value' ]
@@ -3591,6 +3599,7 @@ def __init__(self, **args):
3591
3599
args ['_objName' ] = 'checkbox'
3592
3600
self ._checked = False
3593
3601
self ._text = ''
3602
+ self ._name = ''
3594
3603
super (checkbox , self ).setup (args )
3595
3604
3596
3605
@property
@@ -3611,12 +3620,22 @@ def checked(self, value):
3611
3620
if not self ._constructing :
3612
3621
self .addattr ('checked' )
3613
3622
3623
+ _radio_groups = {} # radio buttons grouped by name
3624
+
3614
3625
class radio (controls ):
3615
3626
def __init__ (self , ** args ):
3616
3627
args ['_objName' ] = 'radio'
3617
3628
self ._checked = False
3618
3629
self ._text = ''
3630
+ self ._name = ''
3619
3631
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 ]
3620
3639
3621
3640
@property
3622
3641
def text (self ):
@@ -3632,6 +3651,10 @@ def checked(self):
3632
3651
return self ._checked
3633
3652
@checked .setter
3634
3653
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
3635
3658
self ._checked = value
3636
3659
if not self ._constructing :
3637
3660
self .addattr ('checked' )
0 commit comments