sys.stdout.write (self.BLUE + "Across word at position: " + aword + "\n" + self.ENDCOL)
clue = raw_input (self.BRICKRED + "Clue for across word: " + self.ENDCOL)
self.puzzle.data[arow][acol].clue_across = clue
- sys.stdout.write (self.BLUE + "Set the clue: \n" + self.puzzle.data[arow][acol].clue_across)
+ sys.stdout.write (self.BLUE + "Set the clue: \n" +
+ self.puzzle.data[arow][acol].clue_across + "\n")
except crosswordpuzzle.NoWordException:
sys.stderr.write ("No across word found at that position\n")
sys.stdout.write (self.BLUE + "Down word at position: " + dword + "\n" + self.ENDCOL)
clue = raw_input (self.BRICKRED + "Clue for down word: " + self.ENDCOL)
self.puzzle.data[drow][dcol].clue_down = clue
- sys.stdout.write (self.BLUE + "Set the clue: \n" + self.puzzle.data[drow][dcol].clue_down)
+ sys.stdout.write (self.BLUE + "Set the clue: \n" +
+ self.puzzle.data[drow][dcol].clue_down + "\n")
except crosswordpuzzle.NoWordException:
sys.stderr.write ("No down word found at that position\n")
ACROSS = 1
DOWN = 2
- def gtk_main_quit (self, *args):
- gtk.main_quit ()
+ # callback for menu item open activated event
+ def on_open_activate (self, menuitem):
+ dlg = gtk.FileChooserDialog ("Open a GetAClue puzzle", self.window,
+ gtk.FILE_CHOOSER_ACTION_OPEN,
+ (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK))
- # callback for menu item quit activated event
- def on_quit_activate (self, menuitem):
+ if dlg.run () == gtk.RESPONSE_OK:
+ puzzlefile = dlg.get_filename ()
+ self.open_file (puzzlefile)
+
+ dlg.destroy ()
+
+ # quit verification
+ def verify_quit (self):
if self.puzzle:
dlg = gtk.MessageDialog (self.window, gtk.DIALOG_MODAL,
gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO,
dlg.destroy ()
return False
dlg.destroy ()
+ return True
+
- self.gtk_main_quit ()
+ # callback for main window destroy
+ def on_mainwindow_destroy (self, args):
+ gtk.main_quit ()
+
+
+ # callback for window closing dialog
+ def on_mainwindow_delete_event (self, window, event):
+ # verify whether really to quit or not if a puzzle is open
+ v = self.verify_quit ()
+ # return False for deleting and True for not deleting
+ return not v
+
+ # callback for menu item quit activated event
+ def on_quit_activate (self, menuitem):
+ # verify whether really to quit or not if a puzzle is open
+ v = self.verify_quit ()
+ # if verified, then quit
+ if v is True:
+ self.window.destroy ()
# callback for menu item clear grid activated event
def on_cleargrid_activate (self, menuitem):
<property name="title" translatable="yes">GetAClue player</property>
<property name="default_width">640</property>
<property name="default_height">480</property>
- <signal name="destroy" handler="gtk_main_quit"/>
+ <signal name="destroy" handler="on_mainwindow_destroy"/>
+ <signal name="delete_event" handler="on_mainwindow_delete_event"/>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="visible">True</property>
<property name="label" translatable="yes">Open...</property>
<property name="use_underline">True</property>
+ <signal name="activate" handler="on_open_activate"/>
</object>
</child>
<child>