See previous commit...
This commit is contained in:
75
pygo.py
75
pygo.py
@ -6,34 +6,67 @@
|
||||
import sys
|
||||
sys.path.append('lib/')
|
||||
|
||||
import ConfigParser
|
||||
|
||||
import goban
|
||||
import pygogui
|
||||
import config
|
||||
import gtk, gtk.glade
|
||||
|
||||
|
||||
class Pygo():
|
||||
"""This class handles the main interface, defines basic callbacks"""
|
||||
|
||||
def __init__(self):
|
||||
self.resize = True
|
||||
self.goban = None
|
||||
|
||||
self.network_mode = False
|
||||
self.our_color = None
|
||||
|
||||
self.init_user_interface('./ui/default.glade')
|
||||
self.init_widgets()
|
||||
|
||||
def init_user_interface(self, path_to_skin):
|
||||
self.tree=gtk.glade.XML(path_to_skin, "window")
|
||||
self.tree.signal_autoconnect(self)
|
||||
self.window = self.tree.get_widget('window')
|
||||
|
||||
|
||||
def init_widgets(self):
|
||||
self.window.resize(1000,800)
|
||||
|
||||
# gobject.timeout_add(1000, self.update)
|
||||
|
||||
|
||||
def on_local_new(self, widget):
|
||||
if self.goban:
|
||||
del self.goban
|
||||
self.goban = goban.Goban()
|
||||
self.network_mode = False
|
||||
self.our_color = None
|
||||
|
||||
|
||||
def on_net_direct(self, widget):
|
||||
print 'stub: Pygo.on_menu_net_direct()'
|
||||
|
||||
|
||||
def on_quit(self, widget):
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
# Read config file
|
||||
settings = read_config_file()
|
||||
config.init()
|
||||
|
||||
# Data
|
||||
gb = goban.Goban()
|
||||
gui = pygogui.GUI(gb, settings)
|
||||
# base_icon = gtk.gdk.pixbuf_new_from_file('ui/icon.svg')
|
||||
# icon = base_icon.scale_simple(128, 128, gtk.gdk.INTERP_BILINEAR)
|
||||
# gtk.window_set_default_icon(icon)
|
||||
go_obj = Pygo()
|
||||
|
||||
gui.update()
|
||||
|
||||
while True:
|
||||
# All of the real work happens in pygogui
|
||||
# It keeps a copy of all the relevant data
|
||||
gui.do_event()
|
||||
gui.update()
|
||||
|
||||
|
||||
|
||||
def read_config_file():
|
||||
ret = ConfigParser.ConfigParser()
|
||||
ret.read('pygo.cfg')
|
||||
return ret
|
||||
# Let's see if we can avoid using threads in this implementation
|
||||
# gtk.gdk.threads_init()
|
||||
# gtk.gdk.threads_enter()
|
||||
gtk.main()
|
||||
# gtk.gdk.threads_leave()
|
||||
|
||||
|
||||
if __name__ == '__main__': main()
|
||||
|
Reference in New Issue
Block a user