p88 - graph viewer now takes player name from GUI rather than hardcoded player id

This commit is contained in:
steffen123 2008-09-21 14:24:43 +01:00
parent 009161d55b
commit 8117193b4f
3 changed files with 56 additions and 48 deletions

View File

@ -3,7 +3,8 @@ Please also see db-todo.txt
alpha4 (release 25Sep-2Oct) alpha4 (release 25Sep-2Oct)
====== ======
graph: fixed player id and using the wrong table fields, update dependencies.txt graph: using the wrong table fields, update dependencies.txt, select site from drop down
check we're reading mucked cards from PS
newsletter&mailing list newsletter&mailing list
update requirements to include new pgsql interface lib update requirements to include new pgsql interface lib
ebuild: support pgsql ebuild: support pgsql

View File

@ -29,31 +29,44 @@ try:
except: except:
print "Failed to load libs for graphing, graphing will not function. Please install numpy and matplotlib." 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_import
import fpdb_db import fpdb_db
class GuiGraphViewer (threading.Thread): class GuiGraphViewer (threading.Thread):
def get_vbox(self): def get_vbox(self):
"""returns the vbox of this thread""" """returns the vbox of this thread"""
return self.main_vbox return self.mainVBox
#end def get_vbox #end def get_vbox
def showClicked(self, widget, data):
name=self.nameTBuffer.get_text(self.nameTBuffer.get_start_iter(), self.nameTBuffer.get_end_iter())
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.execute("SELECT handId, winnings FROM HandsPlayers INNER JOIN Players ON HandsPlayers.playerId = Players.id WHERE Players.name = %s ORDER BY handId", (name, ))
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.mainVBox.pack_start(self.canvas)
self.canvas.show()
def __init__(self, db, settings, debug=True): def __init__(self, db, settings, debug=True):
"""Constructor for table_viewer""" """Constructor for table_viewer"""
self.debug=debug self.debug=debug
@ -62,32 +75,26 @@ class GuiGraphViewer (threading.Thread):
self.cursor=db.cursor self.cursor=db.cursor
self.settings=settings self.settings=settings
self.main_vbox = gtk.VBox(False, 0) self.mainVBox = gtk.VBox(False, 0)
self.main_vbox.show() self.mainVBox.show()
self.fig = Figure(figsize=(5,4), dpi=100) self.settingsHBox = gtk.HBox(False, 0)
self.ax = self.fig.add_subplot(111) self.mainVBox.pack_start(self.settingsHBox, False, True, 0)
# x = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] self.settingsHBox.show()
# 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.nameLabel = gtk.Label("Name of the player to be graphed:")
self.cursor=self.db.cursor self.settingsHBox.pack_start(self.nameLabel)
self.nameLabel.show()
self.db.cursor.execute("SELECT handId, winnings FROM HandsPlayers WHERE playerId=1 ORDER BY handId") self.nameTBuffer=gtk.TextBuffer()
self.nameTBuffer.set_text("name")
self.nameTView=gtk.TextView(self.nameTBuffer)
self.settingsHBox.pack_start(self.nameTView)
self.nameTView.show()
self.results = self.db.cursor.fetchall() self.showButton=gtk.Button("Show/Refresh")
self.showButton.connect("clicked", self.showClicked, "show clicked")
self.settingsHBox.add(self.showButton)
self.showButton.show()
# x=map(lambda x:float(x[0]),self.results) #end of GuiGraphViewer.__init__
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__

View File

@ -417,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 = 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 - version: alpha4+, p87 or higher") self.window.set_title("Free Poker DB - version: alpha4+, p88 or higher")
self.window.set_border_width(1) self.window.set_border_width(1)
self.window.set_size_request(1020,400) self.window.set_size_request(1020,400)
self.window.set_resizable(True) self.window.set_resizable(True)
@ -435,7 +435,7 @@ This program is licensed under the AGPL3, see docs"""+os.sep+"agpl-3.0.txt")
("/Import/Auto _Rating (todo)", "<control>R", self.not_implemented, 0, None ), ("/Import/Auto _Rating (todo)", "<control>R", self.not_implemented, 0, None ),
("/_Viewers", None, None, 0, "<Branch>" ), ("/_Viewers", None, None, 0, "<Branch>" ),
("/_Viewers/_Auto Import and HUD", "<control>A", self.tab_auto_import, 0, None ), ("/_Viewers/_Auto Import and HUD", "<control>A", self.tab_auto_import, 0, None ),
("/Viewers/_Graphs", None, self.tabGraphViewer, 0, None ), ("/Viewers/_Graphs", "<control>G", self.tabGraphViewer, 0, None ),
("/Viewers/Hand _Replayer (todo)", None, self.not_implemented, 0, None ), ("/Viewers/Hand _Replayer (todo)", None, self.not_implemented, 0, None ),
("/Viewers/Player _Details (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 ), ("/Viewers/_Player Stats (tabulated view) (todo)", None, self.not_implemented, 0, None ),