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

Compare commits

...

6 commits

Author SHA1 Message Date
Joe R
4478212d20 Add more alternate names 2024-09-23 20:31:00 -04:00
Alexandre Detiste
dd16750d5f
import tkinter directly (#383)
* import tkinter directly

* linter

* linter
2024-09-21 17:10:10 -04:00
Joe R
68d6b64fa2 Document Python 3.7 as the minimum supported version 2024-09-19 22:30:45 -04:00
Joe R
679c9a74c1 Add missing button icons 2024-09-19 22:20:40 -04:00
Joe R
4a3d6e7383 Delete game statistics when deleting a game 2024-09-19 21:41:56 -04:00
Alexandre Detiste
148f189a74
trim usage of six (#382)
This is artisanal manual craftwork :-)

     def mDone(self, button):
         if button == 0:        # "OK" or double click
-            if isinstance(self.tree.selection_key, six.string_types):
-                self.key = str(self.tree.selection_key)
-            else:
-                self.key = self.tree.selection_key
+            self.key = self.tree.selection_key
2024-09-18 20:33:10 -04:00
78 changed files with 146 additions and 174 deletions

View file

@ -7,7 +7,7 @@ for general guidelines for contributing to open source.
- The [GitHub Actions CI build](https://github.com/shlomif/PySolFC/actions) and [AppVeyor build](https://ci.appveyor.com/project/shlomif/pysolfc) (which also run the test suite) should pass on each commit.
- Your contributions should be under [GPLv3+](https://en.wikipedia.org/wiki/GNU_General_Public_License#Version_3) or a [compatible free software licence](https://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses), but please don't put them under the [AGPL](https://en.wikipedia.org/wiki/Affero_General_Public_License), which adds additional restrictions.
- The code should be compatible with Python 3.4.x-and-above.
- The code should be compatible with Python 3.7 and above.
# How you can contribute

View file

@ -31,7 +31,7 @@ can be implemented.
## Requirements.
- Python 3.x
- Python (3.7 or later)
- Tkinter (Tcl/Tk 8.4 or later)
- For sound support (optional)

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 680 B

After

Width:  |  Height:  |  Size: 724 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

View file

@ -542,6 +542,9 @@ class Application:
(_("&Hmm"), 'ok'),
(_('&Cancel'), 'cancel'),
(_('&Close'), 'cancel'),
(_("&Apply"), 'apply'),
(_("&Start"), 'apply'),
(_('&New'), 'new'),
(_('&New game'), 'new'),
(_('&Back to game'), 'back'),
(_('&Reset...'), 'reset'),
@ -550,6 +553,7 @@ class Application:
(_('&Info...'), 'help'),
(_('&Credits'), 'help'),
(_('&Next number'), 'next'),
(_('&Play'), 'next'),
(_('&Play this game'), 'next'),
(_('&Solid color...'), 'color'),
(_('&Save to file'), 'save'),

View file

@ -72,6 +72,19 @@ class Statistics:
else:
games[player] = [g for g in games[player] if g[0] != gameid]
def deleteGameStats(self, gameid):
for player in self.games_stats:
try:
del self.games_stats[player][gameid]
except KeyError:
pass
for player in self.prev_games:
self.prev_games[player] = \
[g for g in self.prev_games[player] if g[0] != gameid]
for player in self.session_games:
self.session_games[player] = \
[g for g in self.session_games[player] if g[0] != gameid]
def getStats(self, player, gameid):
# returned (won, lost)
return self.getFullStats(player, gameid)[:2]

View file

@ -70,8 +70,6 @@ from pysollib.util import ACE, ANY_RANK, ANY_SUIT, \
UNLIMITED_MOVES
from pysollib.wizardutil import WizardWidgets
import six
# ************************************************************************
# *
# ************************************************************************
@ -80,7 +78,7 @@ import six
def get_settings(ss):
s = {}
for w in WizardWidgets:
if isinstance(w, six.string_types):
if isinstance(w, str):
continue
if w.var_name in ss:
v = ss[w.var_name]

View file

@ -26,6 +26,7 @@ import math
import random
import time
import traceback
from io import BytesIO
from pickle import Pickler, Unpickler, UnpicklingError
import attr
@ -68,10 +69,6 @@ from pysollib.settings import PACKAGE, TITLE, TOOLKIT, TOP_SIZE
from pysollib.settings import VERSION, VERSION_TUPLE
from pysollib.struct_new import NewStruct
import six
from six import BytesIO
from six.moves import range
if TOOLKIT == 'tk':
from pysollib.ui.tktile.solverdialog import reset_solver_dialog
else:
@ -104,7 +101,7 @@ def _updateStatus_process_key_val(tb, sb, k, v):
# self.top.wm_title("%s - %s"
# % (TITLE, self.getTitleName()))
return
if isinstance(v, six.string_types):
if isinstance(v, str):
if sb:
sb.updateText(gamenumber=v)
# self.top.wm_title("%s - %s %s" % (TITLE,
@ -146,7 +143,7 @@ def _updateStatus_process_key_val(tb, sb, k, v):
if tb:
tb.updateText(player=_("Player\n"))
return
if isinstance(v, six.string_types):
if isinstance(v, str):
if tb:
# if self.app.opt.toolbar_size:
if tb.getSize():
@ -168,7 +165,7 @@ def _updateStatus_process_key_val(tb, sb, k, v):
if v is None:
if sb:
sb.updateText(time='')
if isinstance(v, six.string_types):
if isinstance(v, str):
if sb:
sb.updateText(time=v)
return
@ -1341,7 +1338,7 @@ class Game(object):
if self.preview:
return
tb, sb = self.app.toolbar, self.app.statusbar
for k, v in six.iteritems(kw):
for k, v in kw.items():
_updateStatus_process_key_val(tb, sb, k, v)
def _unmapHandler(self, event):

View file

@ -158,6 +158,7 @@ registerGame(GameInfo(557, GrandDuchess, "Grand Duchess",
altnames=('Duchess de Luynes')))
registerGame(GameInfo(617, Parisienne, "Parisienne",
GI.GT_NUMERICA, 2, 3,
altnames=('La Parisienne', 'Parisian')))
altnames=('La Parisienne', 'Parisian',
'Isle of Capri')))
registerGame(GameInfo(618, GrandDuchessPlus, "Grand Duchess +",
GI.GT_NUMERICA, 2, 3))

View file

@ -1055,7 +1055,8 @@ class AceOfHearts(Game):
# register the game
registerGame(GameInfo(1, Gypsy, "Gypsy",
GI.GT_GYPSY, 2, 0, GI.SL_MOSTLY_SKILL))
GI.GT_GYPSY, 2, 0, GI.SL_MOSTLY_SKILL,
altnames=("Normandy",)))
registerGame(GameInfo(65, Giant, "Giant",
GI.GT_GYPSY, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(3, Irmgard, "Irmgard",

View file

@ -1624,7 +1624,8 @@ registerGame(GameInfo(2, Klondike, "Klondike",
registerGame(GameInfo(61, CasinoKlondike, "Casino Klondike",
GI.GT_KLONDIKE | GI.GT_SCORE, 1, 2, GI.SL_BALANCED))
registerGame(GameInfo(129, VegasKlondike, "Vegas Klondike",
GI.GT_KLONDIKE | GI.GT_SCORE, 1, 0, GI.SL_BALANCED))
GI.GT_KLONDIKE | GI.GT_SCORE, 1, 0, GI.SL_BALANCED,
altnames=("Las Vegas",)))
registerGame(GameInfo(18, KlondikeByThrees, "Klondike (Draw 3)",
GI.GT_KLONDIKE, 1, -1, GI.SL_MOSTLY_LUCK))
registerGame(GameInfo(58, ThumbAndPouch, "Thumb and Pouch",

View file

@ -40,8 +40,6 @@ from pysollib.stack import \
OpenStack
from pysollib.util import ANY_SUIT, NO_RANK
from six.moves import range
def factorial(x):
if x <= 1:

View file

@ -37,8 +37,6 @@ from pysollib.stack import \
InitialDealTalonStack
from pysollib.util import ANY_SUIT
from six.moves import range
class Shisen_Hint(AbstractHint):
TOP_MATCHING = False

View file

@ -730,7 +730,7 @@ registerGame(GameInfo(399, Zeus, "Zeus",
GI.GT_PICTURE_GALLERY, 2, 0, GI.SL_BALANCED))
registerGame(GameInfo(546, RoyalParade, "Royal Parade",
GI.GT_PICTURE_GALLERY, 2, 0, GI.SL_MOSTLY_SKILL,
altnames=("Hussars", "Financier")))
altnames=("Hussars", "Financier", "Cavalcade")))
registerGame(GameInfo(547, VirginiaReel, "Virginia Reel",
GI.GT_PICTURE_GALLERY, 2, 0, GI.SL_MOSTLY_SKILL))
registerGame(GameInfo(782, GreaterWheel, "Greater Wheel",

View file

@ -34,8 +34,6 @@ from pysollib.stack import \
OpenStack
from pysollib.util import ANY_SUIT
from six.moves import range
# ************************************************************************
# * Samegame

View file

@ -33,8 +33,6 @@ from pysollib.pysolrandom import construct_random
from pysollib.settings import DEBUG, FCS_COMMAND
from pysollib.util import KING
import six
FCS_VERSION = None
# ************************************************************************
@ -819,7 +817,7 @@ class Base_Solver_Hint:
if os.name != 'nt':
kw['close_fds'] = True
p = subprocess.Popen(command, **kw)
bytes_board = six.binary_type(board, 'utf-8')
bytes_board = bytes(board, 'utf-8')
pout, perr = p.communicate(bytes_board)
if p.returncode in (127, 1):
# Linux and Windows return codes for "command not found" error
@ -1018,7 +1016,7 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
FCS_VERSION = (5, 0, 0)
else:
pout, _ = self.run_solver(FCS_COMMAND + ' --version', '')
s = six.text_type(pout.read(), encoding='utf-8')
s = str(pout.read(), encoding='utf-8')
m = re.search(r'version ([0-9]+)\.([0-9]+)\.([0-9]+)', s)
if m:
FCS_VERSION = (int(m.group(1)), int(m.group(2)),
@ -1082,7 +1080,7 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
states = 0
for sbytes in pout:
s = six.text_type(sbytes, encoding='utf-8')
s = str(sbytes, encoding='utf-8')
if DEBUG >= 5:
print(s)
@ -1127,7 +1125,7 @@ class FreeCellSolver_Hint(Base_Solver_Hint):
self.solver_state = 'unsolved'
else:
for sbytes in pout:
s = six.text_type(sbytes, encoding='utf-8')
s = str(sbytes, encoding='utf-8')
if DEBUG:
print(s)
if self._determineIfSolverState(s):
@ -1356,7 +1354,7 @@ class BlackHoleSolver_Hint(Base_Solver_Hint):
pout, perr = self.run_solver(command, board)
for sbytes in pout:
s = six.text_type(sbytes, encoding='utf-8')
s = str(sbytes, encoding='utf-8')
if DEBUG >= 5:
print(s)
@ -1390,7 +1388,7 @@ class BlackHoleSolver_Hint(Base_Solver_Hint):
else:
self.solver_state = result.lower()
for sbytes in pout:
s = six.text_type(sbytes, encoding='utf-8')
s = str(sbytes, encoding='utf-8')
if DEBUG:
print(s)

View file

@ -102,7 +102,7 @@ def init():
sys.argv.remove('--kivy')
if pysollib.settings.TOOLKIT == 'tk':
from six.moves import tkinter
import tkinter
root = tkinter.Tk(className=pysollib.settings.TITLE)
root.withdraw()
if tkinter.TkVersion < 8.4:

View file

@ -21,6 +21,8 @@
#
# ---------------------------------------------------------------------------#
from collections import UserList
from kivy.clock import Clock
from pysollib.gamedb import GI
@ -33,8 +35,6 @@ from pysollib.kivy.selecttree import SelectDialogTreeData
from pysollib.kivy.selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
from pysollib.mygettext import _
from six.moves import UserList
# ************************************************************************
# * Nodes

View file

@ -31,9 +31,6 @@ from pickle import Pickler, Unpickler
from pysollib.settings import PACKAGE, TOOLKIT
import six
from six import print_
Image = ImageTk = ImageOps = ImageDraw = None
if TOOLKIT == 'tk':
try: # PIL
@ -125,9 +122,9 @@ def print_err(s, level=1):
elif level == 2:
ss = PACKAGE+': DEBUG WARNING:'
try:
print_(ss, s, file=sys.stderr)
print(ss, s, file=sys.stderr)
except Exception:
print_(ss, s.encode(locale.getpreferredencoding()), file=sys.stderr)
print(ss, s.encode(locale.getpreferredencoding()), file=sys.stderr)
sys.stderr.flush()
@ -184,7 +181,7 @@ if os.name == "posix":
def win32_getusername():
user = os.environ.get('USERNAME', '').strip()
try:
user = six.text_type(user, locale.getpreferredencoding())
user = str(user, locale.getpreferredencoding())
except Exception:
user = ''
return user

View file

@ -1,10 +1,8 @@
import gettext
import sys
import six
class myLocalGettext(object):
class myLocalGettext:
def __init__(self, lang):
self.language = lang
@ -19,8 +17,8 @@ class myLocalGettext(object):
return t
def maketext(self, msg):
if not isinstance(msg, six.text_type):
return six.text_type(msg, 'utf-8')
if not isinstance(msg, str):
return str(msg, 'utf-8')
return msg
def ungettext(self, msgid1, msgid2, n):

View file

@ -35,9 +35,6 @@ from pysollib.mygettext import myGettext
from pysollib.pysoltk import STATUSBAR_ITEMS, TOOLBAR_BUTTONS, TOOLKIT
from pysollib.resource import CSI
import six
import validate
# ************************************************************************
@ -663,7 +660,7 @@ class Options:
val = getattr(self, key)
if isinstance(val, str):
if sys.version_info < (3,):
val = six.text_type(val, 'utf-8')
val = str(val, 'utf-8')
config['general'][key] = val
config['general']['recent_gameid'] = self.recent_gameid

View file

@ -23,7 +23,7 @@
# imports
# import os
# from six.moves import tkinter
# import tkinter
# import traceback
# # PySol imports

View file

@ -23,7 +23,7 @@
# imports
# import os
# from six.moves import tkinter
# import tkinter
# import traceback
# # PySol imports

View file

@ -24,7 +24,7 @@
# # imports
# import os, sys
# from six.moves import tkinter
# import tkinter
# # PySol imports
# from pysollib.mfxutil import KwStruct

View file

@ -25,8 +25,6 @@ import gtk
from pysollib.mygettext import _
import six
class BasicStatusbar:
def __init__(self, top, row, column, columnspan):
@ -60,7 +58,7 @@ class BasicStatusbar:
for k, v in kw.items():
label = getattr(self, k + "_label")
label.pop(0)
label.push(0, six.text_type(v))
label.push(0, str(v))
def config(self, name, show):
# FIXME
@ -70,7 +68,7 @@ class BasicStatusbar:
label = getattr(self, name + "_label")
# FIXME kw['fg']
label.pop(0)
label.push(0, six.text_type(kw['text']))
label.push(0, str(kw['text']))
def show(self, show=True, resize=False):
if show:

View file

@ -38,8 +38,6 @@ from pysollib.mfxutil import Struct, openURL
from pysollib.mygettext import _
from pysollib.settings import TITLE
import six
from tkwidget import MfxMessageDialog
if __name__ == '__main__':
@ -71,7 +69,7 @@ class tkHTMLWriter(pysollib.formatter.NullWriter):
self.indent = ''
def write(self, data):
data = six.text_type(data)
data = str(data)
self.text.insert(self.text.get_end_iter(), data, len(data))
def anchor_bgn(self, href, name, type):

View file

@ -29,8 +29,6 @@ from pysollib.mfxutil import Image, KwStruct, Struct, USE_PIL
from pysollib.mygettext import _
from pysollib.settings import DEBUG
import six
# ************************************************************************
# * Abstract
# ************************************************************************
@ -477,7 +475,7 @@ class Cardset(Resource):
def updateCardback(self, backname=None, backindex=None):
# update default back
if isinstance(backname, six.string_types):
if isinstance(backname, str):
if backname in self.backnames:
backindex = self.backnames.index(backname)
if isinstance(backindex, int):

View file

@ -27,8 +27,6 @@ from pysollib.gamedb import GI
from pysollib.mfxutil import format_time
from pysollib.mygettext import _
from six.moves import range
# ************************************************************************
# *
# ************************************************************************

View file

@ -21,11 +21,12 @@
#
# ---------------------------------------------------------------------------
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from pysollib.ui.tktile.tkutil import bind
from six.moves import tkinter
from six.moves import tkinter_font
from six.moves import tkinter_ttk as ttk

View file

@ -21,10 +21,11 @@
#
# ---------------------------------------------------------------------------##
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from six.moves import tkinter
from six.moves import tkinter_ttk as ttk
from .tkwidget import MfxDialog

View file

@ -21,10 +21,11 @@
#
# ---------------------------------------------------------------------------
import tkinter
from pysollib.ui.tktile.tkconst import EVENT_HANDLED
from pysollib.ui.tktile.tkutil import makeToplevel, setTransient
from six.moves import tkinter
from six.moves import tkinter_ttk as ttk
# ************************************************************************

View file

@ -22,6 +22,7 @@
# ---------------------------------------------------------------------------##
import os
import tkinter
from pysollib.mfxutil import KwStruct, USE_PIL
from pysollib.mygettext import _
@ -31,7 +32,6 @@ from pysollib.ui.tktile.tkcanvas import MfxCanvasImage
from pysollib.ui.tktile.tkutil import bind, loadImage
from pysollib.util import CARDSET
from six.moves import tkinter
from six.moves import tkinter_ttk as ttk
from .selecttree import SelectDialogTreeCanvas

View file

@ -22,6 +22,8 @@
# ---------------------------------------------------------------------------
import os
import tkinter
from collections import UserList
from pysollib.gamedb import GI
from pysollib.mfxutil import KwStruct, Struct, destruct
@ -31,8 +33,6 @@ from pysollib.resource import CSI
from pysollib.ui.tktile.selecttree import SelectDialogTreeData
from pysollib.ui.tktile.tkutil import bind, unbind_destroy
from six.moves import UserList
from six.moves import tkinter
from six.moves import tkinter_ttk as ttk
from .selecttree import SelectDialogTreeCanvas

View file

@ -22,6 +22,7 @@
# ---------------------------------------------------------------------------##
import os
import tkinter
from pysollib.mfxutil import KwStruct, USE_PIL
from pysollib.mygettext import _
@ -29,8 +30,6 @@ from pysollib.resource import TTI
from pysollib.ui.tktile.selecttree import SelectDialogTreeData
from pysollib.ui.tktile.tkutil import bind
import six
from six.moves import tkinter
from six.moves import tkinter_colorchooser
from six.moves import tkinter_ttk as ttk
@ -276,7 +275,7 @@ class SelectTileDialogWithPreview(MfxDialog):
def mDone(self, button):
if button == 0: # "OK" or double click
if isinstance(self.tree.selection_key, six.string_types):
if isinstance(self.tree.selection_key, str):
self.key = str(self.tree.selection_key)
else:
self.key = self.tree.selection_key
@ -378,7 +377,7 @@ class SelectTileDialogWithPreview(MfxDialog):
canvas.deleteAllItems()
self.preview_scaling = scaling
if isinstance(key, six.string_types):
if isinstance(key, str):
if USE_PIL:
self.textScale['state'] = 'disabled'
# solid color

View file

@ -22,6 +22,7 @@
# ---------------------------------------------------------------------------
import os
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
@ -29,7 +30,6 @@ from pysollib.pysolaudio import pysolsoundserver
from pysollib.settings import TITLE
from pysollib.ui.tktile.tkconst import EVENT_HANDLED
from six.moves import tkinter
from six.moves import tkinter_ttk as ttk
from .tkwidget import MfxDialog, MfxMessageDialog

View file

@ -24,11 +24,10 @@
# imports
import os
import sys
import tkinter
from pysollib.mygettext import _
import six
from six.moves import tkinter
from six.moves import tkinter_ttk as ttk
from .tkwidget import MfxTooltip
@ -97,7 +96,7 @@ class MfxStatusbar:
def updateText(self, **kw):
for k, v in kw.items():
label = getattr(self, k + '_label')
text = six.text_type(v)
text = str(v)
width = label['width']
if width and len(text) > width:
label['width'] = len(text)

View file

@ -21,10 +21,11 @@
#
# ---------------------------------------------------------------------------##
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from six.moves import tkinter
from six.moves import tkinter_ttk as ttk
from .tkwidget import MfxDialog, PysolScale

View file

@ -23,12 +23,12 @@
import os
import sys
import tkinter
from pysollib.mfxutil import Struct
from pysollib.mygettext import _
from pysollib.ui.tktile.tkhtml import Base_HTMLViewer
from six.moves import tkinter
from six.moves import tkinter_ttk as ttk
from .statusbar import HtmlStatusbar

View file

@ -23,6 +23,7 @@
import os
import time
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mfxutil import format_time
@ -31,7 +32,6 @@ from pysollib.settings import TOP_TITLE
from pysollib.stats import ProgressionFormatter, PysolStatsFormatter
from pysollib.ui.tktile.tkutil import bind, loadImage
from six.moves import tkinter
from six.moves import tkinter_font
from six.moves import tkinter_ttk as ttk

View file

@ -22,11 +22,10 @@
# ---------------------------------------------------------------------------
import os
import tkinter
from pysollib.ui.tktile.tkutil import bind
from six.moves import tkinter
from .tkwidget import MfxScrolledCanvas

View file

@ -24,6 +24,7 @@
import locale
import os
import time
import tkinter
import traceback
from pysollib.mfxutil import KwStruct, destruct, kwdefault, openURL
@ -34,9 +35,6 @@ from pysollib.ui.tktile.tkutil import after, after_cancel
from pysollib.ui.tktile.tkutil import bind, unbind_destroy
from pysollib.ui.tktile.tkutil import makeToplevel, setTransient
import six
from six import PY2
from six.moves import tkinter
from six.moves import tkinter_font
from six.moves import tkinter_ttk as ttk
@ -121,9 +119,9 @@ class MfxDialog: # ex. _ToplevelDialog
key = event.char
try:
if os.name == 'nt':
key = six.text_type(key, locale.getpreferredencoding())
key = str(key, locale.getpreferredencoding())
else:
key = six.text_type(key, 'utf-8')
key = str(key, 'utf-8')
except Exception:
pass
else:
@ -289,8 +287,6 @@ class MfxExceptionDialog(MfxMessageDialog):
(ex.errno, ex.strerror, repr(ex.filename))
else:
t = str(ex)
if PY2:
t = six.text_type(t, errors='replace')
kw.text = text + t
MfxMessageDialog.__init__(self, parent, title, **kw.getKw())

View file

@ -22,6 +22,7 @@
# ---------------------------------------------------------------------------##
import os
import tkinter
from pysollib.mfxutil import Image, ImageOps, ImageTk
from pysollib.mygettext import _, n_
@ -32,7 +33,6 @@ from pysollib.ui.tktile.tkutil import loadImage
from pysollib.util import IMAGE_EXTENSIONS
from pysollib.winsystems import TkSettings
from six.moves import tkinter
from six.moves import tkinter_ttk as ttk
from .tkwidget import MfxTooltip

View file

@ -21,13 +21,13 @@
#
# ---------------------------------------------------------------------------
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from pysollib.wizardpresets import presets
from pysollib.wizardutil import WizardWidgets
import six
from six.moves import tkinter
from six.moves import tkinter_ttk as ttk
from .tkwidget import MfxDialog
@ -49,7 +49,7 @@ class WizardDialog(MfxDialog):
notebook.pack(expand=True, fill='both')
for w in WizardWidgets:
if isinstance(w, six.string_types):
if isinstance(w, str):
frame = ttk.Frame(notebook)
notebook.add(frame, text=w, sticky='nsew', padding=5)
frame.columnconfigure(1, weight=1)
@ -128,7 +128,7 @@ class WizardDialog(MfxDialog):
n = w.translation_map[n]
p = presets[n]
for w in WizardWidgets:
if isinstance(w, six.string_types):
if isinstance(w, str):
continue
if w.var_name in p:
v = p[w.var_name]

View file

@ -1,6 +1,6 @@
from pysollib.tk.tkwidget import MfxDialog
import tkinter
from six.moves import tkinter
from pysollib.tk.tkwidget import MfxDialog
class BaseTkMfxDialog(MfxDialog):

View file

@ -21,12 +21,13 @@
#
# ---------------------------------------------------------------------------##
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from pysollib.tk.tkwidget import MfxDialog
from pysollib.ui.tktile.tkutil import bind
from six.moves import tkinter
from six.moves import tkinter_font

View file

@ -21,12 +21,12 @@
#
# ---------------------------------------------------------------------------##
import tkinter
from pysollib.mfxutil import KwStruct, Struct
from pysollib.mygettext import _
from pysollib.ui.tktile.tkutil import bind
from six.moves import tkinter
from .tkwidget import MfxDialog

View file

@ -21,11 +21,11 @@
#
# ---------------------------------------------------------------------------##
import tkinter
from pysollib.ui.tktile.tkconst import EVENT_HANDLED
from pysollib.ui.tktile.tkutil import makeToplevel, setTransient
from six.moves import tkinter
# ************************************************************************
# * a simple progress bar
# ************************************************************************

View file

@ -22,6 +22,7 @@
# ---------------------------------------------------------------------------##
import os
import tkinter
from pysollib.mfxutil import KwStruct, USE_PIL
from pysollib.mygettext import _
@ -31,8 +32,6 @@ from pysollib.ui.tktile.tkcanvas import MfxCanvasImage
from pysollib.ui.tktile.tkutil import loadImage
from pysollib.util import CARDSET
from six.moves import tkinter
from .selecttree import SelectDialogTreeCanvas
from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
from .tkwidget import MfxDialog, MfxScrolledCanvas

View file

@ -22,6 +22,8 @@
# ---------------------------------------------------------------------------
import os
import tkinter
from collections import UserList
from pysollib.gamedb import GI
from pysollib.mfxutil import KwStruct, Struct, destruct
@ -31,9 +33,6 @@ from pysollib.resource import CSI
from pysollib.ui.tktile.selecttree import SelectDialogTreeData
from pysollib.ui.tktile.tkutil import unbind_destroy
from six.moves import UserList
from six.moves import tkinter
from .selecttree import SelectDialogTreeCanvas
from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
from .tkwidget import MfxDialog, MfxScrolledCanvas

View file

@ -21,13 +21,13 @@
#
# ---------------------------------------------------------------------------##
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from pysollib.ui.tktile.selecttree import SelectDialogTreeData
import six
from six.moves import tkinter, tkinter_colorchooser
from six.moves import tkinter_colorchooser
from .selecttree import SelectDialogTreeCanvas
from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode
@ -172,10 +172,7 @@ class SelectTileDialogWithPreview(MfxDialog):
def mDone(self, button):
if button == 0: # "OK" or double click
if isinstance(self.tree.selection_key, six.string_types):
self.key = str(self.tree.selection_key)
else:
self.key = self.tree.selection_key
self.key = self.tree.selection_key
self.tree.n_expansions = 1 # save xyview in any case
if button == 1: # "Solid color..."
try:
@ -201,7 +198,7 @@ class SelectTileDialogWithPreview(MfxDialog):
return
canvas = self.preview.canvas
canvas.deleteAllItems()
if isinstance(key, six.string_types):
if isinstance(key, str):
# solid color
canvas.config(bg=key)
canvas.setTile(None)

View file

@ -21,13 +21,13 @@
#
# ---------------------------------------------------------------------------##
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from pysollib.tk.basetkmfxdialog import BaseTkMfxDialog
from pysollib.ui.tktile.solverdialog import BaseSolverDialog, solver_dialog
from six.moves import range, tkinter
# ************************************************************************
# *
# ************************************************************************

View file

@ -22,6 +22,7 @@
# ---------------------------------------------------------------------------##
import os
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
@ -29,8 +30,6 @@ from pysollib.pysolaudio import pysolsoundserver
from pysollib.settings import TITLE
from pysollib.ui.tktile.tkconst import EVENT_HANDLED
from six.moves import tkinter
from .tkwidget import MfxDialog, MfxMessageDialog
# ************************************************************************

View file

@ -23,13 +23,11 @@
import os
import sys
import tkinter
from pysollib.mygettext import _
from pysollib.settings import WIN_SYSTEM
import six
from six.moves import tkinter
from .tkwidget import MfxTooltip
if __name__ == '__main__':
@ -96,7 +94,7 @@ class MfxStatusbar:
def updateText(self, **kw):
for k, v in kw.items():
label = getattr(self, k + '_label')
text = six.text_type(v)
text = str(v)
width = label['width']
if width and len(text) > width:
label['width'] = len(text)

View file

@ -24,7 +24,7 @@
a couple of classes for implementing partial tabbed-page like behaviour
"""
from six.moves import tkinter
import tkinter
MYRIDGE, MYRAISED = tkinter.RAISED, tkinter.RIDGE
# MYRIDGE, MYRAISED = tkinter.RIDGE, tkinter.RAISED

View file

@ -21,12 +21,11 @@
#
# ---------------------------------------------------------------------------
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from six.moves import tkinter
from .tkwidget import MfxDialog

View file

@ -23,13 +23,12 @@
import os
import sys
import tkinter
from pysollib.mfxutil import Struct
from pysollib.mygettext import _
from pysollib.ui.tktile.tkhtml import Base_HTMLViewer
from six.moves import tkinter
from .statusbar import HtmlStatusbar
from .tkwidget import MfxMessageDialog

View file

@ -23,6 +23,7 @@
import os
import time
import tkinter
from pysollib.mfxutil import KwStruct, kwdefault
from pysollib.mfxutil import format_time
@ -31,7 +32,6 @@ from pysollib.settings import TOP_TITLE
from pysollib.stats import ProgressionFormatter, PysolStatsFormatter
from pysollib.ui.tktile.tkutil import bind, loadImage
from six.moves import tkinter
from six.moves import tkinter_font
from .tkwidget import MfxDialog, MfxMessageDialog

View file

@ -22,11 +22,10 @@
# ---------------------------------------------------------------------------##
import os
import tkinter
from pysollib.ui.tktile.tkutil import bind
from six.moves import tkinter
from .tkwidget import MfxScrolledCanvas

View file

@ -22,6 +22,7 @@
# ---------------------------------------------------------------------------
import time
import tkinter
import traceback
from pysollib.mfxutil import KwStruct, destruct, kwdefault, openURL
@ -32,8 +33,6 @@ from pysollib.ui.tktile.tkutil import after, after_cancel
from pysollib.ui.tktile.tkutil import bind, unbind_destroy
from pysollib.ui.tktile.tkutil import makeToplevel, setTransient
import six
from six.moves import tkinter
from six.moves import tkinter_font
# ************************************************************************
@ -130,7 +129,7 @@ class MfxDialog: # ex. _ToplevelDialog
def altKeyEvent(self, event):
key = event.char
key = six.text_type(key, 'utf-8')
key = str(key, 'utf-8')
key = key.lower()
button = self.accel_keys.get(key)
if button is not None:
@ -285,7 +284,7 @@ class MfxExceptionDialog(MfxMessageDialog):
(ex.errno, ex.strerror, repr(ex.filename))
else:
t = str(ex)
kw.text = text + six.text_type(t, errors='replace')
kw.text = text + str(t, errors='replace')
MfxMessageDialog.__init__(self, parent, title, **kw.getKw())

View file

@ -22,6 +22,7 @@
# ---------------------------------------------------------------------------##
import os
import tkinter
from pysollib.mfxutil import Image, ImageTk
from pysollib.mygettext import _, n_
@ -31,8 +32,6 @@ from pysollib.ui.tktile.tkconst import EVENT_HANDLED
from pysollib.util import IMAGE_EXTENSIONS
from pysollib.winsystems import TkSettings
from six.moves import tkinter
from .tkwidget import MfxTooltip

View file

@ -21,14 +21,13 @@
#
# ---------------------------------------------------------------------------##
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from pysollib.wizardpresets import presets
from pysollib.wizardutil import WizardWidgets
import six
from six.moves import tkinter
from .tabpage import TabPageSet
from .tkwidget import MfxDialog
@ -48,7 +47,7 @@ class WizardDialog(MfxDialog):
notebook.pack(expand=True, fill='both')
for w in WizardWidgets:
if isinstance(w, six.string_types):
if isinstance(w, str):
notebook.AddPage(w)
frame = tkinter.Frame(notebook.pages[w]['page'])
frame.pack(expand=True, fill='both', padx=2, pady=4)
@ -117,7 +116,7 @@ class WizardDialog(MfxDialog):
n = w.translation_map[v]
p = presets[n]
for w in WizardWidgets:
if isinstance(w, six.string_types):
if isinstance(w, str):
continue
if w.var_name in p:
v = p[w.var_name]

View file

@ -1,9 +1,9 @@
# This module exports classes for the various canvas item types
# NOTE: This module was an experiment and is now obsolete.
# It's best to use the Tkinter.Canvas class directly.
# It's best to use the tkinter.Canvas class directly.
from six.moves.tkinter import Canvas, _cnfmerge, _flatten # noqa: F401
from tkinter import Canvas, _cnfmerge, _flatten # noqa: F401
class CanvasItem:

View file

@ -21,10 +21,11 @@
#
# ---------------------------------------------------------------------------
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from six.moves import tkinter
from six.moves.tkinter_colorchooser import askcolor

View file

@ -1,8 +1,8 @@
import tkinter
from pysollib.mfxutil import KwStruct
from pysollib.mygettext import _
from six.moves import tkinter
class BaseEditTextDialog:
def __init__(self, parent, title, text, **kw):

View file

@ -22,6 +22,7 @@
# ---------------------------------------------------------------------------
import os
import tkinter
from pysollib.mygettext import _
from pysollib.resource import CSI
@ -31,8 +32,6 @@ from pysollib.ui.tktile.tkcanvas import MfxCanvasImage, MfxCanvasRectangle
from pysollib.ui.tktile.tkutil import after, after_cancel
from pysollib.ui.tktile.tkutil import bind, makeImage, unbind_destroy
from six.moves import tkinter
LARGE_EMBLEMS_SIZE = (38, 34)
SMALL_EMBLEMS_SIZE = (31, 21)

View file

@ -21,14 +21,14 @@
#
# ---------------------------------------------------------------------------
import tkinter
from pysollib.mygettext import _
from pysollib.settings import TITLE
from pysollib.ui.tktile.tkcanvas import MfxCanvas, MfxCanvasGroup
from pysollib.ui.tktile.tkcanvas import MfxCanvasImage
from pysollib.ui.tktile.tkutil import bind, unbind_destroy
from six.moves import tkinter
class FullPictureDialog(tkinter.Toplevel):
CARD_IMAGES = {} # key: (type, rank, suit)

View file

@ -3,6 +3,7 @@ import os
import platform
import re
import sys
import tkinter
from pysollib.gamedb import GI
from pysollib.hint import PySolHintLayoutImportError
@ -17,7 +18,6 @@ from pysollib.ui.tktile.tkconst import EVENT_PROPAGATE
from pysollib.ui.tktile.tkconst import STATUSBAR_ITEMS, TOOLBAR_BUTTONS
from pysollib.ui.tktile.tkutil import after_idle, bind
from six.moves import tkinter
from six.moves import tkinter_tkfiledialog
@ -2190,7 +2190,7 @@ Error while saving game.
% self.game.gameinfo.name):
return
from pysollib.wizardutil import delete_game
delete_game(self.game)
delete_game(self.app, self.game)
self.game.endGame()
self.game.quitGame(2)

View file

@ -1,9 +1,9 @@
import tkinter
from pysollib.mygettext import _
from pysollib.settings import TITLE
from pysollib.ui.tktile.tkconst import EVENT_HANDLED
from six.moves import tkinter
class BaseSolverDialog:
def _ToggleShowProgressButton(self, *args):

View file

@ -21,13 +21,13 @@
#
# ---------------------------------------------------------------------------
import tkinter
from pysollib.mfxutil import Image, ImageTk
from pysollib.ui.tktile.Canvas2 import CanvasText, Group, Line, Rectangle
from pysollib.ui.tktile.Canvas2 import ImageItem as ImageItem2
from pysollib.ui.tktile.tkutil import loadImage, unbind_destroy
from six.moves import tkinter
# ************************************************************************
# * canvas items

View file

@ -21,9 +21,9 @@
#
# ---------------------------------------------------------------------------##
from pysollib.mygettext import n_
import tkinter
from six.moves import tkinter
from pysollib.mygettext import n_
# ************************************************************************
# * constants

View file

@ -23,6 +23,7 @@
import os
import sys
import tkinter
import pysollib.formatter
import pysollib.htmllib2 as htmllib
@ -31,8 +32,6 @@ from pysollib.mygettext import _
from pysollib.settings import TITLE
from pysollib.ui.tktile.tkutil import bind, unbind_destroy
from six.moves import tkinter
REMOTE_PROTOCOLS = ("ftp:", "gopher:", "http:", "https:", "mailto:", "news:",
"telnet:")

View file

@ -23,12 +23,12 @@
import os
import re
import tkinter
from pysollib.mfxutil import Image, ImageDraw, ImageOps, ImageTk, \
get_default_resampling
from pysollib.settings import TITLE, WIN_SYSTEM
from six.moves import tkinter
from six.moves import tkinter_font

View file

@ -21,9 +21,10 @@
#
# ---------------------------------------------------------------------------
import tkinter
from pysollib.ui.tktile.tkconst import EVENT_PROPAGATE
from six.moves import tkinter
TclError = tkinter.TclError

View file

@ -37,8 +37,6 @@ from pysollib.mfxutil import Image
from pysollib.mygettext import _
from pysollib.settings import DATA_DIRS, TOOLKIT
import six
# ************************************************************************
# * constants
# ************************************************************************
@ -152,8 +150,8 @@ class DataLoader:
def __findFile(self, func, filename, subdirs=None, do_raise=1):
if subdirs is None:
subdirs = ("",)
elif isinstance(subdirs, six.string_types):
subdirs = (str(subdirs),)
elif isinstance(subdirs, str):
subdirs = (subdirs,)
for dir in subdirs:
f = os.path.join(self.dir, dir, filename)
f = os.path.normpath(f)

View file

@ -66,8 +66,6 @@ from pysollib.stack import AC_FoundationStack, \
from pysollib.util import ACE, ANY_RANK, KING, NO_RANK, UNLIMITED_MOVES
from pysollib.wizardpresets import presets
import six
# ************************************************************************
# *
# ************************************************************************
@ -436,7 +434,7 @@ class MyCustomGame(CustomGame):
''')
for w in WizardWidgets:
if isinstance(w, six.string_types):
if isinstance(w, str):
continue
v = w.variable.get()
if w.widget in ('menu', 'preset'):
@ -455,7 +453,7 @@ class MyCustomGame(CustomGame):
v = v.replace("\r", "\\r")
v = v.replace("\t", "\\t")
# See: https://github.com/shlomif/PySolFC/issues/177
# if isinstance(v, six.text_type):
# if isinstance(v, str):
# v = v.encode('utf-8')
if not v:
v = 'Invalid Game Name'
@ -473,15 +471,16 @@ registerCustomGame(MyCustomGame)
return gameid
def delete_game(game):
def delete_game(app, game):
hideGame(game)
app.stats.deleteGameStats(game.id)
fn = game.MODULE_FILENAME
os.remove(fn)
def reset_wizard(game):
for w in WizardWidgets:
if isinstance(w, six.string_types):
if isinstance(w, str):
continue
if game is None:
# set to default

View file

@ -2,6 +2,7 @@
# -*- mode: python; coding: koi8-r; -*-
#
import builtins
import os
import sys
import time
@ -16,7 +17,6 @@ from pysollib.mfxutil import latin1_normalize
from pysollib.mygettext import fix_gettext
from pysollib.resource import CSI
from six.moves import builtins
os.environ['LANG'] = 'C'
builtins.__dict__['_'] = lambda x: x
builtins.__dict__['n_'] = lambda x: x

View file

@ -8,11 +8,11 @@
# Arrow up/down flip through the sets
import os
import tkinter
from glob import glob
from PIL import Image, ImageTk
from six.moves import tkinter
from six.moves import tkinter_tkfiledialog as filedialog # messagebox