Use debian 2.7 only
[fpbd-bostik.git] / pyfpdb / Tables_Demo.py
blob4267c975b658d069074363622b5c99d593555cbf
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[0:5] == 'linux':
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 if __name__ == "__main__":
47 Configuration.set_logfile("fpdb-log.txt")
48 config = Configuration.Config()
49 # Main function used for testing
50 if __name__=="__main__":
51 # c = Configuration.Config()
53 class fake_hud(object):
54 def __init__(self, table, dx = 100, dy = 100):
55 self.table = table
56 self.dx = dx
57 self.dy = dy
59 self.main_window = gtk.Window()
60 self.main_window.connect("destroy", self.client_destroyed)
61 self.label = gtk.Label('Fake Fake Fake Fake\nFake\nFake\nFake')
62 self.main_window.add(self.label)
63 self.main_window.set_title(_("Fake HUD Main Window"))
64 self.main_window.move(table.x + dx, table.y + dy)
65 self.main_window.show_all()
66 table.topify(self.main_window)
68 # These are the currently defined signals. Do this in the HUD.
69 self.main_window.connect("client_moved", self.client_moved)
70 self.main_window.connect("client_resized", self.client_resized)
71 self.main_window.connect("client_destroyed", self.client_destroyed)
72 self.main_window.connect("game_changed", self.game_changed)
73 self.main_window.connect("table_changed", self.table_changed)
75 # And these of the handlers that go with those signals.
76 # These would live inside the HUD code.
77 def client_moved(self, widget, hud):
78 self.main_window.move(self.table.x + self.dx, self.table.y + self.dy)
80 def client_resized(self, *args):
81 print "Client resized"
83 def client_destroyed(self, *args): # call back for terminating the main eventloop
84 print "Client destroyed."
85 gtk.main_quit()
87 def game_changed(self, *args):
88 print "Game Changed."
90 def table_changed(self, *args):
91 print "Table Changed."
93 print _("enter table name to find: "),
94 table_name = sys.stdin.readline()
95 if "," in table_name: # tournament
96 print "tournament"
97 (tour_no, tab_no) = table_name.split(",", 1)
98 tour_no = tour_no.rstrip()
99 tab_no = tab_no.rstrip()
100 type = "tour"
101 table_kwargs = dict(tournament = tour_no, table_number = tab_no)
102 else: # not a tournament
103 print "cash game"
104 table_name = table_name.rstrip()
105 type = "cash"
106 table_kwargs = dict(table_name = table_name)
108 table = Tables.Table(config, "Full Tilt Poker", **table_kwargs)
109 table.gdkhandle = gtk.gdk.window_foreign_new(table.number)
110 print table
112 fake = fake_hud(table)
113 fake.parent = fake
115 gobject.timeout_add(1000, table.check_game, fake)
116 gobject.timeout_add(100, table.check_table, fake)
117 print "calling main"
118 gtk.main()