Expanded my entry in contributors.txt.
[fpdb-dooglus.git] / pyfpdb / Tables_Demo.py
blobfc5e8547abdc4bca01e8dad97832804372efb1c0
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 """Tables_Demo.py
5 Main program module to test/demo the Tables subclasses.
6 """
7 # Copyright 2008-2011, Ray E. Barker
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write to the Free Software
21 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 ########################################################################
25 # Standard Library modules
26 import sys
28 # pyGTK modules
29 import pygtk
30 import gtk
31 import gobject
33 # fpdb/free poker tools modules
34 import Configuration
35 import L10n
36 _ = L10n.get_translation()
38 # get the correct module for the current os
39 if sys.platform == 'linux2':
40 import XTables as Tables
41 elif sys.platform == 'darwin':
42 import OSXTables as Tables
43 else: # This is bad--figure out the values for the various windows flavors
44 import WinTables as Tables
46 config = Configuration.Config()
47 # Main function used for testing
48 if __name__=="__main__":
49 # c = Configuration.Config()
51 class fake_hud(object):
52 def __init__(self, table, dx = 100, dy = 100):
53 self.table = table
54 self.dx = dx
55 self.dy = dy
57 self.main_window = gtk.Window()
58 self.main_window.connect("destroy", self.client_destroyed)
59 self.label = gtk.Label('Fake Fake Fake Fake\nFake\nFake\nFake')
60 self.main_window.add(self.label)
61 self.main_window.set_title(_("Fake HUD Main Window"))
62 self.main_window.move(table.x + dx, table.y + dy)
63 self.main_window.show_all()
64 table.topify(self.main_window)
66 # These are the currently defined signals. Do this in the HUD.
67 self.main_window.connect("client_moved", self.client_moved)
68 self.main_window.connect("client_resized", self.client_resized)
69 self.main_window.connect("client_destroyed", self.client_destroyed)
70 self.main_window.connect("game_changed", self.game_changed)
71 self.main_window.connect("table_changed", self.table_changed)
73 # And these of the handlers that go with those signals.
74 # These would live inside the HUD code.
75 def client_moved(self, widget, hud):
76 self.main_window.move(self.table.x + self.dx, self.table.y + self.dy)
78 def client_resized(self, *args):
79 print "Client resized"
81 def client_destroyed(self, *args): # call back for terminating the main eventloop
82 print "Client destroyed."
83 gtk.main_quit()
85 def game_changed(self, *args):
86 print "Game Changed."
88 def table_changed(self, *args):
89 print "Table Changed."
91 print _("enter table name to find: "),
92 table_name = sys.stdin.readline()
93 if "," in table_name: # tournament
94 print "tournament"
95 (tour_no, tab_no) = table_name.split(",", 1)
96 tour_no = tour_no.rstrip()
97 tab_no = tab_no.rstrip()
98 type = "tour"
99 table_kwargs = dict(tournament = tour_no, table_number = tab_no)
100 else: # not a tournament
101 print "cash game"
102 table_name = table_name.rstrip()
103 type = "cash"
104 table_kwargs = dict(table_name = table_name)
106 table = Tables.Table(config, "Full Tilt Poker", **table_kwargs)
107 table.gdkhandle = gtk.gdk.window_foreign_new(table.number)
108 print table
110 fake = fake_hud(table)
111 fake.parent = fake
113 gobject.timeout_add(1000, table.check_game, fake)
114 gobject.timeout_add(100, table.check_table, fake)
115 print "calling main"
116 gtk.main()