From 38b298ec4518907448162b2076683c3d6d39309d Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Tue, 17 Apr 2012 01:21:39 -0400 Subject: [PATCH] Make go board widget show (even if it doesn't quite work yet) --- pygo.py | 18 ++++++++++++++---- widgets/gogame.py | 13 +++++++++---- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/pygo.py b/pygo.py index e85d481..0f66d35 100755 --- a/pygo.py +++ b/pygo.py @@ -5,10 +5,12 @@ import sys sys.path.append('lib/') +sys.path.append('widgets/') import goban import config import gtk, gtk.glade, gobject +import gogame class Pygo(): @@ -22,7 +24,8 @@ 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): self.tree=gtk.glade.XML(path_to_skin, "window") @@ -31,20 +34,27 @@ 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_local_new(self, widget): + if self.gogame: + self.contents.remove(self.gogame) + del self.gogame if self.goban: del self.goban + self.goban = goban.Goban() self.network_mode = False self.our_color = None - # fixme: create the go board widget and add it to our box here + self.gogame = gogame.GoGame(self.goban) + self.contents.pack_start(self.gogame) + self.gogame.show_all() + diff --git a/widgets/gogame.py b/widgets/gogame.py index c7ee12d..ded5725 100644 --- a/widgets/gogame.py +++ b/widgets/gogame.py @@ -1,9 +1,10 @@ # This is a widget that handles a go game # It needs a goban object, and handles it from beginning to end -import goban +import os import gtk -import lib.options + +import goban class GoGame(gtk.HBox): @@ -15,7 +16,7 @@ class GoGame(gtk.HBox): _img_res = None def __init__(self, goban): - self.HBox.__init__(self) + super(GoGame, self).__init__() if GoGame._img_res is None: GoGame._img_res = _build_img_res() @@ -28,8 +29,12 @@ class GoGame(gtk.HBox): 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 info_box = gtk.VBox() - info_rows = [gtk.VBox()] * 3 + info_rows = [] + for i in range(3): + info_rows.append(gtk.VBox()) + to_move_label = gtk.Label('To Move:') black_cap_label = gtk.Label('Black Captures:') white_cap_label = gtk.Label('White Captures:')