@@ -138,7 +138,6 @@ class Statusbar(gtk.Statusbar):
138138 """Contains feedback messages"""
139139 def __init__ (self ):
140140 gtk .Statusbar .__init__ (self )
141-
142141 self .context_id = self .get_context_id ('Statusbar' )
143142
144143 def message (self , s , n = 3 ):
@@ -276,23 +275,27 @@ def __init__(self, config, statusbar):
276275 repl .Interaction .__init__ (self , config , statusbar )
277276
278277 def confirm (self , q ):
279- dialog = gtk .MessageDialog (None , gtk .DIALOG_MODAL , gtk .MESSAGE_INFO , gtk .BUTTONS_YES_NO , q )
280- response = True if dialog .run () == gtk .RESPONSE_YES else False
278+ dialog = gtk .MessageDialog (None , gtk .DIALOG_MODAL , gtk .MESSAGE_INFO ,
279+ gtk .BUTTONS_YES_NO , q )
280+ response = dialog .run ()
281281 dialog .destroy ()
282- return response
282+ return response == gtk . RESPONSE_YES
283283
284284 def file_prompt (self , s ):
285285 chooser = gtk .FileChooserDialog (title = "File to save to" ,
286286 action = gtk .FILE_CHOOSER_ACTION_SAVE ,
287- buttons = (gtk .STOCK_CANCEL ,gtk .RESPONSE_CANCEL ,gtk .STOCK_OPEN ,gtk .RESPONSE_OK ))
287+ buttons = (gtk .STOCK_CANCEL ,
288+ gtk .RESPONSE_CANCEL ,
289+ gtk .STOCK_OPEN ,
290+ gtk .RESPONSE_OK ))
288291 chooser .set_default_response (gtk .RESPONSE_OK )
289292 chooser .set_current_name ('test.py' )
290293 chooser .set_current_folder (os .path .expanduser ('~' ))
291-
294+
292295 pyfilter = gtk .FileFilter ()
293296 pyfilter .set_name ("Python files" )
294297 pyfilter .add_pattern ("*.py" )
295- chooser .add_filter (pyfilter )
298+ chooser .add_filter (pyfilter )
296299
297300 allfilter = gtk .FileFilter ()
298301 allfilter .set_name ("All files" )
@@ -618,7 +621,6 @@ def on_suggestion_selection_changed(self, selection, word):
618621 self .get_cursor_iter ())
619622 self .text_buffer .insert_at_cursor (word )
620623
621-
622624 def do_paste (self , widget ):
623625 clipboard = gtk .clipboard_get ()
624626 paste_url = self .pastebin ()
@@ -635,7 +637,6 @@ def do_partial_paste(self, widget):
635637 pass
636638 else :
637639 self .pastebin (self .text_buffer .get_text (bounds [0 ], bounds [1 ]))
638-
639640
640641 def write (self , s ):
641642 """For overriding stdout defaults"""
@@ -654,8 +655,6 @@ def write(self, s):
654655 self .echo (s )
655656 self .s_hist .append (s .rstrip ())
656657
657-
658-
659658 def prompt (self , more ):
660659 """
661660 Show the appropriate Python prompt.
@@ -792,20 +791,19 @@ def main(args=None):
792791
793792 filem = gtk .MenuItem ("File" )
794793 filem .set_submenu (filemenu )
795-
794+
796795 save = gtk .MenuItem ("Save to file" )
797796 save .connect ("activate" , repl_widget .do_write2file )
798797 filemenu .append (save )
799798
800-
801799 pastebin = gtk .MenuItem ("Pastebin" )
802800 pastebin .connect ("activate" , repl_widget .do_paste )
803801 filemenu .append (pastebin )
804802
805803 pastebin_partial = gtk .MenuItem ("Pastebin selection" )
806804 pastebin_partial .connect ("activate" , repl_widget .do_partial_paste )
807805 filemenu .append (pastebin_partial )
808-
806+
809807 exit = gtk .MenuItem ("Exit" )
810808 exit .connect ("activate" , gtk .main_quit )
811809 filemenu .append (exit )
@@ -816,7 +814,6 @@ def main(args=None):
816814
817815 container .pack_start (vbox , expand = False )
818816
819-
820817 # read from config
821818 sw = gtk .ScrolledWindow ()
822819 sw .set_policy (gtk .POLICY_NEVER , gtk .POLICY_AUTOMATIC )
0 commit comments