Make go board widget show (even if it doesn't quite work yet)

This commit is contained in:
Anna Rose 2012-04-17 01:21:39 -04:00
parent 966c6eb9e7
commit 38b298ec45
2 changed files with 23 additions and 8 deletions

18
pygo.py
View File

@ -5,10 +5,12 @@
import sys import sys
sys.path.append('lib/') sys.path.append('lib/')
sys.path.append('widgets/')
import goban import goban
import config import config
import gtk, gtk.glade, gobject import gtk, gtk.glade, gobject
import gogame
class Pygo(): class Pygo():
@ -22,7 +24,8 @@ class Pygo():
self.our_color = None self.our_color = None
self.init_user_interface('./ui/default.glade') self.init_user_interface('./ui/default.glade')
self.init_widgets() self._init_widgets()
def init_user_interface(self, path_to_skin): def init_user_interface(self, path_to_skin):
self.tree=gtk.glade.XML(path_to_skin, "window") self.tree=gtk.glade.XML(path_to_skin, "window")
@ -31,20 +34,27 @@ class Pygo():
self.contents = self.tree.get_widget('main_box') self.contents = self.tree.get_widget('main_box')
def init_widgets(self): def _init_widgets(self):
self.window.resize(1000,800) self.window.resize(1000,800)
self.gogame = None
# gobject.timeout_add(1000, self.update) # gobject.timeout_add(1000, self.update)
def on_local_new(self, widget): def on_local_new(self, widget):
if self.gogame:
self.contents.remove(self.gogame)
del self.gogame
if self.goban: if self.goban:
del self.goban del self.goban
self.goban = goban.Goban() self.goban = goban.Goban()
self.network_mode = False self.network_mode = False
self.our_color = None 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()

View File

@ -1,9 +1,10 @@
# This is a widget that handles a go game # This is a widget that handles a go game
# It needs a goban object, and handles it from beginning to end # It needs a goban object, and handles it from beginning to end
import goban import os
import gtk import gtk
import lib.options
import goban
class GoGame(gtk.HBox): class GoGame(gtk.HBox):
@ -15,7 +16,7 @@ class GoGame(gtk.HBox):
_img_res = None _img_res = None
def __init__(self, goban): def __init__(self, goban):
self.HBox.__init__(self) super(GoGame, self).__init__()
if GoGame._img_res is None: if GoGame._img_res is None:
GoGame._img_res = _build_img_res() GoGame._img_res = _build_img_res()
@ -28,8 +29,12 @@ class GoGame(gtk.HBox):
def _init_widgets(self): def _init_widgets(self):
self.board_area = gtk.DrawingArea() 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_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:') to_move_label = gtk.Label('To Move:')
black_cap_label = gtk.Label('Black Captures:') black_cap_label = gtk.Label('Black Captures:')
white_cap_label = gtk.Label('White Captures:') white_cap_label = gtk.Label('White Captures:')