1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00

Revamped the status bar functionality - better design and cleaner options list.

This commit is contained in:
Joe R 2022-07-17 09:22:38 -04:00
parent f968a2c9e4
commit 8bbf3bbebe
12 changed files with 110 additions and 35 deletions

View file

@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: PySol 0.0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-12-10 10:19-0500\n"
"PO-Revision-Date: 2022-07-06 18:33-0400\n"
"PO-Revision-Date: 2022-07-17 09:21-0400\n"
"Last-Translator: H. Schaekel <Holger.Schaekel@web.de>\n"
"Language-Team: German\n"
"Language: de\n"
@ -3471,6 +3471,12 @@ msgstr "Bewegungen/total"
msgid "Games played: won/lost"
msgstr "Gespielt: gewonnen/verloren"
msgid "Number of cards"
msgstr ""
msgid "Help info"
msgstr ""
#: pysollib/pysolgtk/tkhtml.py:437 pysollib/ui/tktile/tkhtml.py:314
#, python-format
msgid ""

View file

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: 1.02\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-12-10 10:19-0500\n"
"PO-Revision-Date: 2022-07-06 18:33-0400\n"
"PO-Revision-Date: 2022-07-17 09:19-0400\n"
"Last-Translator: Eric Rausch <neelix570@gmail.com>\n"
"Language-Team: French\n"
"Language: fr\n"
@ -3517,6 +3517,12 @@ msgstr "Déplacements/Total déplacements"
msgid "Games played: won/lost"
msgstr "Jeux finis: gagnés/perdus"
msgid "Number of cards"
msgstr ""
msgid "Help info"
msgstr ""
#: pysollib/pysolgtk/tkhtml.py:437 pysollib/ui/tktile/tkhtml.py:314
#, python-format
msgid ""

View file

@ -12,7 +12,7 @@ msgstr ""
"Project-Id-Version: it_pysol\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-12-10 10:19-0500\n"
"PO-Revision-Date: 2022-07-06 18:32-0400\n"
"PO-Revision-Date: 2022-07-17 09:19-0400\n"
"Last-Translator: Giuliano Colla <giuliano.colla@gmail.com>\n"
"Language-Team: Italiano <it@li.org>\n"
"Language: it\n"
@ -3578,6 +3578,12 @@ msgstr "Mosse/Mosse totali"
msgid "Games played: won/lost"
msgstr "Giocati: vinti/perduti"
msgid "Number of cards"
msgstr ""
msgid "Help info"
msgstr ""
#: pysollib/pysolgtk/tkhtml.py:437 pysollib/ui/tktile/tkhtml.py:314
#, python-format
msgid ""

View file

@ -8,7 +8,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-12-10 10:19-0500\n"
"PO-Revision-Date: 2022-07-06 18:32-0400\n"
"PO-Revision-Date: 2022-07-17 09:19-0400\n"
"Last-Translator: Jerzy Trzeciak <artusek@wp.pl>\n"
"Language-Team: Polish <pl@li.org>\n"
"Language: pl\n"
@ -3619,6 +3619,12 @@ msgstr "Ruchy/Ruchy ogółem"
msgid "Games played: won/lost"
msgstr "Gry rozegrane: wygrane/przegrane"
msgid "Number of cards"
msgstr ""
msgid "Help info"
msgstr ""
#: pysollib/pysolgtk/tkhtml.py:437 pysollib/ui/tktile/tkhtml.py:314
#, fuzzy, python-format
msgid ""

View file

@ -3343,6 +3343,12 @@ msgstr ""
msgid "Games played: won/lost"
msgstr ""
msgid "Number of cards"
msgstr ""
msgid "Help info"
msgstr ""
#: pysollib/pysolgtk/tkhtml.py:437 pysollib/ui/tktile/tkhtml.py:314
#, python-format
msgid ""

View file

@ -7,7 +7,7 @@ msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-12-10 10:19-0500\n"
"PO-Revision-Date: 2022-07-06 18:31-0400\n"
"PO-Revision-Date: 2022-07-17 09:18-0400\n"
"Last-Translator: Skomoroh <skomoroh@gmail.com>\n"
"Language-Team: Russian <ru@li.org>\n"
"Language: ru\n"
@ -3589,6 +3589,12 @@ msgstr "Ходов/Всего ходов"
msgid "Games played: won/lost"
msgstr "Игр: выиграно/проиграно"
msgid "Number of cards"
msgstr ""
msgid "Help info"
msgstr ""
#: pysollib/pysolgtk/tkhtml.py:437 pysollib/ui/tktile/tkhtml.py:314
#, python-format
msgid ""

View file

@ -46,7 +46,7 @@ from pysollib.mygettext import _
from pysollib.options import Options
from pysollib.pysolrandom import PysolRandom, construct_random
from pysollib.pysoltk import HTMLViewer
from pysollib.pysoltk import HelpStatusbar, PysolStatusbar
from pysollib.pysoltk import PysolStatusbar
from pysollib.pysoltk import MfxDialog, MfxExceptionDialog, MfxMessageDialog
from pysollib.pysoltk import MfxScrolledCanvas, TclError
from pysollib.pysoltk import PysolProgressBar
@ -356,10 +356,8 @@ class Application:
# create the statusbar(s)
self.statusbar = PysolStatusbar(self.top)
self.statusbar.show(self.opt.statusbar)
self.statusbar.config('gamenumber', self.opt.statusbar_game_number)
self.statusbar.config('stuck', self.opt.statusbar_stuck)
self.helpbar = HelpStatusbar(self.top)
self.helpbar.show(self.opt.helpbar)
for w, v in self.opt.statusbar_vars.items():
self.statusbar.config(w, v)
# create the canvas
self.scrolled_canvas = MfxScrolledCanvas(self.top, propagate=True)
self.canvas = self.scrolled_canvas.canvas

View file

@ -3382,10 +3382,10 @@ class Game(object):
kw = dict([(args[i], args[i+1]) for i in range(0, len(args), 2)])
if not kw:
kw = {'info': '', 'help': ''}
if 'info' in kw and self.app.opt.statusbar and self.app.opt.num_cards:
if 'info' in kw and self.app.opt.statusbar:
self.app.statusbar.updateText(info=kw['info'])
if 'help' in kw and self.app.opt.helpbar:
self.app.helpbar.updateText(info=kw['help'])
if 'help' in kw and self.app.opt.statusbar:
self.app.statusbar.updateText(help=kw['help'])
#
# Piles descriptions

View file

@ -31,7 +31,7 @@ import pysollib.settings
from pysollib.mfxutil import Image, USE_PIL, print_err
from pysollib.mygettext import _
from pysollib.mygettext import myGettext
from pysollib.pysoltk import TOOLBAR_BUTTONS, TOOLKIT
from pysollib.pysoltk import STATUSBAR_ITEMS, TOOLBAR_BUTTONS, TOOLKIT
from pysollib.resource import CSI
@ -127,6 +127,7 @@ center_layout = boolean
recent_gameid = int_list
favorite_gameid = int_list
visible_buttons = string_list
visible_status = string_list
translate_game_names = boolean
solver_presets = string_list
solver_show_progress = boolean
@ -250,10 +251,10 @@ class Options:
('toolbar_compound', 'str'),
('toolbar_size', 'int'),
('statusbar', 'bool'),
('statusbar_game_number', 'bool'),
('statusbar_stuck', 'bool'),
('num_cards', 'bool'),
('helpbar', 'bool'),
# ('statusbar_game_number', 'bool'),
# ('statusbar_stuck', 'bool'),
# ('num_cards', 'bool'),
# ('helpbar', 'bool'),
('num_recent_games', 'int'),
('last_gameid', 'int'),
('game_holded', 'int'),
@ -349,11 +350,14 @@ class Options:
self.toolbar_vars = {}
for w in TOOLBAR_BUTTONS:
self.toolbar_vars[w] = True # show all buttons
self.statusbar_vars = {}
for w, x in STATUSBAR_ITEMS:
self.statusbar_vars[w] = True
self.statusbar = True
self.statusbar_game_number = False # show game number in statusbar
self.statusbar_stuck = False # show stuck indicator
self.num_cards = False
self.helpbar = False
# self.statusbar_game_number = False # show game number in statusbar
# self.statusbar_stuck = False # show stuck indicator
# self.num_cards = False
# self.helpbar = False
self.splashscreen = True
self.date_format = '%m-%d'
self.mouse_button1 = 1
@ -590,6 +594,9 @@ class Options:
visible_buttons = [b for b in self.toolbar_vars
if self.toolbar_vars[b]]
config['general']['visible_buttons'] = visible_buttons
visible_status = [b for b in self.statusbar_vars
if self.statusbar_vars[b]]
config['general']['visible_status'] = visible_status
if 'none' in config['general']['solver_presets']:
config['general']['solver_presets'].remove('none')
@ -731,6 +738,10 @@ class Options:
if visible_buttons is not None:
for key in TOOLBAR_BUTTONS:
self.toolbar_vars[key] = (key in visible_buttons)
visible_status = self._getOption('general', 'visible_status', 'list')
if visible_status is not None:
for key, label in STATUSBAR_ITEMS:
self.statusbar_vars[key] = (key in visible_status)
myGettext.language = self.language

View file

@ -155,10 +155,11 @@ class PysolStatusbar(MfxStatusbar):
('moves', _('Moves/Total moves'), 10),
('gamenumber', _('Game number'), 26),
('stats', _('Games played: won/lost'), 12),
('info', _('Number of cards'), 12),
):
self._createLabel(n, tooltip=t, width=w)
#
label = self._createLabel('info', expand=True)
label = self._createLabel('help', expand=True)
label.config(padding=(8, 0))
self._createSizegrip()

View file

@ -13,7 +13,7 @@ from pysollib.settings import TITLE, WIN_SYSTEM
from pysollib.settings import USE_FREECELL_SOLVER
from pysollib.ui.tktile.tkconst import COMPOUNDS, CURSOR_WATCH, EVENT_HANDLED
from pysollib.ui.tktile.tkconst import EVENT_PROPAGATE
from pysollib.ui.tktile.tkconst import TOOLBAR_BUTTONS
from pysollib.ui.tktile.tkconst import STATUSBAR_ITEMS, TOOLBAR_BUTTONS
from pysollib.ui.tktile.tkutil import after_idle, bind
from six.moves import tkinter
@ -71,6 +71,18 @@ def createToolbarMenu(menubar, menu):
command=menubar.mOptToolbar)
def createStatusbarMenu(menubar, menu):
menu.add_checkbutton(
label=n_("Show &statusbar"), variable=menubar.tkopt.statusbar,
command=menubar.mOptStatusbar)
menu.add_separator()
for comp, label in STATUSBAR_ITEMS:
menu.add_checkbutton(
label=label,
variable=menubar.tkopt.statusbar_vars[comp],
command=lambda m=menubar, w=comp: m.mOptStatusbarConfig(w))
def createResamplingMenu(menubar, menu):
tearoff = menu.cget('tearoff')
submenu = MfxMenu(menu, label=n_('R&esampling'), tearoff=tearoff)
@ -247,9 +259,12 @@ class PysolMenubarTkCommon:
pause=tkinter.BooleanVar(),
theme=tkinter.StringVar(),
toolbar_vars={},
statusbar_vars={},
)
for w in TOOLBAR_BUTTONS:
self.tkopt.toolbar_vars[w] = tkinter.BooleanVar()
for w, x in STATUSBAR_ITEMS:
self.tkopt.statusbar_vars[w] = tkinter.BooleanVar()
def _setOptions(self):
tkopt, opt = self.tkopt, self.app.opt
@ -295,8 +310,8 @@ class PysolMenubarTkCommon:
tkopt.toolbar_size.set(opt.toolbar_size)
tkopt.toolbar_relief.set(opt.toolbar_relief)
tkopt.statusbar.set(opt.statusbar)
tkopt.num_cards.set(opt.num_cards)
tkopt.helpbar.set(opt.helpbar)
# tkopt.num_cards.set(opt.num_cards)
# tkopt.helpbar.set(opt.helpbar)
tkopt.demo_logo.set(opt.demo_logo)
tkopt.splashscreen.set(opt.splashscreen)
tkopt.mouse_type.set(opt.mouse_type)
@ -304,6 +319,8 @@ class PysolMenubarTkCommon:
tkopt.negative_bottom.set(opt.negative_bottom)
for w in TOOLBAR_BUTTONS:
tkopt.toolbar_vars[w].set(opt.toolbar_vars.get(w, False))
for w, x in STATUSBAR_ITEMS:
tkopt.statusbar_vars[w].set(opt.statusbar_vars.get(w, False))
def connectGame(self, game):
self.game = game
@ -714,15 +731,7 @@ class PysolMenubarTkCommon:
submenu = MfxMenu(menu, label=n_("&Toolbar"))
createToolbarMenu(self, submenu)
submenu = MfxMenu(menu, label=n_("Stat&usbar"))
submenu.add_checkbutton(
label=n_("Show &statusbar"), variable=self.tkopt.statusbar,
command=self.mOptStatusbar)
submenu.add_checkbutton(
label=n_("Show &number of cards"), variable=self.tkopt.num_cards,
command=self.mOptNumCards)
submenu.add_checkbutton(
label=n_("Show &help bar"), variable=self.tkopt.helpbar,
command=self.mOptHelpbar)
createStatusbarMenu(self, submenu)
menu.add_checkbutton(
label=n_("&Demo logo"), variable=self.tkopt.demo_logo,
command=self.mOptDemoLogo)
@ -1768,6 +1777,9 @@ Unsupported game for import.
if self.app.statusbar.show(side, resize=resize):
self.top.update_idletasks()
def mOptStatusbarConfig(self, w):
self.statusbarConfig(w, self.tkopt.statusbar_vars[w].get())
def mOptNumCards(self, *event):
if self._cancelDrag(break_pause=False):
return
@ -1921,6 +1933,13 @@ Error while saving game.
self.app.toolbar.config(w, v)
self.top.update_idletasks()
def statusbarConfig(self, w, v):
if self._cancelDrag(break_pause=False):
return
self.app.opt.statusbar_vars[w] = v
self.app.statusbar.config(w, v)
self.top.update_idletasks()
#
# stacks descriptions
#

View file

@ -72,3 +72,13 @@ TOOLBAR_BUTTONS = (
"quit",
"player",
)
STATUSBAR_ITEMS = (
('stuck', "'You Are Stuck' indicator"),
('time', 'Playing time'),
('moves', 'Moves/Total moves'),
('gamenumber', 'Game number'),
('stats', 'Games played: won/lost'),
('info', 'Number of cards'),
('help', 'Help info')
)