@@ -186,6 +186,8 @@ def setupwidgets(self, text):
186186
187187 def makeoptionsmenu (self ):
188188 menuitems = [('Font settingsŠ' , self .domenu_fontsettings ),
189+ ("Save optionsŠ" , self .domenu_options ),
190+ '-' ,
189191 ('\0 ' + chr (self .run_as_main ) + 'Run as __main__' , self .domenu_toggle_run_as_main ),
190192 ('Modularize' , self .domenu_modularize ),
191193 ('Browse namespaceŠ' , self .domenu_browsenamespace ),
@@ -263,6 +265,11 @@ def domenu_fontsettings(self, *args):
263265 self .editgroup .editor .setfontsettings (fontsettings )
264266 self .editgroup .editor .settabsettings (tabsettings )
265267
268+ def domenu_options (self , * args ):
269+ rv = SaveOptions (self ._creator )
270+ if rv :
271+ self ._creator = rv
272+
266273 def clicklinefield (self ):
267274 if self ._currentwidget <> self .linefield :
268275 self .linefield .select (1 )
@@ -619,6 +626,55 @@ def popselectline(self, lineno):
619626 def selectline (self , lineno , charoffset = 0 ):
620627 self .editgroup .editor .selectline (lineno - 1 , charoffset )
621628
629+ class _saveoptions :
630+
631+ def __init__ (self , creator ):
632+ self .rv = None
633+ self .w = w = W .ModalDialog ((240 , 140 ), 'Save options' )
634+ radiobuttons = []
635+ w .label = W .TextBox ((8 , 8 , 80 , 18 ), "File creator:" )
636+ w .ide_radio = W .RadioButton ((8 , 22 , 80 , 18 ), "IDE" , radiobuttons , self .ide_hit )
637+ w .interp_radio = W .RadioButton ((8 , 42 , 80 , 18 ), "Interpreter" , radiobuttons , self .interp_hit )
638+ w .other_radio = W .RadioButton ((8 , 62 , 50 , 18 ), "Other:" , radiobuttons )
639+ w .other_creator = W .EditText ((62 , 62 , 40 , 20 ), creator , self .otherselect )
640+ w .cancelbutton = W .Button ((- 180 , - 30 , 80 , 16 ), "Cancel" , self .cancelbuttonhit )
641+ w .okbutton = W .Button ((- 90 , - 30 , 80 , 16 ), "Done" , self .okbuttonhit )
642+ w .setdefaultbutton (w .okbutton )
643+ if creator == 'Pyth' :
644+ w .interp_radio .set (1 )
645+ elif creator == 'Pide' :
646+ w .ide_radio .set (1 )
647+ else :
648+ w .other_radio .set (1 )
649+ w .bind ("cmd." , w .cancelbutton .push )
650+ w .open ()
651+
652+ def ide_hit (self ):
653+ self .w .other_creator .set ("Pide" )
654+
655+ def interp_hit (self ):
656+ self .w .other_creator .set ("Pyth" )
657+
658+ def otherselect (self , * args ):
659+ sel_from , sel_to = self .w .other_creator .getselection ()
660+ creator = self .w .other_creator .get ()[:4 ]
661+ creator = creator + " " * (4 - len (creator ))
662+ self .w .other_creator .set (creator )
663+ self .w .other_creator .setselection (sel_from , sel_to )
664+ self .w .other_radio .set (1 )
665+
666+ def cancelbuttonhit (self ):
667+ self .w .close ()
668+
669+ def okbuttonhit (self ):
670+ self .rv = self .w .other_creator .get ()[:4 ]
671+ self .w .close ()
672+
673+
674+ def SaveOptions (creator ):
675+ s = _saveoptions (creator )
676+ return s .rv
677+
622678
623679def _escape (where , what ) :
624680 return string .join (string .split (where , what ), '\\ ' + what )
0 commit comments