Added a way to close the currently open game, to ease transition to multiple games running at once
This commit is contained in:
parent
cb0fdcf017
commit
00b65a65df
12
pygo.py
12
pygo.py
|
@ -24,7 +24,7 @@ class Pygo():
|
|||
self.our_color = None
|
||||
|
||||
self.init_user_interface('./ui/default.glade')
|
||||
self._init_widgets()
|
||||
self.init_widgets()
|
||||
|
||||
|
||||
def init_user_interface(self, path_to_skin):
|
||||
|
@ -34,18 +34,22 @@ class Pygo():
|
|||
self.contents = self.tree.get_widget('main_box')
|
||||
|
||||
|
||||
def _init_widgets(self):
|
||||
def init_widgets(self):
|
||||
self.window.resize(1000,800)
|
||||
self.gogame = None
|
||||
# gobject.timeout_add(1000, self.update)
|
||||
|
||||
|
||||
def on_game_close(self, widget):
|
||||
print 'Pygo.on_game_close(): stub'
|
||||
|
||||
|
||||
def on_local_new(self, widget):
|
||||
if self.gogame:
|
||||
self.contents.remove(self.gogame)
|
||||
del self.gogame
|
||||
self.gogame = None
|
||||
if self.goban:
|
||||
del self.goban
|
||||
self.goban = None
|
||||
|
||||
self.goban = goban.Goban()
|
||||
self.network_mode = False
|
||||
|
|
|
@ -40,6 +40,16 @@
|
|||
<child>
|
||||
<widget class="GtkMenu" id="game1_menu">
|
||||
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="close1">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Close</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="on_game_close" last_modification_time="Tue, 17 Apr 2012 05:44:12 GMT"/>
|
||||
<accelerator key="W" modifiers="GDK_CONTROL_MASK" signal="activate"/>
|
||||
</widget>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<widget class="GtkImageMenuItem" id="quit">
|
||||
<property name="visible">True</property>
|
||||
|
|
|
@ -13,19 +13,19 @@ class GoGame(gtk.HBox):
|
|||
It also handles moves and other operations on the goban.
|
||||
"""
|
||||
|
||||
_img_res = None
|
||||
img_res = None
|
||||
|
||||
def __init__(self, goban):
|
||||
super(GoGame, self).__init__()
|
||||
|
||||
self.goban = goban
|
||||
|
||||
if GoGame._img_res is None:
|
||||
GoGame._img_res = _build_img_res()
|
||||
self._init_widgets()
|
||||
if GoGame.img_res is None:
|
||||
GoGame.img_res = _build_img_res()
|
||||
self.init_widgets()
|
||||
|
||||
|
||||
def _init_widgets(self):
|
||||
def init_widgets(self):
|
||||
self.board_area = gtk.DrawingArea()
|
||||
|
||||
# All of this is to create the info box along the right side of the board
|
||||
|
@ -54,8 +54,8 @@ class GoGame(gtk.HBox):
|
|||
|
||||
self.pass_button = gtk.Button('Pass')
|
||||
self.resign_button = gtk.Button('Resign')
|
||||
self.pass_button.connect('clicked', self._on_pass)
|
||||
self.resign_button.connect('clicked', self._on_resign)
|
||||
self.pass_button.connect('clicked', self.on_pass)
|
||||
self.resign_button.connect('clicked', self.on_resign)
|
||||
|
||||
info_box.pack_start(self.pass_button, expand=False, padding=10)
|
||||
info_box.pack_start(self.resign_button, expand=False, padding=10)
|
||||
|
@ -64,18 +64,18 @@ class GoGame(gtk.HBox):
|
|||
self.pack_end(info_box, expand=False)
|
||||
|
||||
|
||||
def _draw_board(self):
|
||||
def draw_board(self):
|
||||
gc = self.board_area.get_style().fg_gc[gtk.STATE_NORMAL]
|
||||
|
||||
# gtk.gdk.gdk_pixbuf_scale_simple(img, new_width, new_height, GDK_INTERP_BILINEAR)
|
||||
|
||||
|
||||
def _on_pass(self, widget):
|
||||
print 'GoGame._on_pass(): stub'
|
||||
def on_pass(self, widget):
|
||||
print 'GoGame.on_pass(): stub'
|
||||
|
||||
|
||||
def _on_resign(self, widget):
|
||||
print 'GoGame._on_resign(): stub'
|
||||
def on_resign(self, widget):
|
||||
print 'GoGame.on_resign(): stub'
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user