5050_COLORS = dict (b = 'blue' , c = 'cyan' , g = 'green' , m = 'magenta' , r = 'red' ,
5151 w = 'white' , y = 'yellow' , k = 'black' , d = 'black' )
5252
53- def run_stdin (stdin ):
54- """
55- Overwrite stdin reader from args as GTK does not supply a stdin/stdout
56- as a tty.
57- """
58- pass
59-
60- bpython .args .run_stdin = run_stdin
61-
6253class ArgspecFormatter (object ):
6354 """
6455 Format an argspec using Pango markup language.
@@ -147,7 +138,6 @@ class Statusbar(gtk.Statusbar):
147138 """Contains feedback messages"""
148139 def __init__ (self ):
149140 gtk .Statusbar .__init__ (self )
150-
151141 self .context_id = self .get_context_id ('Statusbar' )
152142
153143 def message (self , s , n = 3 ):
@@ -285,23 +275,27 @@ def __init__(self, config, statusbar):
285275 repl .Interaction .__init__ (self , config , statusbar )
286276
287277 def confirm (self , q ):
288- dialog = gtk .MessageDialog (None , gtk .DIALOG_MODAL , gtk .MESSAGE_INFO , gtk .BUTTONS_YES_NO , q )
289- 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 ()
290281 dialog .destroy ()
291- return response
282+ return response == gtk . RESPONSE_YES
292283
293284 def file_prompt (self , s ):
294285 chooser = gtk .FileChooserDialog (title = "File to save to" ,
295286 action = gtk .FILE_CHOOSER_ACTION_SAVE ,
296- 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 ))
297291 chooser .set_default_response (gtk .RESPONSE_OK )
298292 chooser .set_current_name ('test.py' )
299293 chooser .set_current_folder (os .path .expanduser ('~' ))
300-
294+
301295 pyfilter = gtk .FileFilter ()
302296 pyfilter .set_name ("Python files" )
303297 pyfilter .add_pattern ("*.py" )
304- chooser .add_filter (pyfilter )
298+ chooser .add_filter (pyfilter )
305299
306300 allfilter = gtk .FileFilter ()
307301 allfilter .set_name ("All files" )
@@ -331,7 +325,7 @@ class ReplWidget(gtk.TextView, repl.Repl):
331325 def __init__ (self , interpreter , config ):
332326 gtk .TextView .__init__ (self )
333327 repl .Repl .__init__ (self , interpreter , config )
334- interpreter .writetb = self .writetb
328+ self . interp .writetb = self .writetb
335329 self .editing = Nested ()
336330 self .reset_indent = False
337331 self .modify_font (pango .FontDescription (self .config .gtk_font ))
@@ -627,12 +621,12 @@ def on_suggestion_selection_changed(self, selection, word):
627621 self .get_cursor_iter ())
628622 self .text_buffer .insert_at_cursor (word )
629623
630-
631624 def do_paste (self , widget ):
632625 clipboard = gtk .clipboard_get ()
633626 paste_url = self .pastebin ()
634- clipboard .set_text (paste_url )
635- clipboard .store ()
627+ if paste_url :
628+ clipboard .set_text (paste_url )
629+ clipboard .store ()
636630
637631 def do_write2file (self , widget ):
638632 self .write2file ()
@@ -644,7 +638,6 @@ def do_partial_paste(self, widget):
644638 pass
645639 else :
646640 self .pastebin (self .text_buffer .get_text (bounds [0 ], bounds [1 ]))
647-
648641
649642 def write (self , s ):
650643 """For overriding stdout defaults"""
@@ -663,8 +656,6 @@ def write(self, s):
663656 self .echo (s )
664657 self .s_hist .append (s .rstrip ())
665658
666-
667-
668659 def prompt (self , more ):
669660 """
670661 Show the appropriate Python prompt.
@@ -755,7 +746,8 @@ def main(args=None):
755746 "Options specific to bpython's Gtk+ front end" ,
756747 [optparse .Option ('--socket-id' , dest = 'socket_id' ,
757748 type = 'int' , help = 'Embed bpython' )])
758- config , options , exec_args = bpython .args .parse (args , gtk_options )
749+ config , options , exec_args = bpython .args .parse (args , gtk_options ,
750+ True )
759751
760752 interpreter = repl .Interpreter (None , getpreferredencoding ())
761753 repl_widget = ReplWidget (interpreter , config )
@@ -800,21 +792,20 @@ def main(args=None):
800792
801793 filem = gtk .MenuItem ("File" )
802794 filem .set_submenu (filemenu )
803-
804- save = gtk .MenuItem ( "Save to file" )
795+
796+ save = gtk .ImageMenuItem ( gtk . STOCK_SAVE )
805797 save .connect ("activate" , repl_widget .do_write2file )
806798 filemenu .append (save )
807799
808-
809800 pastebin = gtk .MenuItem ("Pastebin" )
810801 pastebin .connect ("activate" , repl_widget .do_paste )
811802 filemenu .append (pastebin )
812803
813804 pastebin_partial = gtk .MenuItem ("Pastebin selection" )
814805 pastebin_partial .connect ("activate" , repl_widget .do_partial_paste )
815806 filemenu .append (pastebin_partial )
816-
817- exit = gtk .MenuItem ( "Exit" )
807+
808+ exit = gtk .ImageMenuItem ( gtk . STOCK_QUIT )
818809 exit .connect ("activate" , gtk .main_quit )
819810 filemenu .append (exit )
820811
@@ -824,7 +815,6 @@ def main(args=None):
824815
825816 container .pack_start (vbox , expand = False )
826817
827-
828818 # read from config
829819 sw = gtk .ScrolledWindow ()
830820 sw .set_policy (gtk .POLICY_NEVER , gtk .POLICY_AUTOMATIC )
0 commit comments