Implemented sgf file saving, loading, and tracking during play
This commit is contained in:
parent
da935d8e46
commit
00448c967f
2 changed files with 56 additions and 5 deletions
27
pygo.py
27
pygo.py
|
@ -54,11 +54,34 @@ class Pygo():
|
|||
|
||||
|
||||
def on_game_save(self, widget):
|
||||
print 'stub: Pygo.on_game_save()'
|
||||
if self.games.get_current_page() == -1:
|
||||
return
|
||||
|
||||
game = self.games.get_nth_page(self.games.get_current_page())
|
||||
if game.goban.file_name is None:
|
||||
self.on_game_save_as(None)
|
||||
else:
|
||||
game.goban.save_sgf()
|
||||
|
||||
|
||||
def on_game_save_as(self, widget):
|
||||
print 'stub: Pygo.on_game_save_as()'
|
||||
if self.games.get_current_page() == -1:
|
||||
return
|
||||
|
||||
game = self.games.get_nth_page(self.games.get_current_page())
|
||||
|
||||
dialog = gtk.FileChooserDialog(title=None, action=gtk.FILE_CHOOSER_ACTION_SAVE,
|
||||
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
|
||||
|
||||
if game.goban.file_name is not None:
|
||||
dialog.set_current_name(game.goban.file_name)
|
||||
|
||||
# fixme - when we already have a filename, this throws an error...
|
||||
resp = dialog.run()
|
||||
if resp == gtk.RESPONSE_OK:
|
||||
game.goban.save_sgf(dialog.get_filename())
|
||||
|
||||
dialog.destroy()
|
||||
|
||||
|
||||
def on_game_close(self, widget):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue