From 30cd5791315cf6c1c9dc613137a0718ab5d713f4 Mon Sep 17 00:00:00 2001 From: Worros Date: Thu, 22 Jan 2009 01:40:05 +0900 Subject: [PATCH 1/4] Session detection code. Possible use in showing sessions graphically on the plot --- pyfpdb/GuiGraphViewer.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py index 8026a2c7..834817fb 100644 --- a/pyfpdb/GuiGraphViewer.py +++ b/pyfpdb/GuiGraphViewer.py @@ -20,7 +20,7 @@ import pygtk pygtk.require('2.0') import gtk import os -from time import time +from time import * #import pokereval try: @@ -366,3 +366,31 @@ class GuiGraphViewer (threading.Thread): self.leftPanelBox.show() self.graphBox.show() + +################################# + + self.db.cursor.execute("""select UNIX_TIMESTAMP(handStart) as time, id from Hands ORDER BY time""") + THRESHOLD = 1800 + hands = self.db.cursor.fetchall() + + times = map(lambda x:long(x[0]), hands) + handids = map(lambda x:int(x[1]), hands) + print "DEBUG: len(times) %s" %(len(times)) + diffs = diff(times) + print "DEBUG: len(diffs) %s" %(len(diffs)) + index = nonzero(diff(times) > THRESHOLD) + print "DEBUG: len(index[0]) %s" %(len(index[0])) + print "DEBUG: index %s" %(index) + print "DEBUG: index[0][0] %s" %(index[0][0]) + + total = 0 + + last_idx = 0 + for i in range(len(index[0])): + print "Hands in session %4s: %4s Start: %s End: %s Total: %s" %(i, index[0][i] - last_idx, strftime("%d/%m/%Y %H:%M", localtime(times[last_idx])), strftime("%d/%m/%Y %H:%M", localtime(times[index[0][i]])), times[index[0][i]] - times[last_idx]) + total = total + (index[0][i] - last_idx) + last_idx = index[0][i] + 1 + + print "Total: ", total +################################# + From 37a643f0549617a2e625f2e902e27c97abbd280e Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 26 Jan 2009 14:31:08 -0500 Subject: [PATCH 2/4] Kill aux windows when killing the HUD. --- pyfpdb/Hud.py | 5 +++++ pyfpdb/Mucked.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 612cd9de..157e6c42 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -167,6 +167,11 @@ class Hud: return # no killing self twice. for k in self.stat_windows: self.stat_windows[k].window.destroy() +# also kill any aux windows + for m in self.aux_windows: + m.destroy() + self.aux_windows.remove(m) + self.deleted = True self.main_window.disconnect(self.main_window.destroyhandler) # so we don't potentially infiniteloop in here, right self.main_window.destroy() diff --git a/pyfpdb/Mucked.py b/pyfpdb/Mucked.py index 5d4d8047..07021c7e 100755 --- a/pyfpdb/Mucked.py +++ b/pyfpdb/Mucked.py @@ -50,6 +50,9 @@ class Aux_Window: def update_gui(self): pass + def destroy(self): + self.container.destroy() + class Stud_mucked(Aux_Window): def __init__(self, container, hud, config, params): From 3261f285066c7edf2a74f8cf8f71ade1d344adbf Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 26 Jan 2009 18:31:04 -0500 Subject: [PATCH 3/4] Put a frame around each eb in the stat window-avoid tooltip annoyance. --- pyfpdb/Hud.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pyfpdb/Hud.py b/pyfpdb/Hud.py index 157e6c42..b1794c5d 100644 --- a/pyfpdb/Hud.py +++ b/pyfpdb/Hud.py @@ -365,23 +365,29 @@ class Stat_Window: self.grid = gtk.Table(rows = self.game.rows, columns = self.game.cols, homogeneous = False) self.window.add(self.grid) + self.window.modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) self.e_box = [] self.frame = [] self.label = [] for r in range(self.game.rows): + self.frame.append([]) self.e_box.append([]) self.label.append([]) for c in range(self.game.cols): + self.frame[r].append( gtk.Frame() ) self.e_box[r].append( gtk.EventBox() ) self.e_box[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) self.e_box[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor) Stats.do_tip(self.e_box[r][c], 'stuff') - self.grid.attach(self.e_box[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0) +# self.grid.attach(self.e_box[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0) + self.grid.attach(self.frame[r][c], c, c+1, r, r+1, xpadding = 0, ypadding = 0) + self.frame[r][c].add(self.e_box[r][c]) self.label[r].append( gtk.Label('xxx') ) + self.frame[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) self.label[r][c].modify_bg(gtk.STATE_NORMAL, parent.backgroundcolor) self.label[r][c].modify_fg(gtk.STATE_NORMAL, parent.foregroundcolor) From 64f1f17d7c25ef686c82fd0d4b5b7a6e2dc26054 Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 26 Jan 2009 20:02:01 -0500 Subject: [PATCH 4/4] Make player stats rows not expand = prettier. --- pyfpdb/GuiPlayerStats.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyfpdb/GuiPlayerStats.py b/pyfpdb/GuiPlayerStats.py index 1f1967e9..b2eb0108 100644 --- a/pyfpdb/GuiPlayerStats.py +++ b/pyfpdb/GuiPlayerStats.py @@ -67,7 +67,7 @@ class GuiPlayerStats (threading.Thread): for t in titles: l = gtk.Label(titles[col]) l.show() - self.stats_table.attach(l, col, col+1, row, row+1) + self.stats_table.attach(l, col, col+1, row, row+1, yoptions=gtk.SHRINK) col +=1 for row in range(rows-1): @@ -87,7 +87,7 @@ class GuiPlayerStats (threading.Thread): else: l.set_alignment(xalign=1.0, yalign=0.5) eb.add(l) - self.stats_table.attach(eb, col, col+1, row+1, row+2) + self.stats_table.attach(eb, col, col+1, row+1, row+2, yoptions=gtk.SHRINK) l.show() eb.show() self.fdb.db.commit()