예제 #1
0
파일: tkstats.py 프로젝트: tuchang/PySolFC
    def _updateTop(self, gameid):
        s = self.app.stats.games_stats
        cond = (self.player not in s or gameid not in s[self.player]
                or not s[self.player][gameid].time_result.top)
        if cond:
            return

        s = s[self.player][gameid]

        label = self.widgets_tree.get_widget('playing_time_minimum_label')
        label.set_text(format_time(s.time_result.min))
        label = self.widgets_tree.get_widget('playing_time_maximum_label')
        label.set_text(format_time(s.time_result.max))
        label = self.widgets_tree.get_widget('playing_time_average_label')
        label.set_text(format_time(s.time_result.average))

        label = self.widgets_tree.get_widget('moves_minimum_label')
        label.set_text(str(s.moves_result.min))
        label = self.widgets_tree.get_widget('moves_maximum_label')
        label.set_text(str(s.moves_result.max))
        label = self.widgets_tree.get_widget('moves_average_label')
        label.set_text(str(round(s.moves_result.average, 2)))

        label = self.widgets_tree.get_widget('total_moves_minimum_label')
        label.set_text(str(s.total_moves_result.min))
        label = self.widgets_tree.get_widget('total_moves_maximum_label')
        label.set_text(str(s.total_moves_result.max))
        label = self.widgets_tree.get_widget('total_moves_average_label')
        label.set_text(str(round(s.total_moves_result.average, 2)))

        for n, ss in (('top_10_time_treeview', s.time_result.top),
                      ('top_10_moves_treeview',
                       s.moves_result.top), ('top_10_total_moves_treeview',
                                             s.total_moves_result.top)):
            self._updateTopList(n, ss)
예제 #2
0
파일: tkstats.py 프로젝트: iske/PySolFC
    def _updateTop(self, gameid):
        if (self.player not in self.app.stats.games_stats or
            gameid not in self.app.stats.games_stats[self.player] or
            not self.app.stats.games_stats[self.player][gameid].time_result.top):
            return

        s = self.app.stats.games_stats[self.player][gameid]

        label = self.widgets_tree.get_widget('playing_time_minimum_label')
        label.set_text(format_time(s.time_result.min))
        label = self.widgets_tree.get_widget('playing_time_maximum_label')
        label.set_text(format_time(s.time_result.max))
        label = self.widgets_tree.get_widget('playing_time_average_label')
        label.set_text(format_time(s.time_result.average))

        label = self.widgets_tree.get_widget('moves_minimum_label')
        label.set_text(str(s.moves_result.min))
        label = self.widgets_tree.get_widget('moves_maximum_label')
        label.set_text(str(s.moves_result.max))
        label = self.widgets_tree.get_widget('moves_average_label')
        label.set_text(str(round(s.moves_result.average, 2)))

        label = self.widgets_tree.get_widget('total_moves_minimum_label')
        label.set_text(str(s.total_moves_result.min))
        label = self.widgets_tree.get_widget('total_moves_maximum_label')
        label.set_text(str(s.total_moves_result.max))
        label = self.widgets_tree.get_widget('total_moves_average_label')
        label.set_text(str(round(s.total_moves_result.average, 2)))

        for n, ss in (
            ('top_10_time_treeview',        s.time_result.top),
            ('top_10_moves_treeview',       s.moves_result.top),
            ('top_10_total_moves_treeview', s.total_moves_result.top)):
            self._updateTopList(n, ss)
예제 #3
0
파일: stats.py 프로젝트: iske/PySolFC
 def getStatResults(self, player, sort_by='name'):
     app = self.app
     #
     sort_functions = {
         'name':    app.getGamesIdSortedByName,
         'played':  app.getGamesIdSortedByPlayed,
         'won':     app.getGamesIdSortedByWon,
         'lost':    app.getGamesIdSortedByLost,
         'time':    app.getGamesIdSortedByPlayingTime,
         'moves':   app.getGamesIdSortedByMoves,
         'percent': app.getGamesIdSortedByPercent,
         }
     sort_func = sort_functions[sort_by]
     g = sort_func(player=player)
     twon, tlost, tgames, ttime, tmoves = 0, 0, 0, 0, 0
     for id in g:
         won, lost, time, moves = app.stats.getFullStats(player, id)
         if won > 0 or lost > 0 or id == app.game.id:
             # yield only played games
             name = app.getGameTitleName(id)
             twon, tlost = twon + won, tlost + lost
             ttime, tmoves = ttime+time, tmoves+moves
             if won + lost > 0:
                 perc = "%.1f" % (100.0 * won / (won + lost))
             else:
                 perc = "0.0"
             t = format_time(time)
             m = str(round(moves, 1))
             yield [name, won+lost, won, lost, t, m, perc, id]
             tgames += 1
     # summary
     won, lost = twon, tlost
     if won + lost > 0:
         if won > 0:
             time = format_time(ttime/tgames)
             moves = round(tmoves/tgames, 1)
         else:
             time = format_time(0)
             moves = 0
         perc = "%.1f" % (100.0*won/(won+lost))
     else:
         perc = "0.0"
     self.total_games = len(g)
     self.played_games = tgames
     self.won_games = won
     self.lost_games = lost
     self.avrg_time = time
     self.avrg_moves = moves
     self.percent = perc
예제 #4
0
파일: stats.py 프로젝트: yegle/PySolFC
 def getStatResults(self, player, sort_by='name'):
     app = self.app
     #
     sort_functions = {
         'name': app.getGamesIdSortedByName,
         'played': app.getGamesIdSortedByPlayed,
         'won': app.getGamesIdSortedByWon,
         'lost': app.getGamesIdSortedByLost,
         'time': app.getGamesIdSortedByPlayingTime,
         'moves': app.getGamesIdSortedByMoves,
         'percent': app.getGamesIdSortedByPercent,
     }
     sort_func = sort_functions[sort_by]
     g = sort_func(player=player)
     twon, tlost, tgames, ttime, tmoves = 0, 0, 0, 0, 0
     for id in g:
         won, lost, time, moves = app.stats.getFullStats(player, id)
         if won > 0 or lost > 0 or id == app.game.id:
             # yield only played games
             name = app.getGameTitleName(id)
             twon, tlost = twon + won, tlost + lost
             ttime, tmoves = ttime + time, tmoves + moves
             if won + lost > 0:
                 perc = "%.1f" % (100.0 * won / (won + lost))
             else:
                 perc = "0.0"
             t = format_time(time)
             m = str(round(moves, 1))
             yield [name, won + lost, won, lost, t, m, perc, id]
             tgames += 1
     # summary
     won, lost = twon, tlost
     if won + lost > 0:
         if won > 0:
             time = format_time(ttime / tgames)
             moves = round(tmoves / tgames, 1)
         else:
             time = format_time(0)
             moves = 0
         perc = "%.1f" % (100.0 * won / (won + lost))
     else:
         perc = "0.0"
     self.total_games = len(g)
     self.played_games = tgames
     self.won_games = won
     self.lost_games = lost
     self.avrg_time = time
     self.avrg_moves = moves
     self.percent = perc
예제 #5
0
    def __init__(self, parent, title, top, **kw):
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)

        cnf = {
            'master': top_frame,
            'highlightthickness': 1,
            'highlightbackground': 'black',
        }
        frame = tkinter.Frame(**cnf)
        frame.pack(expand=True, fill='both', padx=10, pady=10)
        frame.columnconfigure(0, weight=1)
        cnf['master'] = frame
        cnf['text'] = _('N')
        label = tkinter.Label(**cnf)
        label.grid(row=0, column=0, sticky='ew')
        cnf['text'] = _('Game number')
        label = tkinter.Label(**cnf)
        label.grid(row=0, column=1, sticky='ew')
        cnf['text'] = _('Started at')
        label = tkinter.Label(**cnf)
        label.grid(row=0, column=2, sticky='ew')
        cnf['text'] = _('Result')
        label = tkinter.Label(**cnf)
        label.grid(row=0, column=3, sticky='ew')

        row = 1
        for i in top:
            # N
            cnf['text'] = str(row)
            label = tkinter.Label(**cnf)
            label.grid(row=row, column=0, sticky='ew')
            # Game number
            cnf['text'] = '#' + str(i.game_number)
            label = tkinter.Label(**cnf)
            label.grid(row=row, column=1, sticky='ew')
            # Start time
            t = time.strftime('%Y-%m-%d %H:%M',
                              time.localtime(i.game_start_time))
            cnf['text'] = t
            label = tkinter.Label(**cnf)
            label.grid(row=row, column=2, sticky='ew')
            # Result
            if isinstance(i.value, float):
                # time
                s = format_time(i.value)
            else:
                # moves
                s = str(i.value)
            cnf['text'] = s
            label = tkinter.Label(**cnf)
            label.grid(row=row, column=3, sticky='ew')
            row += 1

        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
예제 #6
0
파일: tkstats.py 프로젝트: shlomif/PySolFC
    def __init__(self, parent, title, top, **kw):
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)

        cnf = {'master': top_frame,
               'highlightthickness': 1,
               'highlightbackground': 'black',
               }
        frame = tkinter.Frame(**cnf)
        frame.pack(expand=True, fill='both', padx=10, pady=10)
        frame.columnconfigure(0, weight=1)
        cnf['master'] = frame
        cnf['text'] = _('N')
        label = tkinter.Label(**cnf)
        label.grid(row=0, column=0, sticky='ew')
        cnf['text'] = _('Game number')
        label = tkinter.Label(**cnf)
        label.grid(row=0, column=1, sticky='ew')
        cnf['text'] = _('Started at')
        label = tkinter.Label(**cnf)
        label.grid(row=0, column=2, sticky='ew')
        cnf['text'] = _('Result')
        label = tkinter.Label(**cnf)
        label.grid(row=0, column=3, sticky='ew')

        row = 1
        for i in top:
            # N
            cnf['text'] = str(row)
            label = tkinter.Label(**cnf)
            label.grid(row=row, column=0, sticky='ew')
            # Game number
            cnf['text'] = '#'+str(i.game_number)
            label = tkinter.Label(**cnf)
            label.grid(row=row, column=1, sticky='ew')
            # Start time
            t = time.strftime(
                '%Y-%m-%d %H:%M', time.localtime(i.game_start_time))
            cnf['text'] = t
            label = tkinter.Label(**cnf)
            label.grid(row=row, column=2, sticky='ew')
            # Result
            if isinstance(i.value, float):
                # time
                s = format_time(i.value)
            else:
                # moves
                s = str(i.value)
            cnf['text'] = s
            label = tkinter.Label(**cnf)
            label.grid(row=row, column=3, sticky='ew')
            row += 1

        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
예제 #7
0
 def updateInfo(self, gameid):
     gi = self.app.gdb.get(gameid)
     # info
     name = gi.name
     altnames = '\n'.join(gi.altnames)
     category = _(CSI.TYPE[gi.category])
     type = ''
     if gi.si.game_type in GI.TYPE_NAMES:
         type = _(GI.TYPE_NAMES[gi.si.game_type])
     sl = {
         GI.SL_LUCK: _('Luck only'),
         GI.SL_MOSTLY_LUCK: _('Mostly luck'),
         GI.SL_BALANCED: _('Balanced'),
         GI.SL_MOSTLY_SKILL: _('Mostly skill'),
         GI.SL_SKILL: _('Skill only'),
     }
     skill_level = sl.get(gi.skill_level)
     if gi.redeals == -2:
         redeals = _('Variable')
     elif gi.redeals == -1:
         redeals = _('Unlimited')
     else:
         redeals = str(gi.redeals)
     # stats
     won, lost, time, moves = self.app.stats.getFullStats(
         self.app.opt.player, gameid)
     if won + lost > 0:
         percent = "%.1f" % (100.0 * won / (won + lost))
     else:
         percent = "0.0"
     time = format_time(time)
     moves = str(round(moves, 1))
     for n, t in (
         ('name', name),
         ('altnames', altnames),
         ('category', category),
         ('type', type),
         ('skill_level', skill_level),
         ('decks', gi.decks),
         ('redeals', redeals),
         ('played', won + lost),
         ('won', won),
         ('lost', lost),
         ('time', time),
         ('moves', moves),
         ('percent', percent),
     ):
         title_label, text_label = self.info_labels[n]
         if t in ('', None):
             title_label.grid_remove()
             text_label.grid_remove()
         else:
             title_label.grid()
             text_label.grid()
         text_label.config(text=t)
예제 #8
0
 def updateInfo(self, gameid):
     gi = self.app.gdb.get(gameid)
     # info
     name = gi.name
     altnames = '\n'.join(gi.altnames)
     category = _(CSI.TYPE[gi.category])
     type = ''
     if gi.si.game_type in GI.TYPE_NAMES:
         type = _(GI.TYPE_NAMES[gi.si.game_type])
     sl = {
         GI.SL_LUCK:         _('Luck only'),
         GI.SL_MOSTLY_LUCK:  _('Mostly luck'),
         GI.SL_BALANCED:     _('Balanced'),
         GI.SL_MOSTLY_SKILL: _('Mostly skill'),
         GI.SL_SKILL:        _('Skill only'),
         }
     skill_level = sl.get(gi.skill_level)
     if gi.redeals == -2:
         redeals = _('variable')
     elif gi.redeals == -1:
         redeals = _('unlimited')
     else:
         redeals = str(gi.redeals)
     # stats
     won, lost, time, moves = self.app.stats.getFullStats(
         self.app.opt.player, gameid)
     if won+lost > 0:
         percent = "%.1f" % (100.0*won/(won+lost))
     else:
         percent = "0.0"
     time = format_time(time)
     moves = str(round(moves, 1))
     for n, t in (
         ('name',        name),
         ('altnames',    altnames),
         ('category',    category),
         ('type',        type),
         ('skill_level', skill_level),
         ('decks',       gi.decks),
         ('redeals',     redeals),
         ('played',      won+lost),
         ('won',         won),
         ('lost',        lost),
         ('time',        time),
         ('moves',       moves),
         ('percent',     percent),
             ):
         title_label, text_label = self.info_labels[n]
         if t in ('', None):
             title_label.grid_remove()
             text_label.grid_remove()
         else:
             title_label.grid()
             text_label.grid()
         text_label.config(text=t)
예제 #9
0
 def updateInfo(self, gameid):
     gi = self.app.gdb.get(gameid)
     # info
     name = gi.name
     altnames = "\n".join(gi.altnames)
     category = _(CSI.TYPE[gi.category])
     type = ""
     if gi.si.game_type in GI.TYPE_NAMES:
         type = _(GI.TYPE_NAMES[gi.si.game_type])
     sl = {
         GI.SL_LUCK: _("Luck only"),
         GI.SL_MOSTLY_LUCK: _("Mostly luck"),
         GI.SL_BALANCED: _("Balanced"),
         GI.SL_MOSTLY_SKILL: _("Mostly skill"),
         GI.SL_SKILL: _("Skill only"),
     }
     skill_level = sl.get(gi.skill_level)
     if gi.redeals == -2:
         redeals = _("variable")
     elif gi.redeals == -1:
         redeals = _("unlimited")
     else:
         redeals = str(gi.redeals)
     # stats
     won, lost, time, moves = self.app.stats.getFullStats(self.app.opt.player, gameid)
     if won + lost > 0:
         percent = "%.1f" % (100.0 * won / (won + lost))
     else:
         percent = "0.0"
     time = format_time(time)
     moves = str(round(moves, 1))
     for n, t in (
         ("name", name),
         ("altnames", altnames),
         ("category", category),
         ("type", type),
         ("skill_level", skill_level),
         ("decks", gi.decks),
         ("redeals", redeals),
         ("played", won + lost),
         ("won", won),
         ("lost", lost),
         ("time", time),
         ("moves", moves),
         ("percent", percent),
     ):
         title_label, text_label = self.info_labels[n]
         if t in ("", None):
             title_label.grid_remove()
             text_label.grid_remove()
         else:
             title_label.grid()
             text_label.grid()
         text_label.config(text=t)
예제 #10
0
 def _updateTopList(self, tv_name, top):
     treeview = self.widgets_tree.get_widget(tv_name)
     store = treeview.get_model()
     store.clear()
     row = 1
     for i in top:
         t = time.strftime("%Y-%m-%d %H:%M", time.localtime(i.game_start_time))
         if isinstance(i.value, float):
             # time
             r = format_time(i.value)
         else:
             # moves
             r = str(i.value)
         iter = store.append(None)
         store.set(iter, 0, row, 1, i.game_number, 2, t, 3, r)
         row += 1
예제 #11
0
 def _updateTopList(self, tv_name, top):
     treeview = self.widgets_tree.get_widget(tv_name)
     store = treeview.get_model()
     store.clear()
     row = 1
     for i in top:
         t = time.strftime('%Y-%m-%d %H:%M',
                           time.localtime(i.game_start_time))
         if isinstance(i.value, float):
             # time
             r = format_time(i.value)
         else:
             # moves
             r = str(i.value)
         iter = store.append(None)
         store.set(iter, 0, row, 1, i.game_number, 2, t, 3, r)
         row += 1
예제 #12
0
    def createTopFrame(self, frame, player, gameid):
        app = self.app

        cond = (player not in app.stats.games_stats or
                gameid not in app.stats.games_stats[player] or
                not app.stats.games_stats[player][gameid].time_result.top)
        if cond:
            return False

        ttk.Label(frame, text=_('Minimum')
                  ).grid(row=0, column=1, padx=5, pady=5)
        ttk.Label(frame, text=_('Maximum')
                  ).grid(row=0, column=2, padx=5, pady=5)
        ttk.Label(frame, text=_('Average')
                  ).grid(row=0, column=3, padx=5, pady=5)
        # ttk.Label(frame, text=_('Total')).grid(row=0, column=4)

        s = app.stats.games_stats[player][gameid]

        row = 1
        ll = [
            (_('Playing time:'),
             format_time(s.time_result.min),
             format_time(s.time_result.max),
             format_time(s.time_result.average),
             format_time(s.time_result.total),
             s.time_result.top,
             ),
            (_('Moves:'),
             s.moves_result.min,
             s.moves_result.max,
             round(s.moves_result.average, 2),
             s.moves_result.total,
             s.moves_result.top,
             ),
            (_('Total moves:'),
             s.total_moves_result.min,
             s.total_moves_result.max,
             round(s.total_moves_result.average, 2),
             s.total_moves_result.total,
             s.total_moves_result.top,
             ),
            ]
        #  if s.score_result.min:
        #      ll.append(('Score:',
        #                 s.score_result.min,
        #                 s.score_result.max,
        #                 round(s.score_result.average, 2),
        #                 s.score_result.top,
        #                 ))
        #  if s.score_casino_result.min:
        #      ll.append(('Casino Score:',
        #                 s.score_casino_result.min,
        #                 s.score_casino_result.max,
        #                 round(s.score_casino_result.average, 2), ))
        for label, min, max, avr, tot, top in ll:
            ttk.Label(frame, text=label
                      ).grid(row=row, column=0, padx=5, pady=5)
            ttk.Label(frame, text=str(min)
                      ).grid(row=row, column=1, padx=5, pady=5)
            ttk.Label(frame, text=str(max)
                      ).grid(row=row, column=2, padx=5, pady=5)
            ttk.Label(frame, text=str(avr)
                      ).grid(row=row, column=3, padx=5, pady=5)
            # ttk.Label(frame, text=str(tot)).grid(row=row, column=4)

            def command(gameid=gameid, top=top):
                self.showTop(gameid, top)
            b = ttk.Button(frame, text=TOP_TITLE+' ...',
                           width=10, command=command)
            b.grid(row=row, column=5)
            row += 1
        return True
예제 #13
0
    def __init__(self, parent, title, app, gameid, top, **kw):
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)

        cnf = {'master': top_frame,
               'padding': (4, 1),
               }
        frame = ttk.Frame(**cnf)
        frame.pack(expand=True, fill='both', padx=10, pady=10)
        frame.columnconfigure(0, weight=1)
        cnf['master'] = frame
        cnf['text'] = _('N')
        label = ttk.Label(**cnf)
        label.grid(row=0, column=0, sticky='ew')
        if gameid == 'all':
            cnf['text'] = _('Game')
            label = ttk.Label(**cnf)
            label.grid(row=0, column=1, sticky='ew')
        cnf['text'] = _('Game number')
        label = ttk.Label(**cnf)
        label.grid(row=0, column=2, sticky='ew')
        cnf['text'] = _('Started at')
        label = ttk.Label(**cnf)
        label.grid(row=0, column=3, sticky='ew')
        cnf['text'] = _('Result')
        label = ttk.Label(**cnf)
        label.grid(row=0, column=4, sticky='ew')

        row = 1
        for i in top:
            # N
            cnf['text'] = str(row)
            label = ttk.Label(**cnf)
            label.grid(row=row, column=0, sticky='ew')
            if gameid == 'all':
                name = app.getGameTitleName(i.gameid)
                if name is None:
                    name = _("** UNKNOWN %d **") % i.gameid
                cnf['text'] = name
                label = ttk.Label(**cnf)
                label.grid(row=row, column=1, sticky='ew')
            # Game number
            cnf['text'] = '#'+str(i.game_number)
            label = ttk.Label(**cnf)
            label.grid(row=row, column=2, sticky='ew')
            # Start time
            t = time.strftime(
                '%Y-%m-%d %H:%M', time.localtime(i.game_start_time))
            cnf['text'] = t
            label = ttk.Label(**cnf)
            label.grid(row=row, column=3, sticky='ew')
            # Result
            if isinstance(i.value, float):
                # time
                s = format_time(i.value)
            else:
                # moves
                s = str(i.value)
            cnf['text'] = s
            label = ttk.Label(**cnf)
            label.grid(row=row, column=4, sticky='ew')
            row += 1

        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
예제 #14
0
    def __init__(self, parent, title, app, player, gameid, **kw):
        self.app = app
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)

        frame = Tkinter.Frame(top_frame)
        frame.pack(expand=True, fill='both', padx=10, pady=10)
        frame.columnconfigure(0, weight=1)

        if (player in app.stats.games_stats and
            gameid in app.stats.games_stats[player] and
                app.stats.games_stats[player][gameid].time_result.top):

            Tkinter.Label(frame, text=_('Minimum')).grid(row=0, column=1)
            Tkinter.Label(frame, text=_('Maximum')).grid(row=0, column=2)
            Tkinter.Label(frame, text=_('Average')).grid(row=0, column=3)
            # Tkinter.Label(frame, text=_('Total')).grid(row=0, column=4)

            s = app.stats.games_stats[player][gameid]
            row = 1
            ll = [
                (_('Playing time:'),
                 format_time(s.time_result.min),
                 format_time(s.time_result.max),
                 format_time(s.time_result.average),
                 format_time(s.time_result.total),
                 s.time_result.top,
                 ),
                (_('Moves:'),
                 s.moves_result.min,
                 s.moves_result.max,
                 round(s.moves_result.average, 2),
                 s.moves_result.total,
                 s.moves_result.top,
                 ),
                (_('Total moves:'),
                 s.total_moves_result.min,
                 s.total_moves_result.max,
                 round(s.total_moves_result.average, 2),
                 s.total_moves_result.total,
                 s.total_moves_result.top,
                 ),
                ]
            #  if s.score_result.min:
            #      ll.append(('Score:',
            #                 s.score_result.min,
            #                 s.score_result.max,
            #                 round(s.score_result.average, 2),
            #                 s.score_result.top,
            #                 ))
            #  if s.score_casino_result.min:
            #      ll.append(('Casino Score:',
            #                 s.score_casino_result.min,
            #                 s.score_casino_result.max,
            #                 round(s.score_casino_result.average, 2), ))
            for l, min, max, avr, tot, top in ll:
                Tkinter.Label(frame, text=l).grid(row=row, column=0)
                Tkinter.Label(frame, text=str(min)).grid(row=row, column=1)
                Tkinter.Label(frame, text=str(max)).grid(row=row, column=2)
                Tkinter.Label(frame, text=str(avr)).grid(row=row, column=3)
                # Tkinter.Label(frame, text=str(tot)).grid(row=row, column=4)
                b = Tkinter.Button(frame, text=TOP_TITLE+' ...', width=10,
                                   command=lambda top=top: self.showTop(top))
                b.grid(row=row, column=5)
                row += 1
        else:
            Tkinter.Label(frame, text=_('No TOP for this game')).pack()

        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
예제 #15
0
파일: tkstats.py 프로젝트: shlomif/PySolFC
    def __init__(self, parent, title, app, player, gameid, **kw):
        self.app = app
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)

        frame = tkinter.Frame(top_frame)
        frame.pack(expand=True, fill='both', padx=10, pady=10)
        frame.columnconfigure(0, weight=1)

        if (player in app.stats.games_stats and
            gameid in app.stats.games_stats[player] and
                app.stats.games_stats[player][gameid].time_result.top):

            tkinter.Label(frame, text=_('Minimum')).grid(row=0, column=1)
            tkinter.Label(frame, text=_('Maximum')).grid(row=0, column=2)
            tkinter.Label(frame, text=_('Average')).grid(row=0, column=3)
            # tkinter.Label(frame, text=_('Total')).grid(row=0, column=4)

            s = app.stats.games_stats[player][gameid]
            row = 1
            ll = [
                (_('Playing time:'),
                 format_time(s.time_result.min),
                 format_time(s.time_result.max),
                 format_time(s.time_result.average),
                 format_time(s.time_result.total),
                 s.time_result.top,
                 ),
                (_('Moves:'),
                 s.moves_result.min,
                 s.moves_result.max,
                 round(s.moves_result.average, 2),
                 s.moves_result.total,
                 s.moves_result.top,
                 ),
                (_('Total moves:'),
                 s.total_moves_result.min,
                 s.total_moves_result.max,
                 round(s.total_moves_result.average, 2),
                 s.total_moves_result.total,
                 s.total_moves_result.top,
                 ),
                ]
            #  if s.score_result.min:
            #      ll.append(('Score:',
            #                 s.score_result.min,
            #                 s.score_result.max,
            #                 round(s.score_result.average, 2),
            #                 s.score_result.top,
            #                 ))
            #  if s.score_casino_result.min:
            #      ll.append(('Casino Score:',
            #                 s.score_casino_result.min,
            #                 s.score_casino_result.max,
            #                 round(s.score_casino_result.average, 2), ))
            for l, min, max, avr, tot, top in ll:
                tkinter.Label(frame, text=l).grid(row=row, column=0)
                tkinter.Label(frame, text=str(min)).grid(row=row, column=1)
                tkinter.Label(frame, text=str(max)).grid(row=row, column=2)
                tkinter.Label(frame, text=str(avr)).grid(row=row, column=3)
                # tkinter.Label(frame, text=str(tot)).grid(row=row, column=4)
                b = tkinter.Button(frame, text=TOP_TITLE+' ...', width=10,
                                   command=lambda top=top: self.showTop(top))
                b.grid(row=row, column=5)
                row += 1
        else:
            tkinter.Label(frame, text=_('No TOP for this game')).pack()

        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
예제 #16
0
파일: tkstats.py 프로젝트: shlomif/PySolFC
    def __init__(self, parent, title, app, gameid, top, **kw):
        kw = self.initKw(kw)
        MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
        top_frame, bottom_frame = self.createFrames(kw)
        self.createBitmaps(top_frame, kw)

        cnf = {'master': top_frame,
               'padding': (4, 1),
               }
        frame = ttk.Frame(**cnf)
        frame.pack(expand=True, fill='both', padx=10, pady=10)
        frame.columnconfigure(0, weight=1)
        cnf['master'] = frame
        cnf['text'] = _('N')
        label = ttk.Label(**cnf)
        label.grid(row=0, column=0, sticky='ew')
        if gameid == 'all':
            cnf['text'] = _('Game')
            label = ttk.Label(**cnf)
            label.grid(row=0, column=1, sticky='ew')
        cnf['text'] = _('Game number')
        label = ttk.Label(**cnf)
        label.grid(row=0, column=2, sticky='ew')
        cnf['text'] = _('Started at')
        label = ttk.Label(**cnf)
        label.grid(row=0, column=3, sticky='ew')
        cnf['text'] = _('Result')
        label = ttk.Label(**cnf)
        label.grid(row=0, column=4, sticky='ew')

        row = 1
        for i in top:
            # N
            cnf['text'] = str(row)
            label = ttk.Label(**cnf)
            label.grid(row=row, column=0, sticky='ew')
            if gameid == 'all':
                name = app.getGameTitleName(i.gameid)
                if name is None:
                    name = _("** UNKNOWN %d **") % i.gameid
                cnf['text'] = name
                label = ttk.Label(**cnf)
                label.grid(row=row, column=1, sticky='ew')
            # Game number
            cnf['text'] = '#'+str(i.game_number)
            label = ttk.Label(**cnf)
            label.grid(row=row, column=2, sticky='ew')
            # Start time
            t = time.strftime(
                '%Y-%m-%d %H:%M', time.localtime(i.game_start_time))
            cnf['text'] = t
            label = ttk.Label(**cnf)
            label.grid(row=row, column=3, sticky='ew')
            # Result
            if isinstance(i.value, float):
                # time
                s = format_time(i.value)
            else:
                # moves
                s = str(i.value)
            cnf['text'] = s
            label = ttk.Label(**cnf)
            label.grid(row=row, column=4, sticky='ew')
            row += 1

        focus = self.createButtons(bottom_frame, kw)
        self.mainloop(focus, kw.timeout)
예제 #17
0
파일: tkstats.py 프로젝트: shlomif/PySolFC
    def createTopFrame(self, frame, player, gameid):
        app = self.app

        cond = (player not in app.stats.games_stats or
                gameid not in app.stats.games_stats[player] or
                not app.stats.games_stats[player][gameid].time_result.top)
        if cond:
            return False

        ttk.Label(frame, text=_('Minimum')
                  ).grid(row=0, column=1, padx=5, pady=5)
        ttk.Label(frame, text=_('Maximum')
                  ).grid(row=0, column=2, padx=5, pady=5)
        ttk.Label(frame, text=_('Average')
                  ).grid(row=0, column=3, padx=5, pady=5)
        # ttk.Label(frame, text=_('Total')).grid(row=0, column=4)

        s = app.stats.games_stats[player][gameid]

        row = 1
        ll = [
            (_('Playing time:'),
             format_time(s.time_result.min),
             format_time(s.time_result.max),
             format_time(s.time_result.average),
             format_time(s.time_result.total),
             s.time_result.top,
             ),
            (_('Moves:'),
             s.moves_result.min,
             s.moves_result.max,
             round(s.moves_result.average, 2),
             s.moves_result.total,
             s.moves_result.top,
             ),
            (_('Total moves:'),
             s.total_moves_result.min,
             s.total_moves_result.max,
             round(s.total_moves_result.average, 2),
             s.total_moves_result.total,
             s.total_moves_result.top,
             ),
            ]
        #  if s.score_result.min:
        #      ll.append(('Score:',
        #                 s.score_result.min,
        #                 s.score_result.max,
        #                 round(s.score_result.average, 2),
        #                 s.score_result.top,
        #                 ))
        #  if s.score_casino_result.min:
        #      ll.append(('Casino Score:',
        #                 s.score_casino_result.min,
        #                 s.score_casino_result.max,
        #                 round(s.score_casino_result.average, 2), ))
        for l, min, max, avr, tot, top in ll:
            ttk.Label(frame, text=l
                      ).grid(row=row, column=0, padx=5, pady=5)
            ttk.Label(frame, text=str(min)
                      ).grid(row=row, column=1, padx=5, pady=5)
            ttk.Label(frame, text=str(max)
                      ).grid(row=row, column=2, padx=5, pady=5)
            ttk.Label(frame, text=str(avr)
                      ).grid(row=row, column=3, padx=5, pady=5)
            # ttk.Label(frame, text=str(tot)).grid(row=row, column=4)

            def command(gameid=gameid, top=top):
                self.showTop(gameid, top)
            b = ttk.Button(frame, text=TOP_TITLE+' ...',
                           width=10, command=command)
            b.grid(row=row, column=5)
            row += 1
        return True