git12 - added percent sign to tv display

removed debug prints that im not going to touch for a while.
This commit is contained in:
steffen123 2008-08-06 21:09:29 +01:00
parent fb7a8ba9a2
commit 5ee5594741
4 changed files with 24 additions and 23 deletions

View File

@ -2,6 +2,7 @@ todolist (db=database, imp=importer, tv=tableviewer)
before alpha before alpha
============ ============
colour in tv
verify at least one PrintPlayerFlags verify at least one PrintPlayerFlags
in tv, select from hud table using named fields rather than the current * in tv, select from hud table using named fields rather than the current *
imp/tv bug: handcount is only about 1/2 of what it should be imp/tv bug: handcount is only about 1/2 of what it should be

View File

@ -30,7 +30,7 @@ import table_viewer
class fpdb: class fpdb:
def tab_clicked(self, widget, tab_name): def tab_clicked(self, widget, tab_name):
"""called when a tab button is clicked to activate that tab""" """called when a tab button is clicked to activate that tab"""
print "start of tab_clicked" #print "start of tab_clicked"
self.display_tab(tab_name) self.display_tab(tab_name)
#end def tab_clicked #end def tab_clicked
@ -42,7 +42,7 @@ class fpdb:
def add_tab(self, new_tab, new_tab_name): def add_tab(self, new_tab, new_tab_name):
"""adds a tab, namely creates the button and displays it and appends all the relevant arrays""" """adds a tab, namely creates the button and displays it and appends all the relevant arrays"""
print "start of add_tab" #print "start of add_tab"
for i in self.tab_names: #todo: check this is valid for i in self.tab_names: #todo: check this is valid
if i==new_tab_name: if i==new_tab_name:
raise fpdb_simple.FpdbError("duplicate tab_name not permitted") raise fpdb_simple.FpdbError("duplicate tab_name not permitted")
@ -59,11 +59,11 @@ class fpdb:
def display_tab(self, new_tab_name): def display_tab(self, new_tab_name):
"""displays the indicated tab""" """displays the indicated tab"""
print "start of display_tab, len(self.tab_names):",len(self.tab_names) #print "start of display_tab, len(self.tab_names):",len(self.tab_names)
tab_no=-1 tab_no=-1
#if len(self.tab_names)>1: #if len(self.tab_names)>1:
for i in range(len(self.tab_names)): for i in range(len(self.tab_names)):
print "display_tab, new_tab_name:",new_tab_name," self.tab_names[i]:", self.tab_names[i] #print "display_tab, new_tab_name:",new_tab_name," self.tab_names[i]:", self.tab_names[i]
if (new_tab_name==self.tab_names[i]): if (new_tab_name==self.tab_names[i]):
tab_no=i tab_no=i
#self.tab_buttons[i].set_active(False) #self.tab_buttons[i].set_active(False)
@ -309,7 +309,7 @@ class fpdb:
def tab_bulk_import(self, widget, data): def tab_bulk_import(self, widget, data):
"""opens a tab for bulk importing""" """opens a tab for bulk importing"""
print "start of tab_bulk_import" #print "start of tab_bulk_import"
new_import_thread=import_threaded.import_threaded(self.db, self.bulk_import_default_path) new_import_thread=import_threaded.import_threaded(self.db, self.bulk_import_default_path)
self.threads.append(new_import_thread) self.threads.append(new_import_thread)
bulk_tab=new_import_thread.get_vbox() bulk_tab=new_import_thread.get_vbox()
@ -318,7 +318,7 @@ class fpdb:
def tab_main_help(self, widget, data): def tab_main_help(self, widget, data):
"""Displays a tab with the main fpdb help screen""" """Displays a tab with the main fpdb help screen"""
print "start of tab_main_help" #print "start of tab_main_help"
mh_tab=gtk.Label("""Welcome to Fpdb mh_tab=gtk.Label("""Welcome to Fpdb
blabla todo make this read a file for the helptext blabla todo make this read a file for the helptext
blabla blabla
@ -328,7 +328,7 @@ blabla""")
def tab_table_viewer(self, widget, data): def tab_table_viewer(self, widget, data):
"""opens a table viewer tab""" """opens a table viewer tab"""
print "start of tab_table_viewer" #print "start of tab_table_viewer"
new_tv_thread=table_viewer.table_viewer(self.db) new_tv_thread=table_viewer.table_viewer(self.db)
self.threads.append(new_tv_thread) self.threads.append(new_tv_thread)
tv_tab=new_tv_thread.get_vbox() tv_tab=new_tv_thread.get_vbox()
@ -343,7 +343,7 @@ blabla""")
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.connect("delete_event", self.delete_event) self.window.connect("delete_event", self.delete_event)
self.window.connect("destroy", self.destroy) self.window.connect("destroy", self.destroy)
self.window.set_title("Free Poker DB") self.window.set_title("Free Poker DB - version: pre-alpha, git12")
self.window.set_border_width(1) self.window.set_border_width(1)
self.window.set_size_request(600,400) self.window.set_size_request(600,400)
self.window.set_resizable(True) self.window.set_resizable(True)

View File

@ -37,7 +37,7 @@ class fpdb_db:
#print "fpdb_db.connect, password:",password,"/end" #print "fpdb_db.connect, password:",password,"/end"
if backend==self.MYSQL_INNODB: if backend==self.MYSQL_INNODB:
import MySQLdb import MySQLdb
print "fpdb_db.connect, host:", host, " user:", user, " passwd:", password, " db:", database #print "fpdb_db.connect, host:", host, " user:", user, " passwd:", password, " db:", database
self.db=MySQLdb.connect(host = host, user = user, passwd = password, db = database) self.db=MySQLdb.connect(host = host, user = user, passwd = password, db = database)
elif backend==self.PGSQL: elif backend==self.PGSQL:
import pgdb import pgdb
@ -73,7 +73,7 @@ class fpdb_db:
def reconnect(self, due_to_error=False): def reconnect(self, due_to_error=False):
"""Reconnects the DB""" """Reconnects the DB"""
print "started fpdb_db.reconnect" #print "started fpdb_db.reconnect"
self.disconnect(due_to_error) self.disconnect(due_to_error)
self.connect(self.backend, self.host, self.database, self.user, self.password) self.connect(self.backend, self.host, self.database, self.user, self.password)
#end def disconnect #end def disconnect

View File

@ -29,13 +29,13 @@ class table_viewer (threading.Thread):
if b==0: if b==0:
return "n/a" return "n/a"
else: else:
return str(int((a/float(b))*100)) return str(int((a/float(b))*100))+"%"
return "todo" return "todo"
#end def hudDivide #end def hudDivide
def browse_clicked(self, widget, data): def browse_clicked(self, widget, data):
"""runs when user clicks browse on tv tab""" """runs when user clicks browse on tv tab"""
print "start of table_viewer.browser_clicked" #print "start of table_viewer.browser_clicked"
current_path=self.filename_tbuffer.get_text(self.filename_tbuffer.get_start_iter(), self.filename_tbuffer.get_end_iter()) current_path=self.filename_tbuffer.get_text(self.filename_tbuffer.get_start_iter(), self.filename_tbuffer.get_end_iter())
dia_chooser = gtk.FileChooserDialog(title="Please choose the file for which you want to open the Table Viewer", dia_chooser = gtk.FileChooserDialog(title="Please choose the file for which you want to open the Table Viewer",
@ -56,7 +56,7 @@ class table_viewer (threading.Thread):
def prepare_data(self): def prepare_data(self):
"""prepares the data for display by refresh_clicked, returns a 2D array""" """prepares the data for display by refresh_clicked, returns a 2D array"""
print "start of prepare_data" #print "start of prepare_data"
arr=[] arr=[]
#first prepare the header row #first prepare the header row
if (self.category=="holdem" or self.category=="omahahi" or self.category=="omahahilo"): if (self.category=="holdem" or self.category=="omahahi" or self.category=="omahahilo"):
@ -91,7 +91,7 @@ class table_viewer (threading.Thread):
def refresh_clicked(self, widget, data): def refresh_clicked(self, widget, data):
"""runs when user clicks refresh""" """runs when user clicks refresh"""
if self.debug: print "start of table_viewer.refresh_clicked" #print "start of table_viewer.refresh_clicked"
arr=self.prepare_data() arr=self.prepare_data()
try: self.data_table.destroy() try: self.data_table.destroy()
@ -109,37 +109,37 @@ class table_viewer (threading.Thread):
def read_names_clicked(self, widget, data): def read_names_clicked(self, widget, data):
"""runs when user clicks read names""" """runs when user clicks read names"""
print "start of table_viewer.read_names_clicked" #print "start of table_viewer.read_names_clicked"
print "self.last_read_hand:",self.last_read_hand #print "self.last_read_hand:",self.last_read_hand
self.db.reconnect() self.db.reconnect()
self.cursor=self.db.cursor self.cursor=self.db.cursor
self.cursor.execute("""SELECT id FROM hands WHERE site_hand_no=%s""", (self.last_read_hand)) self.cursor.execute("""SELECT id FROM hands WHERE site_hand_no=%s""", (self.last_read_hand))
hands_id_tmp=self.db.cursor.fetchone() hands_id_tmp=self.db.cursor.fetchone()
print "tmp:",hands_id_tmp #print "tmp:",hands_id_tmp
self.hands_id=hands_id_tmp[0] self.hands_id=hands_id_tmp[0]
self.db.cursor.execute("SELECT gametype_id FROM hands WHERE id=%s", (self.hands_id, )) self.db.cursor.execute("SELECT gametype_id FROM hands WHERE id=%s", (self.hands_id, ))
self.gametype_id=self.db.cursor.fetchone()[0] self.gametype_id=self.db.cursor.fetchone()[0]
self.cursor.execute("SELECT category FROM gametypes WHERE id=%s", (self.gametype_id, )) self.cursor.execute("SELECT category FROM gametypes WHERE id=%s", (self.gametype_id, ))
self.category=self.db.cursor.fetchone()[0] self.category=self.db.cursor.fetchone()[0]
print "self.gametype_id", self.gametype_id," category:", self.category, " self.hands_id:", self.hands_id #print "self.gametype_id", self.gametype_id," category:", self.category, " self.hands_id:", self.hands_id
self.db.cursor.execute("""SELECT DISTINCT players.id FROM hands_players self.db.cursor.execute("""SELECT DISTINCT players.id FROM hands_players
INNER JOIN players ON hands_players.player_id=players.id INNER JOIN players ON hands_players.player_id=players.id
WHERE hand_id=%s""", (self.hands_id, )) WHERE hand_id=%s""", (self.hands_id, ))
self.player_ids=self.db.cursor.fetchall() self.player_ids=self.db.cursor.fetchall()
print "self.player_ids:",self.player_ids #print "self.player_ids:",self.player_ids
self.db.cursor.execute("""SELECT DISTINCT players.name FROM hands_players self.db.cursor.execute("""SELECT DISTINCT players.name FROM hands_players
INNER JOIN players ON hands_players.player_id=players.id INNER JOIN players ON hands_players.player_id=players.id
WHERE hand_id=%s""", (self.hands_id, )) WHERE hand_id=%s""", (self.hands_id, ))
self.player_names=self.db.cursor.fetchall() self.player_names=self.db.cursor.fetchall()
print "self.player_names:",self.player_names #print "self.player_names:",self.player_names
#end def table_viewer.read_names_clicked #end def table_viewer.read_names_clicked
def import_clicked(self, widget, data): def import_clicked(self, widget, data):
"""runs when user clicks import""" """runs when user clicks import"""
print "start of table_viewer.import_clicked" #print "start of table_viewer.import_clicked"
self.inputFile=self.filename_tbuffer.get_text(self.filename_tbuffer.get_start_iter(), self.filename_tbuffer.get_end_iter()) self.inputFile=self.filename_tbuffer.get_text(self.filename_tbuffer.get_start_iter(), self.filename_tbuffer.get_end_iter())
self.server=self.db.host self.server=self.db.host
@ -157,7 +157,7 @@ class table_viewer (threading.Thread):
def all_clicked(self, widget, data): def all_clicked(self, widget, data):
"""runs when user clicks all""" """runs when user clicks all"""
print "start of table_viewer.all_clicked" #print "start of table_viewer.all_clicked"
self.import_clicked(widget, data) self.import_clicked(widget, data)
self.read_names_clicked(widget, data) self.read_names_clicked(widget, data)
self.refresh_clicked(widget, data) self.refresh_clicked(widget, data)
@ -171,7 +171,7 @@ class table_viewer (threading.Thread):
def __init__(self, db, debug=True): def __init__(self, db, debug=True):
"""Constructor for table_viewer""" """Constructor for table_viewer"""
self.debug=debug self.debug=debug
if self.debug: print "start of table_viewer constructor" #print "start of table_viewer constructor"
self.db=db self.db=db
self.cursor=db.cursor self.cursor=db.cursor