mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
2to3 on pysollib/ui/tktile/*.py
This commit is contained in:
parent
0a1d91ca76
commit
e6894094ec
6 changed files with 29 additions and 24 deletions
|
@ -23,7 +23,7 @@
|
|||
|
||||
# imports
|
||||
from six.moves import tkinter
|
||||
from tkColorChooser import askcolor
|
||||
from six.moves.tkinter_colorchooser import askcolor
|
||||
|
||||
# PySol imports
|
||||
from pysollib.mygettext import _
|
||||
|
|
|
@ -146,7 +146,7 @@ class BaseGameInfoDialog:
|
|||
fs[cn] += 1
|
||||
else:
|
||||
fs[cn] = 1
|
||||
t = '\n'.join(['%s (%d)' % (i[0], i[1]) for i in fs.items()])
|
||||
t = '\n'.join(['%s (%d)' % (i[0], i[1]) for i in list(fs.items())])
|
||||
else:
|
||||
t = stacks.__class__.__name__
|
||||
self._calcToolkit().Label(
|
||||
|
|
|
@ -4,7 +4,7 @@ import re
|
|||
import sys
|
||||
|
||||
from six.moves import tkinter
|
||||
import tkFileDialog
|
||||
from six.moves import tkinter_filedialog
|
||||
|
||||
from pysollib.mfxutil import Struct, kwdefault
|
||||
from pysollib.mfxutil import Image, USE_PIL
|
||||
|
@ -782,7 +782,8 @@ class PysolMenubarTkCommon:
|
|||
def _addSelectGameMenu(self, menu):
|
||||
# games = map(self.app.gdb.get,
|
||||
# self.app.gdb.getGamesIdSortedByShortName())
|
||||
games = map(self.app.gdb.get, self.app.gdb.getGamesIdSortedByName())
|
||||
games = list(map(
|
||||
self.app.gdb.get, self.app.gdb.getGamesIdSortedByName()))
|
||||
# games = tuple(games)
|
||||
# menu = MfxMenu(menu, label="Select &game")
|
||||
m = "Ctrl-"
|
||||
|
@ -823,7 +824,7 @@ class PysolMenubarTkCommon:
|
|||
if label is None:
|
||||
need_sep = 1
|
||||
continue
|
||||
g = filter(select_func, games)
|
||||
g = list(filter(select_func, games))
|
||||
if not g:
|
||||
continue
|
||||
if need_sep:
|
||||
|
@ -835,13 +836,13 @@ class PysolMenubarTkCommon:
|
|||
def _getNumGames(self, games, select_data):
|
||||
ngames = 0
|
||||
for label, select_func in select_data:
|
||||
ngames += len(filter(select_func, games))
|
||||
ngames += len(list(filter(select_func, games)))
|
||||
return ngames
|
||||
|
||||
def _addSelectMahjonggGameSubMenu(self, games, menu, command, variable):
|
||||
def select_func(gi):
|
||||
return gi.si.game_type == GI.GT_MAHJONGG
|
||||
mahjongg_games = filter(select_func, games)
|
||||
mahjongg_games = list(filter(select_func, games))
|
||||
if len(mahjongg_games) == 0:
|
||||
return
|
||||
#
|
||||
|
@ -865,7 +866,7 @@ class PysolMenubarTkCommon:
|
|||
games[c].append(gi)
|
||||
else:
|
||||
games[c] = [gi]
|
||||
games = games.items()
|
||||
games = list(games.items())
|
||||
games.sort()
|
||||
g0 = []
|
||||
c0 = c1 = games[0][0]
|
||||
|
@ -882,7 +883,7 @@ class PysolMenubarTkCommon:
|
|||
def _addSelectPopularGameSubMenu(self, games, menu, command, variable):
|
||||
def select_func(gi):
|
||||
return gi.si.game_flags & GI.GT_POPULAR
|
||||
if len(filter(select_func, games)) == 0:
|
||||
if len(list(filter(select_func, games))) == 0:
|
||||
return
|
||||
data = (n_("&Popular games"), select_func)
|
||||
self._addSelectGameSubMenu(games, menu, (data, ),
|
||||
|
@ -917,7 +918,7 @@ class PysolMenubarTkCommon:
|
|||
|
||||
def select_func(gi):
|
||||
return gi.si.game_type == GI.GT_CUSTOM
|
||||
games = filter(select_func, games)
|
||||
games = list(filter(select_func, games))
|
||||
self.updateGamesMenu(submenu, games)
|
||||
|
||||
def _addSelectAllGameSubMenu(self, games, menu, command, variable):
|
||||
|
@ -1151,7 +1152,7 @@ class PysolMenubarTkCommon:
|
|||
idir, ifile = "", ""
|
||||
if not idir:
|
||||
idir = self.app.dn.savegames
|
||||
d = tkFileDialog.Open()
|
||||
d = tkinter_filedialog.Open()
|
||||
filename = d.show(filetypes=self.FILETYPES,
|
||||
defaultextension=self.DEFAULTEXTENSION,
|
||||
initialdir=idir, initialfile=ifile)
|
||||
|
@ -1188,7 +1189,7 @@ Unsupported game for export.
|
|||
if not idir:
|
||||
idir = self.app.dn.savegames
|
||||
# print self.game.filename, ifile
|
||||
d = tkFileDialog.SaveAs()
|
||||
d = tkinter_filedialog.SaveAs()
|
||||
filename = d.show(filetypes=self.FILETYPES,
|
||||
defaultextension=self.DEFAULTEXTENSION,
|
||||
initialdir=idir, initialfile=ifile)
|
||||
|
@ -1219,7 +1220,7 @@ Unsupported game for export.
|
|||
if not idir:
|
||||
idir = self.app.dn.savegames
|
||||
# print self.game.filename, ifile
|
||||
d = tkFileDialog.SaveAs()
|
||||
d = tkinter_filedialog.SaveAs()
|
||||
filename = d.show(filetypes=self.FILETYPES,
|
||||
defaultextension=self.DEFAULTEXTENSION,
|
||||
initialdir=idir, initialfile=ifile)
|
||||
|
@ -1633,9 +1634,9 @@ Error while saving game.
|
|||
|
||||
def select_func(gi):
|
||||
return gi.si.game_type == GI.GT_CUSTOM
|
||||
games = map(self.app.gdb.get,
|
||||
self.app.gdb.getGamesIdSortedByName())
|
||||
games = filter(select_func, games)
|
||||
games = list(map(self.app.gdb.get,
|
||||
self.app.gdb.getGamesIdSortedByName()))
|
||||
games = list(filter(select_func, games))
|
||||
self.updateGamesMenu(menu, games)
|
||||
|
||||
self.tkopt.gameid.set(gameid)
|
||||
|
|
|
@ -264,7 +264,7 @@ class MfxCanvas(tkinter.Canvas):
|
|||
# delete all CanvasItems, but keep the background and top tiles
|
||||
def deleteAllItems(self):
|
||||
self._text_items = []
|
||||
for id in self.items.keys():
|
||||
for id in list(self.items.keys()):
|
||||
assert id not in self.__tiles # because the tile is created by id
|
||||
unbind_destroy(self.items[id])
|
||||
self.items[id].delete()
|
||||
|
@ -372,11 +372,11 @@ class MfxCanvas(tkinter.Canvas):
|
|||
#
|
||||
|
||||
def hideAllItems(self):
|
||||
for item in self.items.values():
|
||||
for item in list(self.items.values()):
|
||||
item.config(state='hidden')
|
||||
|
||||
def showAllItems(self):
|
||||
for item in self.items.values():
|
||||
for item in list(self.items.values()):
|
||||
item.config(state='normal')
|
||||
|
||||
#
|
||||
|
|
|
@ -255,8 +255,10 @@ class Base_HTMLViewer:
|
|||
if baseurl is None:
|
||||
baseurl = self.url
|
||||
if 0:
|
||||
import urllib
|
||||
url = urllib.pathname2url(url)
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
import urllib.error
|
||||
url = urllib.request.pathname2url(url)
|
||||
if relpath and self.url:
|
||||
url = urllib.basejoin(baseurl, url)
|
||||
else:
|
||||
|
@ -316,8 +318,10 @@ to open the following URL:
|
|||
try:
|
||||
file = None
|
||||
if 0:
|
||||
import urllib
|
||||
file = urllib.urlopen(url)
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
import urllib.error
|
||||
file = urllib.request.urlopen(url)
|
||||
else:
|
||||
file, url = self.openfile(url)
|
||||
data = file.read()
|
||||
|
|
|
@ -83,7 +83,7 @@ def wm_get_geometry(window):
|
|||
m = __wm_get_geometry_re.search(g)
|
||||
if not m:
|
||||
raise tkinter.TclError("invalid geometry "+str(g))
|
||||
l = map(int, m.groups())
|
||||
l = list(map(int, m.groups()))
|
||||
if window.wm_state() == "zoomed":
|
||||
# workaround as Tk returns the "unzoomed" origin
|
||||
l[2] = l[3] = 0
|
||||
|
|
Loading…
Add table
Reference in a new issue