From f768b571ad345601ad30c4849254ea3f7f771295 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Mon, 22 May 2017 19:42:11 +0300 Subject: [PATCH] 2to3 on pysollib/tk/[a-s]*.py --- pysollib/tk/playeroptionsdialog.py | 2 +- pysollib/tk/selectcardset.py | 24 ++++++++++++------------ pysollib/tk/selectgame.py | 30 ++++++++++++++++++------------ pysollib/tk/selecttile.py | 16 ++++++++-------- pysollib/tk/selecttree.py | 2 +- pysollib/tk/soundoptionsdialog.py | 2 +- pysollib/tk/statusbar.py | 2 +- 7 files changed, 42 insertions(+), 36 deletions(-) diff --git a/pysollib/tk/playeroptionsdialog.py b/pysollib/tk/playeroptionsdialog.py index 41b3214d..4511fc12 100644 --- a/pysollib/tk/playeroptionsdialog.py +++ b/pysollib/tk/playeroptionsdialog.py @@ -31,7 +31,7 @@ from pysollib.mygettext import _ from pysollib.mfxutil import KwStruct, Struct # Toolkit imports -from tkwidget import MfxDialog +from .tkwidget import MfxDialog from pysollib.ui.tktile.tkutil import bind diff --git a/pysollib/tk/selectcardset.py b/pysollib/tk/selectcardset.py index 28adad16..9463a60e 100644 --- a/pysollib/tk/selectcardset.py +++ b/pysollib/tk/selectcardset.py @@ -35,10 +35,10 @@ from pysollib.resource import CSI # Toolkit imports from pysollib.ui.tktile.tkutil import loadImage -from tkwidget import MfxDialog, MfxScrolledCanvas +from .tkwidget import MfxDialog, MfxScrolledCanvas from pysollib.ui.tktile.tkcanvas import MfxCanvasImage -from selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode -from selecttree import SelectDialogTreeData, SelectDialogTreeCanvas +from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode +from .selecttree import SelectDialogTreeData, SelectDialogTreeCanvas # ************************************************************************ @@ -73,7 +73,7 @@ class SelectCardsetData(SelectDialogTreeData): None, None, _("(no cardsets)"), key=None), ] # select_by_type = None - items = CSI.TYPE.items() + items = list(CSI.TYPE.items()) items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: @@ -86,7 +86,7 @@ class SelectCardsetData(SelectDialogTreeData): None, _("by Type"), tuple(nodes), expanded=1) # select_by_style = None - items = CSI.STYLE.items() + items = list(CSI.STYLE.items()) items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: @@ -102,7 +102,7 @@ class SelectCardsetData(SelectDialogTreeData): None, _("by Style"), tuple(nodes)) # select_by_nationality = None - items = CSI.NATIONALITY.items() + items = list(CSI.NATIONALITY.items()) items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: @@ -120,7 +120,7 @@ class SelectCardsetData(SelectDialogTreeData): None, _("by Nationality"), tuple(nodes)) # select_by_date = None - items = CSI.DATE.items() + items = list(CSI.DATE.items()) items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: @@ -135,7 +135,7 @@ class SelectCardsetData(SelectDialogTreeData): select_by_date = SelectCardsetNode( None, _("by Date"), tuple(nodes)) # - self.rootnodes = filter(None, ( + self.rootnodes = [_f for _f in ( SelectCardsetNode( None, _("All Cardsets"), lambda cs: 1, expanded=len(self.all_objects) <= 12), @@ -160,7 +160,7 @@ class SelectCardsetData(SelectDialogTreeData): select_by_style, select_by_date, select_by_nationality, - )) + ) if _f] class SelectCardsetByTypeData(SelectDialogTreeData): @@ -170,7 +170,7 @@ class SelectCardsetByTypeData(SelectDialogTreeData): self.no_contents = [SelectCardsetLeaf( None, None, _("(no cardsets)"), key=None), ] # - items = CSI.TYPE.items() + items = list(CSI.TYPE.items()) items.sort(key=lambda x: x[1]) nodes = [] for key, name in items: @@ -180,9 +180,9 @@ class SelectCardsetByTypeData(SelectDialogTreeData): select_by_type = SelectCardsetNode( None, _("by Type"), tuple(nodes), expanded=1) # - self.rootnodes = filter(None, ( + self.rootnodes = [_f for _f in ( select_by_type, - )) + ) if _f] # ************************************************************************ diff --git a/pysollib/tk/selectgame.py b/pysollib/tk/selectgame.py index f73cd57e..5e4ac1cd 100644 --- a/pysollib/tk/selectgame.py +++ b/pysollib/tk/selectgame.py @@ -25,7 +25,7 @@ # imports import os from six.moves import tkinter -from UserList import UserList +from six.moves import UserList # PySol imports from pysollib.mygettext import _ @@ -37,9 +37,9 @@ from pysollib.resource import CSI # Toolkit imports from pysollib.ui.tktile.tkutil import unbind_destroy -from tkwidget import MfxDialog, MfxScrolledCanvas -from selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode -from selecttree import SelectDialogTreeData, SelectDialogTreeCanvas +from .tkwidget import MfxDialog, MfxScrolledCanvas +from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode +from .selecttree import SelectDialogTreeData, SelectDialogTreeCanvas # ************************************************************************ @@ -81,7 +81,9 @@ class SelectGameNode(SelectDialogTreeNode): class SelectGameData(SelectDialogTreeData): def __init__(self, app): SelectDialogTreeData.__init__(self) - self.all_games_gi = map(app.gdb.get, app.gdb.getGamesIdSortedByName()) + self.all_games_gi = list(map( + app.gdb.get, + app.gdb.getGamesIdSortedByName())) self.no_games = [SelectGameLeaf(None, None, _("(no games)"), None), ] # s_by_type = s_oriental = s_special = s_original = s_contrib = \ @@ -95,7 +97,8 @@ class SelectGameData(SelectDialogTreeData): ): gg = [] for name, select_func in data: - if name is None or not filter(select_func, self.all_games_gi): + if name is None or not list(filter( + select_func, self.all_games_gi)): continue gg.append(SelectGameNode(None, _(name), select_func)) g.append(gg) @@ -104,7 +107,7 @@ class SelectGameData(SelectDialogTreeData): return gi.si.game_type == GI.GT_MAHJONGG gg = None - if filter(select_mahjongg_game, self.all_games_gi): + if list(filter(select_mahjongg_game, self.all_games_gi)): gg = SelectGameNode(None, _("Mahjongg Games"), select_mahjongg_game) g.append(gg) @@ -129,7 +132,8 @@ class SelectGameData(SelectDialogTreeData): for name, games in GI.GAMES_BY_COMPATIBILITY: def select_func(gi, games=games): return gi.id in games - if name is None or not filter(select_func, self.all_games_gi): + if name is None or not list(filter( + select_func, self.all_games_gi)): continue gg.append(SelectGameNode(None, name, select_func)) if 1 and gg: @@ -141,7 +145,8 @@ class SelectGameData(SelectDialogTreeData): for name, games in GI.GAMES_BY_PYSOL_VERSION: def select_func(gi, games=games): return gi.id in games - if name is None or not filter(select_func, self.all_games_gi): + if name is None or not list(filter( + select_func, self.all_games_gi)): continue name = _("New games in v. ") + name gg.append(SelectGameNode(None, name, select_func)) @@ -152,7 +157,8 @@ class SelectGameData(SelectDialogTreeData): for name, games in GI.GAMES_BY_INVENTORS: def select_func(gi, games=games): return gi.id in games - if name is None or not filter(select_func, self.all_games_gi): + if name is None or not list(filter( + select_func, self.all_games_gi)): continue gg.append(SelectGameNode(None, name, select_func)) if 1 and gg: @@ -162,7 +168,7 @@ class SelectGameData(SelectDialogTreeData): ul_alternate_names = UserList( list(app.gdb.getGamesTuplesSortedByAlternateName())) # - self.rootnodes = filter(None, ( + self.rootnodes = [_f for _f in ( SelectGameNode(None, _("All Games"), None), SelectGameNode(None, _("Alternate Names"), ul_alternate_names), SelectGameNode(None, _("Popular Games"), @@ -253,7 +259,7 @@ class SelectGameData(SelectDialogTreeData): )), s_original, s_contrib, - )) + ) if _f] # ************************************************************************ diff --git a/pysollib/tk/selecttile.py b/pysollib/tk/selecttile.py index 31603cc0..45466eda 100644 --- a/pysollib/tk/selecttile.py +++ b/pysollib/tk/selecttile.py @@ -24,17 +24,16 @@ # imports import sys -from six.moves import tkinter -import tkColorChooser +from six.moves import tkinter, tkinter_colorchooser # PySol imports from pysollib.mygettext import _ from pysollib.mfxutil import KwStruct # Toolkit imports -from tkwidget import MfxDialog, MfxScrolledCanvas -from selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode -from selecttree import SelectDialogTreeData, SelectDialogTreeCanvas +from .tkwidget import MfxDialog, MfxScrolledCanvas +from .selecttree import SelectDialogTreeLeaf, SelectDialogTreeNode +from .selecttree import SelectDialogTreeData, SelectDialogTreeCanvas if sys.version_info > (3,): @@ -174,9 +173,10 @@ class SelectTileDialogWithPreview(MfxDialog): self.tree.n_expansions = 1 # save xyview in any case if button == 1: # "Solid color..." try: - c = tkColorChooser.askcolor(master=self.top, - initialcolor=self.table_color, - title=_("Select table color")) + c = tkinter_colorchooser.askcolor( + master=self.top, + initialcolor=self.table_color, + title=_("Select table color")) except tkinter.TclError: pass else: diff --git a/pysollib/tk/selecttree.py b/pysollib/tk/selecttree.py index 48101f18..f7057e74 100644 --- a/pysollib/tk/selecttree.py +++ b/pysollib/tk/selecttree.py @@ -26,7 +26,7 @@ __all__ = ['SelectDialogTreeData'] # imports # Toolkit imports -from tktree import MfxTreeLeaf, MfxTreeNode, MfxTreeInCanvas +from .tktree import MfxTreeLeaf, MfxTreeNode, MfxTreeInCanvas from pysollib.ui.tktile.selecttree import BaseSelectDialogTreeLeaf, \ BaseSelectDialogTreeNode, SelectDialogTreeData, \ diff --git a/pysollib/tk/soundoptionsdialog.py b/pysollib/tk/soundoptionsdialog.py index 38150cbb..5471ede2 100644 --- a/pysollib/tk/soundoptionsdialog.py +++ b/pysollib/tk/soundoptionsdialog.py @@ -35,7 +35,7 @@ from pysollib.pysolaudio import pysolsoundserver # Toolkit imports from pysollib.ui.tktile.tkconst import EVENT_HANDLED -from tkwidget import MfxDialog, MfxMessageDialog +from .tkwidget import MfxDialog, MfxMessageDialog # ************************************************************************ # * diff --git a/pysollib/tk/statusbar.py b/pysollib/tk/statusbar.py index b1d86559..a3eb56cf 100644 --- a/pysollib/tk/statusbar.py +++ b/pysollib/tk/statusbar.py @@ -29,7 +29,7 @@ import os import sys from six.moves import tkinter from pysollib.mygettext import _ -from tkwidget import MfxTooltip +from .tkwidget import MfxTooltip from pysollib.settings import WIN_SYSTEM if sys.version_info > (3,):