Stove: Mockup interface for a Stovelike EV calculator page

This commit is contained in:
Worros 2010-11-24 11:30:13 +08:00
parent aa31a4d67b
commit d3f07aae45
2 changed files with 215 additions and 0 deletions

205
pyfpdb/GuiStove.py Normal file
View File

@ -0,0 +1,205 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#Copyright 2008-2010 Steffen Schaumburg
#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 <http://www.gnu.org/licenses/>.
#In the "official" distribution you can find the license in agpl-3.0.txt.
import L10n
_ = L10n.get_translation()
import pygtk
pygtk.require('2.0')
import gtk
import os
import sys
import Charset
DEBUG = False
class GuiStove():
def __init__(self, config, parent, debug=True):
"""Constructor for GraphViewer"""
self.conf = config
self.parent = parent
self.mainHBox = gtk.HBox(False, 0)
# hierarchy: self.mainHBox / self.notebook
self.notebook = gtk.Notebook()
self.notebook.set_tab_pos(gtk.POS_TOP)
self.notebook.set_show_tabs(True)
self.notebook.set_show_border(True)
self.createFlopTab()
#self.createStudTab()
#self.createDrawTab()
self.mainHBox.add(self.notebook)
self.mainHBox.show_all()
if DEBUG == False:
warning_string = """
Stove is a GUI mockup of a EV calculation page, and completely non functional.
Unless you are interested in developing this feature, please ignore this page.
If you are interested in developing the code further see GuiStove.py and Stove.py
Thankyou
"""
self.warning_box(warning_string)
def warning_box(self, str, diatitle=_("FPDB WARNING")):
diaWarning = gtk.Dialog(title=diatitle, parent=self.parent, flags=gtk.DIALOG_DESTROY_WITH_PARENT, buttons=(gtk.STOCK_OK,gtk.RESPONSE_OK))
label = gtk.Label(str)
diaWarning.vbox.add(label)
label.show()
response = diaWarning.run()
diaWarning.destroy()
return response
def get_active_text(combobox):
model = combobox.get_model()
active = combobox.get_active()
if active < 0:
return None
return model[active][0]
def create_combo_box(self, strings):
combobox = gtk.combo_box_new_text()
for label in strings:
combobox.append_text(label)
combobox.set_active(0)
return combobox
def createFlopTab(self):
# hierarchy: hbox / ddbox / ddhbox / Label + flop_games_cb | label + players_cb
# / gamehbox / in_frame / table /
# / out_frame
tab_title = "Flop"
label = gtk.Label(tab_title)
ddbox = gtk.VBox(False, 0)
self.notebook.append_page(ddbox, label)
ddhbox = gtk.HBox(False, 0)
gamehbox = gtk.HBox(False, 0)
ddbox.add(ddhbox)
ddbox.add(gamehbox)
# Combo boxes in the top row
games = [ "Holdem", "Omaha", "Omaha 8", ]
players = [ "2", "3", "4", "5", "6", "7", "8", "9", "10" ]
flop_games_cb = self.create_combo_box(games)
players_cb = self.create_combo_box(players)
label = gtk.Label("Gametype:")
ddhbox.add(label)
ddhbox.add(flop_games_cb)
label = gtk.Label("Players:")
ddhbox.add(label)
ddhbox.add(players_cb)
# Frames for Stove input and output
in_frame = gtk.Frame("Input:")
out_frame = gtk.Frame("Output:")
gamehbox.add(in_frame)
gamehbox.add(out_frame)
outstring = """
No board given. Using Monte-Carlo simulation...
Enumerated 2053443 possible plays.
Your hand: (Ad Ac)
Against the range: {
AhAd, AhAs, AdAs, KhKd, KhKs,
KhKc, KdKs, KdKc, KsKc, QhQd,
QhQs, QhQc, QdQs, QdQc, QsQc,
JhJd, JhJs, JhJc, JdJs, JdJc,
JsJc
}
Win Lose Tie
69.91% 15.83% 14.26%
"""
label = gtk.Label(outstring)
out_frame.add(label)
# Input Frame
table = gtk.Table(4, 4, True)
label = gtk.Label("Board:")
board = gtk.Entry()
#board.connect("changed", self._some_function, arg)
btn1 = gtk.Button()
btn1.set_image(gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
#btn.connect('clicked', self._some_function, arg)
table.attach(label, 0, 1, 0, 1, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK)
table.attach(board, 1, 2, 0, 1, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK)
table.attach(btn1, 2, 3, 0, 1, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK)
label = gtk.Label("Player1:")
board = gtk.Entry()
#board.connect("changed", self._some_function, arg)
btn2 = gtk.Button()
btn2.set_image(gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
#btn.connect('clicked', self._some_function, arg)
btn3 = gtk.Button()
btn3.set_image(gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
#btn.connect('clicked', self._some_function, arg)
table.attach(label, 0, 1, 1, 2, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK)
table.attach(board, 1, 2, 1, 2, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK)
table.attach(btn2, 2, 3, 1, 2, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK)
table.attach(btn3, 3, 4, 1, 2, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK)
label = gtk.Label("Player2:")
board = gtk.Entry()
#board.connect("changed", self._some_function, arg)
btn4 = gtk.Button()
btn4.set_image(gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
#btn.connect('clicked', self._some_function, arg)
btn5 = gtk.Button()
btn5.set_image(gtk.image_new_from_stock(gtk.STOCK_INDEX, gtk.ICON_SIZE_BUTTON))
#btn.connect('clicked', self._some_function, arg)
table.attach(label, 0, 1, 2, 3, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK)
table.attach(board, 1, 2, 2, 3, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK)
table.attach(btn4, 2, 3, 2, 3, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK)
table.attach(btn5, 3, 4, 2, 3, xoptions=gtk.SHRINK, yoptions=gtk.SHRINK)
#table.attach(label, i, i+1, j, j+1,)
in_frame.add(table)
def get_vbox(self):
"""returns the vbox of this thread"""
return self.mainHBox
#end def get_vbox

View File

@ -116,6 +116,7 @@ import GuiAutoImport
import GuiGraphViewer import GuiGraphViewer
import GuiTourneyGraphViewer import GuiTourneyGraphViewer
import GuiSessionViewer import GuiSessionViewer
import GuiStove
import SQL import SQL
import Database import Database
import Configuration import Configuration
@ -778,6 +779,7 @@ class fpdb:
<menuitem action="tourneyviewer"/> <menuitem action="tourneyviewer"/>
<menuitem action="posnstats"/> <menuitem action="posnstats"/>
<menuitem action="sessionstats"/> <menuitem action="sessionstats"/>
<menuitem action="stove"/>
</menu> </menu>
<menu action="database"> <menu action="database">
<menuitem action="maintaindbs"/> <menuitem action="maintaindbs"/>
@ -814,6 +816,7 @@ class fpdb:
('hudConfigurator', None, _('_HUD Configurator'), _('<control>H'), 'HUD Configurator', self.diaHudConfigurator), ('hudConfigurator', None, _('_HUD Configurator'), _('<control>H'), 'HUD Configurator', self.diaHudConfigurator),
('graphs', None, _('_Graphs'), _('<control>G'), 'Graphs', self.tabGraphViewer), ('graphs', None, _('_Graphs'), _('<control>G'), 'Graphs', self.tabGraphViewer),
('tourneygraphs', None, _('Tourney Graphs'), None, 'TourneyGraphs', self.tabTourneyGraphViewer), ('tourneygraphs', None, _('Tourney Graphs'), None, 'TourneyGraphs', self.tabTourneyGraphViewer),
('stove', None, _('Stove'), None, 'Stove', self.tabStove),
('ringplayerstats', None, _('Ring _Player Stats (tabulated view, not on pgsql)'), _('<control>P'), 'Ring Player Stats (tabulated view, not on pgsql)', self.tab_ring_player_stats), ('ringplayerstats', None, _('Ring _Player Stats (tabulated view, not on pgsql)'), _('<control>P'), 'Ring Player Stats (tabulated view, not on pgsql)', self.tab_ring_player_stats),
('tourneyplayerstats', None, _('_Tourney Stats (tabulated view, not on pgsql)'), _('<control>T'), 'Tourney Stats (tabulated view, not on pgsql)', self.tab_tourney_player_stats), ('tourneyplayerstats', None, _('_Tourney Stats (tabulated view, not on pgsql)'), _('<control>T'), 'Tourney Stats (tabulated view, not on pgsql)', self.tab_tourney_player_stats),
('tourneyviewer', None, _('Tourney _Viewer'), None, 'Tourney Viewer)', self.tab_tourney_viewer_stats), ('tourneyviewer', None, _('Tourney _Viewer'), None, 'Tourney Viewer)', self.tab_tourney_viewer_stats),
@ -1078,6 +1081,13 @@ You can find the full license texts in agpl-3.0.txt, gpl-2.0.txt, gpl-3.0.txt an
gv_tab = new_gv_thread.get_vbox() gv_tab = new_gv_thread.get_vbox()
self.add_and_display_tab(gv_tab, _("Tourney Graphs")) self.add_and_display_tab(gv_tab, _("Tourney Graphs"))
def tabStove(self, widget, data=None):
"""opens a tab for bulk importing tournament summaries"""
thread = GuiStove.GuiStove(self.config, self.window)
self.threads.append(thread)
tab = thread.get_vbox()
self.add_and_display_tab(tab, _("Stove"))
def __init__(self): def __init__(self):
# no more than 1 process can this lock at a time: # no more than 1 process can this lock at a time:
self.lock = interlocks.InterProcessLock(name="fpdb_global_lock") self.lock = interlocks.InterProcessLock(name="fpdb_global_lock")