From 009161d55b0a1b0c5b20fc714fe9167b5b9bc6f7 Mon Sep 17 00:00:00 2001 From: steffen123 Date: Sat, 20 Sep 2008 05:56:16 +0100 Subject: [PATCH] p87 - added profit graph kindly sent by Carl Gherardi, it's got fixed player id and is using the wrong table fields right now, will fix that tomorrow or so. note that this adds a new dependency, matplotlib, but I put it into a try except loop to avoid load failure added subfolder gentoo to packaging folder and added it to release script --- create-release.sh | 1 + docs/known-bugs-and-planned-features.txt | 4 +- .../{ => gentoo}/fpdb-1.0_alpha4_p86.ebuild | 0 pyfpdb/GuiGraphViewer.py | 93 +++++++++++++++++++ pyfpdb/fpdb.py | 14 ++- 5 files changed, 108 insertions(+), 4 deletions(-) rename packaging/{ => gentoo}/fpdb-1.0_alpha4_p86.ebuild (100%) create mode 100644 pyfpdb/GuiGraphViewer.py diff --git a/create-release.sh b/create-release.sh index 5f30ed25..975cffd3 100755 --- a/create-release.sh +++ b/create-release.sh @@ -21,6 +21,7 @@ rm pyfpdb/*.pyc mkdir fpdb-$1 cp -R docs fpdb-$1/ +cp -R packaging fpdb-$1/ cp -R pyfpdb fpdb-$1/ rm fpdb-$1/pyfpdb/HUD_config.* cp pyfpdb/HUD_config.xml.example fpdb-$1/pyfpdb/ diff --git a/docs/known-bugs-and-planned-features.txt b/docs/known-bugs-and-planned-features.txt index 86453039..5e768b49 100644 --- a/docs/known-bugs-and-planned-features.txt +++ b/docs/known-bugs-and-planned-features.txt @@ -1,11 +1,11 @@ -todolist (db=database, imp=importer, tv=tableviewer) Everything is subject to change and the order does not indicate priority. Patches for any of these or other features are very welcome, see readme-overview.txt for contacts. Please also see db-todo.txt alpha4 (release 25Sep-2Oct) ====== +graph: fixed player id and using the wrong table fields, update dependencies.txt newsletter&mailing list -update requirements to include new pgsql interface lib and rename to dependencies.txt +update requirements to include new pgsql interface lib ebuild: support pgsql fix HUD config location and update release script accordingly diff --git a/packaging/fpdb-1.0_alpha4_p86.ebuild b/packaging/gentoo/fpdb-1.0_alpha4_p86.ebuild similarity index 100% rename from packaging/fpdb-1.0_alpha4_p86.ebuild rename to packaging/gentoo/fpdb-1.0_alpha4_p86.ebuild diff --git a/pyfpdb/GuiGraphViewer.py b/pyfpdb/GuiGraphViewer.py new file mode 100644 index 00000000..ed673c75 --- /dev/null +++ b/pyfpdb/GuiGraphViewer.py @@ -0,0 +1,93 @@ +#!/usr/bin/python + +#Copyright 2008 Steffen Jobbagy-Felso +#This program is free software: you can redistribute it and/or modify +#it under the terms of the GNU Affero General Public License as published by +#the Free Software Foundation, version 3 of the License. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +#GNU General Public License for more details. +# +#You should have received a copy of the GNU Affero General Public License +#along with this program. If not, see . +#In the "official" distribution you can find the license in +#agpl-3.0.txt in the docs folder of the package. + +import threading +import pygtk +pygtk.require('2.0') +import gtk +import os + +try: + from matplotlib.figure import Figure + from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas + from matplotlib.backends.backend_gtkagg import NavigationToolbar2GTKAgg as NavigationToolbar + from numpy import arange, sin, pi +except: + print "Failed to load libs for graphing, graphing will not function. Please install numpy and matplotlib." + +try: + import MySQLdb +except: + diaSQLLibMissing = gtk.Dialog(title="Fatal Error - SQL interface library missing", parent=None, flags=0, buttons=(gtk.STOCK_QUIT,gtk.RESPONSE_OK)) + + label = gtk.Label("Please note that the table viewer only works with MySQL, if you use PostgreSQL this error is expected.") + diaSQLLibMissing.vbox.add(label) + label.show() + + label = gtk.Label("Since the HUD now runs on all supported plattforms I do not see any point in table viewer anymore, if you disagree please send a message to steffen@sycamoretest.info") + diaSQLLibMissing.vbox.add(label) + label.show() + + response = diaSQLLibMissing.run() + #sys.exit(1) + +import fpdb_import +import fpdb_db + +class GuiGraphViewer (threading.Thread): + def get_vbox(self): + """returns the vbox of this thread""" + return self.main_vbox + #end def get_vbox + + def __init__(self, db, settings, debug=True): + """Constructor for table_viewer""" + self.debug=debug + #print "start of table_viewer constructor" + self.db=db + self.cursor=db.cursor + self.settings=settings + + self.main_vbox = gtk.VBox(False, 0) + self.main_vbox.show() + + self.fig = Figure(figsize=(5,4), dpi=100) + self.ax = self.fig.add_subplot(111) +# x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] +# y = [2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0] + + self.db.reconnect() + self.cursor=self.db.cursor + + self.db.cursor.execute("SELECT handId, winnings FROM HandsPlayers WHERE playerId=1 ORDER BY handId") + + self.results = self.db.cursor.fetchall() + +# x=map(lambda x:float(x[0]),self.results) + y=map(lambda x:float(x[1]),self.results) + line = range(len(y)) + + for i in range(len(y)): + line[i] = y[i] + line[i-1] + + self.ax.plot(line,) + + self.canvas = FigureCanvas(self.fig) # a gtk.DrawingArea + self.main_vbox.pack_start(self.canvas) + self.canvas.show() + + #end of table_viewer.__init__ diff --git a/pyfpdb/fpdb.py b/pyfpdb/fpdb.py index 94e1165e..307c074d 100755 --- a/pyfpdb/fpdb.py +++ b/pyfpdb/fpdb.py @@ -27,6 +27,7 @@ import fpdb_simple import GuiBulkImport import GuiTableViewer import GuiAutoImport +import GuiGraphViewer class fpdb: def tab_clicked(self, widget, tab_name): @@ -399,6 +400,15 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") self.add_and_display_tab(tv_tab, "Table Viewer") #end def tab_table_viewer + def tabGraphViewer(self, widget, data): + """opens a graph viewer tab""" + #print "start of tabGraphViewer" + new_gv_thread=GuiGraphViewer.GuiGraphViewer(self.db, self.settings) + self.threads.append(new_gv_thread) + gv_tab=new_gv_thread.get_vbox() + self.add_and_display_tab(gv_tab, "Graphs") + #end def tabGraphViewer + def __init__(self): self.threads=[] self.db=None @@ -407,7 +417,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) - self.window.set_title("Free Poker DB - version: alpha4, p86") + self.window.set_title("Free Poker DB - version: alpha4+, p87 or higher") self.window.set_border_width(1) self.window.set_size_request(1020,400) self.window.set_resizable(True) @@ -425,7 +435,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt") ("/Import/Auto _Rating (todo)", "R", self.not_implemented, 0, None ), ("/_Viewers", None, None, 0, "" ), ("/_Viewers/_Auto Import and HUD", "A", self.tab_auto_import, 0, None ), - ("/Viewers/_Graphs (todo)", None, self.not_implemented, 0, None ), + ("/Viewers/_Graphs", None, self.tabGraphViewer, 0, None ), ("/Viewers/Hand _Replayer (todo)", None, self.not_implemented, 0, None ), ("/Viewers/Player _Details (todo)", None, self.not_implemented, 0, None ), ("/Viewers/_Player Stats (tabulated view) (todo)", None, self.not_implemented, 0, None ),