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

Preemptive tkinter conversion to py2/py3.

Using the six module. Did it before 2to3 reports it.
This commit is contained in:
Shlomi Fish 2017-05-22 18:38:20 +03:00
parent 0a56ffe224
commit 72a2591ec1
48 changed files with 533 additions and 535 deletions

View file

@ -28,7 +28,7 @@ __all__ = ['create_find_card_dialog',
# imports # imports
# import os # import os
# import Tkinter # from six.moves import tkinter
# import traceback # import traceback
# # PySol imports # # PySol imports

View file

@ -26,7 +26,7 @@ __all__ = ['GameInfoDialog']
# # imports # # imports
# import os, sys # import os, sys
# import Tkinter # from six.moves import tkinter
# # PySol imports # # PySol imports
# from pysollib.mfxutil import KwStruct # from pysollib.mfxutil import KwStruct

View file

@ -23,7 +23,7 @@
# #
# This files tries to wrap a limited subset of the Tkinter canvas # This files tries to wrap a limited subset of the tkinter canvas
# into GTK / Gnome. # into GTK / Gnome.
# #
@ -282,7 +282,7 @@ class MfxCanvasText(_CanvasItem):
class MfxCanvas(gnomecanvas.Canvas): class MfxCanvas(gnomecanvas.Canvas):
def __init__(self, top, bg=None, highlightthickness=0): def __init__(self, top, bg=None, highlightthickness=0):
self.preview = 0 self.preview = 0
# Tkinter compat # tkinter compat
self.items = {} self.items = {}
self._all_items = [] self._all_items = []
self._text_items = [] self._text_items = []

View file

@ -425,7 +425,7 @@ class HTMLViewer:
def display(self, url, add=1, relpath=1, position=(0, 0)): def display(self, url, add=1, relpath=1, position=(0, 0)):
# print 'display:', url, position # print 'display:', url, position
# for some reason we have to stop the PySol demo # for some reason we have to stop the PySol demo
# (is this a multithread problem with Tkinter ?) # (is this a multithread problem with tkinter ?)
try: try:
# self.app.game.stopDemo() # self.app.game.stopDemo()
# self.app.game._cancelDrag() # self.app.game._cancelDrag()

View file

@ -24,7 +24,7 @@
__all__ = ['FontsDialog'] __all__ = ['FontsDialog']
# imports # imports
import Tkinter from six.moves import tkinter
import ttk import ttk
import tkFont import tkFont
@ -74,12 +74,12 @@ class FontChooserDialog(MfxDialog):
else: else:
raise ValueError('invalid font style: '+init_font[3]) raise ValueError('invalid font style: '+init_font[3])
# self.family_var = Tkinter.StringVar() # self.family_var = tkinter.StringVar()
self.weight_var = Tkinter.BooleanVar() self.weight_var = tkinter.BooleanVar()
self.weight_var.set(self.font_weight == 'bold') self.weight_var.set(self.font_weight == 'bold')
self.slant_var = Tkinter.BooleanVar() self.slant_var = tkinter.BooleanVar()
self.slant_var.set(self.font_slant == 'italic') self.slant_var.set(self.font_slant == 'italic')
self.size_var = Tkinter.IntVar() self.size_var = tkinter.IntVar()
self.size_var.set(self.font_size) self.size_var.set(self.font_size)
# #
frame = ttk.Frame(top_frame) frame = ttk.Frame(top_frame)
@ -89,7 +89,7 @@ class FontChooserDialog(MfxDialog):
self.entry = ttk.Entry(frame) self.entry = ttk.Entry(frame)
self.entry.grid(row=0, column=0, columnspan=2, sticky='news') self.entry.grid(row=0, column=0, columnspan=2, sticky='news')
self.entry.insert('end', _('abcdefghABCDEFGH')) self.entry.insert('end', _('abcdefghABCDEFGH'))
self.list_box = Tkinter.Listbox(frame, width=36, exportselection=False) self.list_box = tkinter.Listbox(frame, width=36, exportselection=False)
sb = ttk.Scrollbar(frame) sb = ttk.Scrollbar(frame)
self.list_box.configure(yscrollcommand=sb.set) self.list_box.configure(yscrollcommand=sb.set)
sb.configure(command=self.list_box.yview) sb.configure(command=self.list_box.yview)

View file

@ -24,7 +24,7 @@
__all__ = ['PlayerOptionsDialog'] __all__ = ['PlayerOptionsDialog']
# imports # imports
import Tkinter from six.moves import tkinter
import ttk import ttk
# PySol imports # PySol imports
@ -47,11 +47,11 @@ class PlayerOptionsDialog(MfxDialog):
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
self.app = app self.app = app
# #
self.update_stats_var = Tkinter.BooleanVar() self.update_stats_var = tkinter.BooleanVar()
self.update_stats_var.set(app.opt.update_player_stats != 0) self.update_stats_var.set(app.opt.update_player_stats != 0)
self.confirm_var = Tkinter.BooleanVar() self.confirm_var = tkinter.BooleanVar()
self.confirm_var.set(app.opt.confirm != 0) self.confirm_var.set(app.opt.confirm != 0)
self.win_animation_var = Tkinter.BooleanVar() self.win_animation_var = tkinter.BooleanVar()
self.win_animation_var.set(app.opt.win_animation != 0) self.win_animation_var.set(app.opt.win_animation != 0)
# #
frame = ttk.Frame(top_frame) frame = ttk.Frame(top_frame)

View file

@ -24,7 +24,7 @@
__all__ = ['PysolProgressBar'] __all__ = ['PysolProgressBar']
# imports # imports
import Tkinter from six.moves import tkinter
import ttk import ttk
# Toolkit imports # Toolkit imports
@ -122,7 +122,7 @@ class TestProgressBar:
def progressbar_main(args): def progressbar_main(args):
from pysollib.ui.tktile.tkutil import wm_withdraw from pysollib.ui.tktile.tkutil import wm_withdraw
tk = Tkinter.Tk() tk = tkinter.Tk()
wm_withdraw(tk) wm_withdraw(tk)
TestProgressBar(tk) TestProgressBar(tk)
tk.mainloop() tk.mainloop()

View file

@ -25,7 +25,7 @@ __all__ = ['SelectCardsetDialogWithPreview']
# imports # imports
import os import os
import Tkinter from six.moves import tkinter
import ttk import ttk
# PySol imports # PySol imports
@ -245,7 +245,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
padx=padx, pady=pady) padx=padx, pady=pady)
if USE_PIL: if USE_PIL:
# #
var = Tkinter.DoubleVar() var = tkinter.DoubleVar()
var.set(app.opt.scale_x) var.set(app.opt.scale_x)
self.scale_x = PysolScale( self.scale_x = PysolScale(
left_frame, label=_('Scale X:'), left_frame, label=_('Scale X:'),
@ -256,7 +256,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
self.scale_x.grid( self.scale_x.grid(
row=1, column=0, sticky='ew', padx=padx, pady=pady) row=1, column=0, sticky='ew', padx=padx, pady=pady)
# #
var = Tkinter.DoubleVar() var = tkinter.DoubleVar()
var.set(app.opt.scale_y) var.set(app.opt.scale_y)
self.scale_y = PysolScale( self.scale_y = PysolScale(
left_frame, label=_('Scale Y:'), left_frame, label=_('Scale Y:'),
@ -267,7 +267,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
self.scale_y.grid( self.scale_y.grid(
row=2, column=0, sticky='ew', padx=padx, pady=pady) row=2, column=0, sticky='ew', padx=padx, pady=pady)
# #
self.auto_scale = Tkinter.BooleanVar() self.auto_scale = tkinter.BooleanVar()
self.auto_scale.set(app.opt.auto_scale) self.auto_scale.set(app.opt.auto_scale)
check = ttk.Checkbutton( check = ttk.Checkbutton(
left_frame, text=_('Auto scaling'), left_frame, text=_('Auto scaling'),
@ -278,7 +278,7 @@ class SelectCardsetDialogWithPreview(MfxDialog):
check.grid(row=3, column=0, columnspan=2, sticky='ew', check.grid(row=3, column=0, columnspan=2, sticky='ew',
padx=padx, pady=pady) padx=padx, pady=pady)
# #
self.preserve_aspect = Tkinter.BooleanVar() self.preserve_aspect = tkinter.BooleanVar()
self.preserve_aspect.set(app.opt.preserve_aspect_ratio) self.preserve_aspect.set(app.opt.preserve_aspect_ratio)
self.aspect_check = ttk.Checkbutton( self.aspect_check = ttk.Checkbutton(
left_frame, text=_('Preserve aspect ratio'), left_frame, text=_('Preserve aspect ratio'),
@ -492,7 +492,7 @@ class CardsetInfoDialog(MfxDialog):
settings_frame.grid(row=row, column=0, columnspan=2, sticky='ew', settings_frame.grid(row=row, column=0, columnspan=2, sticky='ew',
padx=0, pady=5, ipadx=5, ipady=5) padx=0, pady=5, ipadx=5, ipady=5)
row += 1 row += 1
var = Tkinter.IntVar() var = tkinter.IntVar()
self.x_offset = PysolScale( self.x_offset = PysolScale(
settings_frame, label=_('X offset:'), settings_frame, label=_('X offset:'),
from_=5, to=40, resolution=1, from_=5, to=40, resolution=1,
@ -502,7 +502,7 @@ class CardsetInfoDialog(MfxDialog):
) )
self.x_offset.grid(row=0, column=0, sticky='ew', self.x_offset.grid(row=0, column=0, sticky='ew',
padx=padx, pady=pady) padx=padx, pady=pady)
var = Tkinter.IntVar() var = tkinter.IntVar()
self.y_offset = PysolScale( self.y_offset = PysolScale(
settings_frame, label=_('Y offset:'), settings_frame, label=_('Y offset:'),
from_=5, to=40, resolution=1, from_=5, to=40, resolution=1,
@ -516,7 +516,7 @@ class CardsetInfoDialog(MfxDialog):
# bg = top_frame["bg"] # bg = top_frame["bg"]
bg = 'white' bg = 'white'
text_w = Tkinter.Text(frame, bd=1, relief="sunken", wrap="word", text_w = tkinter.Text(frame, bd=1, relief="sunken", wrap="word",
padx=4, width=64, height=16, bg=bg) padx=4, width=64, height=16, bg=bg)
text_w.grid(row=row, column=0, sticky='nsew') text_w.grid(row=row, column=0, sticky='nsew')
sb = ttk.Scrollbar(frame) sb = ttk.Scrollbar(frame)

View file

@ -24,7 +24,7 @@
# imports # imports
import sys import sys
import Tkinter from six.moves import tkinter
import ttk import ttk
import tkColorChooser import tkColorChooser
@ -178,7 +178,7 @@ class SelectTileDialogWithPreview(MfxDialog):
c = tkColorChooser.askcolor(master=self.top, c = tkColorChooser.askcolor(master=self.top,
initialcolor=self.table_color, initialcolor=self.table_color,
title=_("Select table color")) title=_("Select table color"))
except Tkinter.TclError: except tkinter.TclError:
pass pass
else: else:
if c and c[1]: if c and c[1]:

View file

@ -25,7 +25,7 @@ __all__ = ['SoundOptionsDialog']
# imports # imports
import os import os
import Tkinter from six.moves import tkinter
import ttk import ttk
# PySol imports # PySol imports
@ -54,42 +54,42 @@ class SoundOptionsDialog(MfxDialog):
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
# #
self.saved_opt = app.opt.copy() self.saved_opt = app.opt.copy()
self.sound = Tkinter.BooleanVar() self.sound = tkinter.BooleanVar()
self.sound.set(app.opt.sound != 0) self.sound.set(app.opt.sound != 0)
self.sound_mode = Tkinter.BooleanVar() self.sound_mode = tkinter.BooleanVar()
self.sound_mode.set(app.opt.sound_mode != 0) self.sound_mode.set(app.opt.sound_mode != 0)
self.sample_volume = Tkinter.IntVar() self.sample_volume = tkinter.IntVar()
self.sample_volume.set(app.opt.sound_sample_volume) self.sample_volume.set(app.opt.sound_sample_volume)
self.music_volume = Tkinter.IntVar() self.music_volume = tkinter.IntVar()
self.music_volume.set(app.opt.sound_music_volume) self.music_volume.set(app.opt.sound_music_volume)
self.samples = [ self.samples = [
('areyousure', _('Are You Sure'), Tkinter.BooleanVar()), ('areyousure', _('Are You Sure'), tkinter.BooleanVar()),
('deal', _('Deal'), Tkinter.BooleanVar()), ('deal', _('Deal'), tkinter.BooleanVar()),
('dealwaste', _('Deal waste'), Tkinter.BooleanVar()), ('dealwaste', _('Deal waste'), tkinter.BooleanVar()),
('turnwaste', _('Turn waste'), Tkinter.BooleanVar()), ('turnwaste', _('Turn waste'), tkinter.BooleanVar()),
('startdrag', _('Start drag'), Tkinter.BooleanVar()), ('startdrag', _('Start drag'), tkinter.BooleanVar()),
('drop', _('Drop'), Tkinter.BooleanVar()), ('drop', _('Drop'), tkinter.BooleanVar()),
('droppair', _('Drop pair'), Tkinter.BooleanVar()), ('droppair', _('Drop pair'), tkinter.BooleanVar()),
('autodrop', _('Auto drop'), Tkinter.BooleanVar()), ('autodrop', _('Auto drop'), tkinter.BooleanVar()),
('flip', _('Flip'), Tkinter.BooleanVar()), ('flip', _('Flip'), tkinter.BooleanVar()),
('autoflip', _('Auto flip'), Tkinter.BooleanVar()), ('autoflip', _('Auto flip'), tkinter.BooleanVar()),
('move', _('Move'), Tkinter.BooleanVar()), ('move', _('Move'), tkinter.BooleanVar()),
('nomove', _('No move'), Tkinter.BooleanVar()), ('nomove', _('No move'), tkinter.BooleanVar()),
('undo', _('Undo'), Tkinter.BooleanVar()), ('undo', _('Undo'), tkinter.BooleanVar()),
('redo', _('Redo'), Tkinter.BooleanVar()), ('redo', _('Redo'), tkinter.BooleanVar()),
('autopilotlost', _('Autopilot lost'), Tkinter.BooleanVar()), ('autopilotlost', _('Autopilot lost'), tkinter.BooleanVar()),
('autopilotwon', _('Autopilot won'), Tkinter.BooleanVar()), ('autopilotwon', _('Autopilot won'), tkinter.BooleanVar()),
('gamefinished', _('Game finished'), Tkinter.BooleanVar()), ('gamefinished', _('Game finished'), tkinter.BooleanVar()),
('gamelost', _('Game lost'), Tkinter.BooleanVar()), ('gamelost', _('Game lost'), tkinter.BooleanVar()),
('gamewon', _('Game won'), Tkinter.BooleanVar()), ('gamewon', _('Game won'), tkinter.BooleanVar()),
('gameperfect', _('Perfect game'), Tkinter.BooleanVar()), ('gameperfect', _('Perfect game'), tkinter.BooleanVar()),
] ]
# #

View file

@ -27,7 +27,7 @@ __all__ = ['PysolStatusbar',
# imports # imports
import os import os
import sys import sys
import Tkinter from six.moves import tkinter
import ttk import ttk
# PySol imports # PySol imports
@ -199,7 +199,7 @@ class TestStatusbar(PysolStatusbar):
def statusbar_main(args): def statusbar_main(args):
tk = Tkinter.Tk() tk = tkinter.Tk()
TestStatusbar(tk, args) TestStatusbar(tk, args)
tk.mainloop() tk.mainloop()
return 0 return 0

View file

@ -24,7 +24,7 @@
__all__ = ['TimeoutsDialog'] __all__ = ['TimeoutsDialog']
# imports # imports
import Tkinter from six.moves import tkinter
import ttk import ttk
# PySol imports # PySol imports
@ -50,17 +50,17 @@ class TimeoutsDialog(MfxDialog):
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
self.demo_sleep_var = Tkinter.DoubleVar() self.demo_sleep_var = tkinter.DoubleVar()
self.demo_sleep_var.set(app.opt.timeouts['demo']) self.demo_sleep_var.set(app.opt.timeouts['demo'])
self.hint_sleep_var = Tkinter.DoubleVar() self.hint_sleep_var = tkinter.DoubleVar()
self.hint_sleep_var.set(app.opt.timeouts['hint']) self.hint_sleep_var.set(app.opt.timeouts['hint'])
self.raise_card_sleep_var = Tkinter.DoubleVar() self.raise_card_sleep_var = tkinter.DoubleVar()
self.raise_card_sleep_var.set(app.opt.timeouts['raise_card']) self.raise_card_sleep_var.set(app.opt.timeouts['raise_card'])
self.highlight_piles_sleep_var = Tkinter.DoubleVar() self.highlight_piles_sleep_var = tkinter.DoubleVar()
self.highlight_piles_sleep_var.set(app.opt.timeouts['highlight_piles']) self.highlight_piles_sleep_var.set(app.opt.timeouts['highlight_piles'])
self.highlight_cards_sleep_var = Tkinter.DoubleVar() self.highlight_cards_sleep_var = tkinter.DoubleVar()
self.highlight_cards_sleep_var.set(app.opt.timeouts['highlight_cards']) self.highlight_cards_sleep_var.set(app.opt.timeouts['highlight_cards'])
self.highlight_samerank_sleep_var = Tkinter.DoubleVar() self.highlight_samerank_sleep_var = tkinter.DoubleVar()
self.highlight_samerank_sleep_var.set( self.highlight_samerank_sleep_var.set(
app.opt.timeouts['highlight_samerank']) app.opt.timeouts['highlight_samerank'])
# #

View file

@ -26,7 +26,7 @@ __all__ = ['HTMLViewer']
# imports # imports
import os import os
import sys import sys
import Tkinter from six.moves import tkinter
import ttk import ttk
# PySol imports # PySol imports
@ -102,7 +102,7 @@ class HTMLViewer(Base_HTMLViewer):
sticky='nsew', padx=1, pady=1) sticky='nsew', padx=1, pady=1)
vbar = ttk.Scrollbar(text_frame) vbar = ttk.Scrollbar(text_frame)
vbar.pack(side='right', fill='y') vbar.pack(side='right', fill='y')
self.text = Tkinter.Text(text_frame, self.text = tkinter.Text(text_frame,
fg='black', bg='white', fg='black', bg='white',
bd=1, relief='sunken', bd=1, relief='sunken',
cursor=self.defcursor, cursor=self.defcursor,
@ -134,7 +134,7 @@ def tkhtml_main(args):
url = args[1] url = args[1]
except: except:
url = os.path.join(os.pardir, os.pardir, "data", "html", "index.html") url = os.path.join(os.pardir, os.pardir, "data", "html", "index.html")
top = Tkinter.Tk() top = tkinter.Tk()
top.tk.call("package", "require", "tile") top.tk.call("package", "require", "tile")
top.wm_minsize(400, 200) top.wm_minsize(400, 200)
viewer = HTMLViewer(top) viewer = HTMLViewer(top)

View file

@ -33,7 +33,7 @@ __all__ = ['SingleGame_StatsDialog',
# imports # imports
import os import os
import time import time
import Tkinter from six.moves import tkinter
import ttk import ttk
import tkFont import tkFont
@ -231,7 +231,7 @@ class SingleGameFrame(ttk.Frame):
self.fg = fg self.fg = fg
# #
w, h = self.tab_x[-1], max(self.tab_y[-1], self.oval_height+40) w, h = self.tab_x[-1], max(self.tab_y[-1], self.oval_height+40)
c = Tkinter.Canvas(frame, width=w, height=h, c = tkinter.Canvas(frame, width=w, height=h,
bg=bg, highlightthickness=0) bg=bg, highlightthickness=0)
c.pack(fill='both', expand=True) c.pack(fill='both', expand=True)
self.canvas = c self.canvas = c
@ -880,7 +880,7 @@ class ProgressionFrame(ttk.Frame):
self.won_color = '#00dc28' self.won_color = '#00dc28'
self.percent_color = 'blue' self.percent_color = 'blue'
# create canvas # create canvas
self.canvas = canvas = Tkinter.Canvas(frame, bg='#dfe8ff', bd=0, self.canvas = canvas = tkinter.Canvas(frame, bg='#dfe8ff', bd=0,
highlightthickness=1, highlightthickness=1,
highlightbackground='black', highlightbackground='black',
width=self.canvas_width, width=self.canvas_width,
@ -890,7 +890,7 @@ class ProgressionFrame(ttk.Frame):
# right frame # right frame
right_frame = ttk.Frame(frame) right_frame = ttk.Frame(frame)
right_frame.pack(side='left', fill='x', padx=5) right_frame.pack(side='left', fill='x', padx=5)
self.all_games_variable = var = Tkinter.StringVar() self.all_games_variable = var = tkinter.StringVar()
var.set('all') var.set('all')
b = ttk.Radiobutton(right_frame, text=_('All games'), b = ttk.Radiobutton(right_frame, text=_('All games'),
variable=var, value='all', variable=var, value='all',
@ -902,7 +902,7 @@ class ProgressionFrame(ttk.Frame):
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
label_frame = ttk.LabelFrame(right_frame, text=_('Statistics for')) label_frame = ttk.LabelFrame(right_frame, text=_('Statistics for'))
label_frame.pack(side='top', fill='x', pady=10) label_frame.pack(side='top', fill='x', pady=10)
self.variable = var = Tkinter.StringVar() self.variable = var = tkinter.StringVar()
var.set('week') var.set('week')
for v, t in ( for v, t in (
('week', _('Last 7 days')), ('week', _('Last 7 days')),
@ -915,19 +915,19 @@ class ProgressionFrame(ttk.Frame):
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
label_frame = ttk.LabelFrame(right_frame, text=_('Show graphs')) label_frame = ttk.LabelFrame(right_frame, text=_('Show graphs'))
label_frame.pack(side='top', fill='x') label_frame.pack(side='top', fill='x')
self.played_graph_var = Tkinter.BooleanVar() self.played_graph_var = tkinter.BooleanVar()
self.played_graph_var.set(True) self.played_graph_var.set(True)
b = ttk.Checkbutton(label_frame, text=_('Played'), b = ttk.Checkbutton(label_frame, text=_('Played'),
command=self.updateGraph, command=self.updateGraph,
variable=self.played_graph_var) variable=self.played_graph_var)
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
self.won_graph_var = Tkinter.BooleanVar() self.won_graph_var = tkinter.BooleanVar()
self.won_graph_var.set(True) self.won_graph_var.set(True)
b = ttk.Checkbutton(label_frame, text=_('Won'), b = ttk.Checkbutton(label_frame, text=_('Won'),
command=self.updateGraph, command=self.updateGraph,
variable=self.won_graph_var) variable=self.won_graph_var)
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
self.percent_graph_var = Tkinter.BooleanVar() self.percent_graph_var = tkinter.BooleanVar()
self.percent_graph_var.set(True) self.percent_graph_var.set(True)
b = ttk.Checkbutton(label_frame, text=_('% won'), b = ttk.Checkbutton(label_frame, text=_('% won'),
command=self.updateGraph, command=self.updateGraph,

View file

@ -23,7 +23,7 @@
# imports # imports
import os import os
import Tkinter from six.moves import tkinter
# Toolkit imports # Toolkit imports
from pysollib.ui.tktile.tkutil import bind from pysollib.ui.tktile.tkutil import bind
@ -106,7 +106,7 @@ class MfxTreeBaseNode:
try: try:
# _tkinter.TclError: unknown option "-fill" ??? # _tkinter.TclError: unknown option "-fill" ???
canvas.itemconfig(self.textrect_id, fill=bg) canvas.itemconfig(self.textrect_id, fill=bg)
except Tkinter.TclError: except tkinter.TclError:
pass pass
elif self.selected: elif self.selected:
b = canvas.bbox(self.text_id) b = canvas.bbox(self.text_id)
@ -281,7 +281,7 @@ class MfxTreeInCanvas(MfxScrolledCanvas):
# draw # draw
try: try:
lx, ly, nx, ny = node.draw(nx, ny, None, None) lx, ly, nx, ny = node.draw(nx, ny, None, None)
except Tkinter.TclError: except tkinter.TclError:
# FIXME: Tk bug ??? # FIXME: Tk bug ???
raise raise
# set scroll region # set scroll region
@ -405,7 +405,7 @@ class DirectoryBrowser(MfxTreeInCanvas):
if __name__ == "__main__": if __name__ == "__main__":
tk = Tkinter.Tk() tk = tkinter.Tk()
if os.name == "nt": if os.name == "nt":
app = DirectoryBrowser(tk, ("c:\\", "c:\\windows")) app = DirectoryBrowser(tk, ("c:\\", "c:\\windows"))
else: else:

View file

@ -36,7 +36,7 @@ import sys
import os import os
import time import time
import locale import locale
import Tkinter from six.moves import tkinter
import ttk import ttk
import tkFont import tkFont
import traceback import traceback
@ -89,7 +89,7 @@ class MfxDialog: # ex. _ToplevelDialog
setTransient(self.top, self.parent) setTransient(self.top, self.parent)
try: try:
self.top.grab_set() self.top.grab_set()
except Tkinter.TclError: except tkinter.TclError:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
pass pass
@ -460,11 +460,11 @@ class MfxTooltip:
y = self.widget.winfo_rooty() + self.widget.winfo_height() y = self.widget.winfo_rooty() + self.widget.winfo_height()
x += self.xoffset x += self.xoffset
y += self.yoffset y += self.yoffset
self.tooltip = Tkinter.Toplevel() self.tooltip = tkinter.Toplevel()
self.tooltip.wm_iconify() self.tooltip.wm_iconify()
self.tooltip.wm_overrideredirect(1) self.tooltip.wm_overrideredirect(1)
self.tooltip.wm_protocol("WM_DELETE_WINDOW", self.destroy) self.tooltip.wm_protocol("WM_DELETE_WINDOW", self.destroy)
self.label = Tkinter.Label(self.tooltip, text=self.text, self.label = tkinter.Label(self.tooltip, text=self.text,
relief=self.relief, justify=self.justify, relief=self.relief, justify=self.justify,
fg=self.fg, bg=self.bg, bd=1, takefocus=0) fg=self.fg, bg=self.bg, bd=1, takefocus=0)
self.label.pack(ipadx=1, ipady=1) self.label.pack(ipadx=1, ipady=1)
@ -573,7 +573,7 @@ class MfxScrolledCanvas:
kw['bd'] = 0 kw['bd'] = 0
relief = kw['relief'] relief = kw['relief']
del kw['relief'] del kw['relief']
frame = Tkinter.Frame(self.frame, bd=bd, relief=relief) frame = tkinter.Frame(self.frame, bd=bd, relief=relief)
frame.grid(row=0, column=0, sticky="news") frame.grid(row=0, column=0, sticky="news")
self.canvas = MfxCanvas(frame, **kw) self.canvas = MfxCanvas(frame, **kw)
self.canvas.pack(expand=True, fill='both') self.canvas.pack(expand=True, fill='both')
@ -712,9 +712,9 @@ class StackDesc:
text = stack.getHelp()+'\n'+stack.getBaseCard() text = stack.getHelp()+'\n'+stack.getBaseCard()
text = text.strip() text = text.strip()
if text: if text:
frame = Tkinter.Frame(self.canvas) frame = tkinter.Frame(self.canvas)
self.frame = frame self.frame = frame
label = Tkinter.Message(frame, font=font, text=text, label = tkinter.Message(frame, font=font, text=text,
width=cardw-8, relief='solid', width=cardw-8, relief='solid',
fg='#000000', bg='#ffffe0', bd=1) fg='#000000', bg='#ffffe0', bd=1)
label.pack() label.pack()
@ -839,11 +839,11 @@ class MyPysolScale:
self.variable.set(v) self.variable.set(v)
class TkinterScale(Tkinter.Scale): class TkinterScale(tkinter.Scale):
def __init__(self, parent, **kw): def __init__(self, parent, **kw):
if 'value' in kw: if 'value' in kw:
del kw['value'] del kw['value']
Tkinter.Scale.__init__(self, parent, **kw) tkinter.Scale.__init__(self, parent, **kw)
PysolScale = MyPysolScale PysolScale = MyPysolScale

View file

@ -25,7 +25,7 @@ __all__ = ['PysolToolbarTk']
# imports # imports
import os import os
import Tkinter from six.moves import tkinter
import ttk import ttk
# PySol imports # PySol imports
@ -127,9 +127,9 @@ class ToolbarSeparator(ttk.Separator):
self.grid_forget() self.grid_forget()
class ToolbarLabel(Tkinter.Message): class ToolbarLabel(tkinter.Message):
def __init__(self, parent, toolbar, toolbar_name, position, **kwargs): def __init__(self, parent, toolbar, toolbar_name, position, **kwargs):
Tkinter.Message.__init__(self, parent, **kwargs) tkinter.Message.__init__(self, parent, **kwargs)
self.toolbar = toolbar self.toolbar = toolbar
self.toolbar_name = toolbar_name self.toolbar_name = toolbar_name
self.position = position self.position = position

View file

@ -25,16 +25,16 @@ __all__ = ["Button", "Checkbutton", "Combobox", "Entry", "Frame", "Label",
# functions # functions
"tclobjs_to_py"] "tclobjs_to_py"]
import Tkinter from six.moves import tkinter
from pysollib.mygettext import _, n_ from pysollib.mygettext import _, n_
_flatten = Tkinter._flatten _flatten = tkinter._flatten
# Verify if Tk is new enough to not need Tile checking # Verify if Tk is new enough to not need Tile checking
_REQUIRE_TILE = True if Tkinter.TkVersion < 8.5 else False _REQUIRE_TILE = True if tkinter.TkVersion < 8.5 else False
def _loadttk(loadtk): def _loadttk(loadtk):
# This extends the default Tkinter.Tk._loadtk method so we can be # This extends the default tkinter.Tk._loadtk method so we can be
# sure that ttk is available for use, or not. # sure that ttk is available for use, or not.
def _wrapper(self): def _wrapper(self):
loadtk(self) loadtk(self)
@ -52,7 +52,7 @@ def _loadttk(loadtk):
return _wrapper return _wrapper
Tkinter.Tk._loadtk = _loadttk(Tkinter.Tk._loadtk) tkinter.Tk._loadtk = _loadttk(tkinter.Tk._loadtk)
def _format_optdict(optdict, script=False, ignore=None): def _format_optdict(optdict, script=False, ignore=None):
"""Formats optdict to a tuple to pass it to tk.call. """Formats optdict to a tuple to pass it to tk.call.
@ -362,10 +362,10 @@ class Style(object):
def __init__(self, master=None): def __init__(self, master=None):
if master is None: if master is None:
if Tkinter._support_default_root: if tkinter._support_default_root:
master = Tkinter._default_root or Tkinter.Tk() master = tkinter._default_root or tkinter.Tk()
else: else:
raise RuntimeError("No master specified and Tkinter is " raise RuntimeError("No master specified and tkinter is "
"configured to not support default master") "configured to not support default master")
self.master = master self.master = master
@ -520,7 +520,7 @@ class Style(object):
self.tk.call("ttk::setTheme", themename) self.tk.call("ttk::setTheme", themename)
class Widget(Tkinter.Widget): class Widget(tkinter.Widget):
"""Base class for Tk themed widgets.""" """Base class for Tk themed widgets."""
def __init__(self, master, widgetname, kw=None): def __init__(self, master, widgetname, kw=None):
@ -543,7 +543,7 @@ class Widget(Tkinter.Widget):
active, disabled, focus, pressed, selected, background, active, disabled, focus, pressed, selected, background,
readonly, alternate, invalid readonly, alternate, invalid
""" """
Tkinter.Widget.__init__(self, master, widgetname, kw=kw) tkinter.Widget.__init__(self, master, widgetname, kw=kw)
def identify(self, x, y): def identify(self, x, y):
@ -634,7 +634,7 @@ class Checkbutton(Widget):
return self.tk.call(self._w, "invoke") return self.tk.call(self._w, "invoke")
class Entry(Widget, Tkinter.Entry): class Entry(Widget, tkinter.Entry):
"""Ttk Entry widget displays a one-line text string and allows that """Ttk Entry widget displays a one-line text string and allows that
string to be edited by the user.""" string to be edited by the user."""
@ -784,7 +784,7 @@ class Labelframe(Widget):
""" """
Widget.__init__(self, master, "ttk::labelframe", kw) Widget.__init__(self, master, "ttk::labelframe", kw)
LabelFrame = Labelframe # Tkinter name compatibility LabelFrame = Labelframe # tkinter name compatibility
class Menubutton(Widget): class Menubutton(Widget):
@ -939,7 +939,7 @@ class Notebook(Widget):
self.tk.call("ttk::notebook::enableTraversal", self._w) self.tk.call("ttk::notebook::enableTraversal", self._w)
class Panedwindow(Widget, Tkinter.PanedWindow): class Panedwindow(Widget, tkinter.PanedWindow):
"""Ttk Panedwindow widget displays a number of subwindows, stacked """Ttk Panedwindow widget displays a number of subwindows, stacked
either vertically or horizontally.""" either vertically or horizontally."""
@ -961,7 +961,7 @@ class Panedwindow(Widget, Tkinter.PanedWindow):
Widget.__init__(self, master, "ttk::panedwindow", kw) Widget.__init__(self, master, "ttk::panedwindow", kw)
forget = Tkinter.PanedWindow.forget # overrides Pack.forget forget = tkinter.PanedWindow.forget # overrides Pack.forget
def insert(self, pos, child, **kw): def insert(self, pos, child, **kw):
@ -995,7 +995,7 @@ class Panedwindow(Widget, Tkinter.PanedWindow):
Returns the new position of sash number index.""" Returns the new position of sash number index."""
return self.tk.call(self._w, "sashpos", index, newpos) return self.tk.call(self._w, "sashpos", index, newpos)
PanedWindow = Panedwindow # Tkinter name compatibility PanedWindow = Panedwindow # tkinter name compatibility
class Progressbar(Widget): class Progressbar(Widget):
@ -1068,7 +1068,7 @@ class Radiobutton(Widget):
return self.tk.call(self._w, "invoke") return self.tk.call(self._w, "invoke")
class Scale(Widget, Tkinter.Scale): class Scale(Widget, tkinter.Scale):
"""Ttk Scale widget is typically used to control the numeric value of """Ttk Scale widget is typically used to control the numeric value of
a linked variable that varies uniformly over some range.""" a linked variable that varies uniformly over some range."""
@ -1107,7 +1107,7 @@ class Scale(Widget, Tkinter.Scale):
return self.tk.call(self._w, 'get', x, y) return self.tk.call(self._w, 'get', x, y)
class Scrollbar(Widget, Tkinter.Scrollbar): class Scrollbar(Widget, tkinter.Scrollbar):
"""Ttk Scrollbar controls the viewport of a scrollable widget.""" """Ttk Scrollbar controls the viewport of a scrollable widget."""
def __init__(self, master=None, **kw): def __init__(self, master=None, **kw):
@ -1487,7 +1487,7 @@ class LabeledScale(Frame, object):
def __init__(self, master=None, variable=None, from_=0, to=10, **kw): def __init__(self, master=None, variable=None, from_=0, to=10, **kw):
"""Construct an horizontal LabeledScale with parent master, a """Construct an horizontal LabeledScale with parent master, a
variable to be associated with the Ttk Scale widget and its range. variable to be associated with the Ttk Scale widget and its range.
If variable is not specified, a Tkinter.IntVar is created. If variable is not specified, a tkinter.IntVar is created.
WIDGET-SPECIFIC OPTIONS WIDGET-SPECIFIC OPTIONS
@ -1498,7 +1498,7 @@ class LabeledScale(Frame, object):
self._label_top = kw.pop('compound', 'top') == 'top' self._label_top = kw.pop('compound', 'top') == 'top'
Frame.__init__(self, master, **kw) Frame.__init__(self, master, **kw)
self._variable = variable or Tkinter.IntVar(master) self._variable = variable or tkinter.IntVar(master)
self._variable.set(from_) self._variable.set(from_)
self._last_valid = from_ self._last_valid = from_
@ -1567,7 +1567,7 @@ class LabeledScale(Frame, object):
class OptionMenu(Menubutton): class OptionMenu(Menubutton):
"""Themed OptionMenu, based after Tkinter's OptionMenu, which allows """Themed OptionMenu, based after tkinter's OptionMenu, which allows
the user to select a value from a menu.""" the user to select a value from a menu."""
def __init__(self, master, variable, default=None, *values, **kwargs): def __init__(self, master, variable, default=None, *values, **kwargs):
@ -1588,12 +1588,12 @@ class OptionMenu(Menubutton):
kw = {'textvariable': variable, 'style': kwargs.pop('style', None), kw = {'textvariable': variable, 'style': kwargs.pop('style', None),
'direction': kwargs.pop('direction', None)} 'direction': kwargs.pop('direction', None)}
Menubutton.__init__(self, master, **kw) Menubutton.__init__(self, master, **kw)
self['menu'] = Tkinter.Menu(self, tearoff=False) self['menu'] = tkinter.Menu(self, tearoff=False)
self._variable = variable self._variable = variable
self._callback = kwargs.pop('command', None) self._callback = kwargs.pop('command', None)
if kwargs: if kwargs:
raise Tkinter.TclError('unknown option -%s' % ( raise tkinter.TclError('unknown option -%s' % (
kwargs.iterkeys().next())) kwargs.iterkeys().next()))
self.set_menu(default, *values) self.set_menu(default, *values)
@ -1613,7 +1613,7 @@ class OptionMenu(Menubutton):
menu.delete(0, 'end') menu.delete(0, 'end')
for val in values: for val in values:
menu.add_radiobutton(label=val, menu.add_radiobutton(label=val,
command=Tkinter._setit(self._variable, val, self._callback)) command=tkinter._setit(self._variable, val, self._callback))
if default: if default:
self._variable.set(default) self._variable.set(default)

View file

@ -27,7 +27,7 @@ __all__ = ['WizardDialog']
# imports # imports
import sys import sys
import Tkinter from six.moves import tkinter
import ttk import ttk
# PySol imports # PySol imports
@ -74,7 +74,7 @@ class WizardDialog(MfxDialog):
if w.widget == 'preset': if w.widget == 'preset':
if w.variable is None: if w.variable is None:
w.variable = Tkinter.StringVar() w.variable = tkinter.StringVar()
values = [_(v) for v in w.values] values = [_(v) for v in w.values]
default = _(w.default) default = _(w.default)
values.remove(default) values.remove(default)
@ -91,12 +91,12 @@ class WizardDialog(MfxDialog):
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2) cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
elif w.widget == 'entry': elif w.widget == 'entry':
if w.variable is None: if w.variable is None:
w.variable = Tkinter.StringVar() w.variable = tkinter.StringVar()
en = ttk.Entry(frame, textvariable=w.variable) en = ttk.Entry(frame, textvariable=w.variable)
en.grid(row=row, column=1, sticky='ew', padx=2, pady=2) en.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
elif w.widget == 'menu': elif w.widget == 'menu':
if w.variable is None: if w.variable is None:
w.variable = Tkinter.StringVar() w.variable = tkinter.StringVar()
values = [_(v) for v in w.values] values = [_(v) for v in w.values]
cb = PysolCombo(frame, values=tuple(values), cb = PysolCombo(frame, values=tuple(values),
textvariable=w.variable, textvariable=w.variable,
@ -105,7 +105,7 @@ class WizardDialog(MfxDialog):
cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2) cb.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
elif w.widget == 'spin': elif w.widget == 'spin':
if w.variable is None: if w.variable is None:
w.variable = Tkinter.IntVar() w.variable = tkinter.IntVar()
else: else:
# delete all trace callbacks # delete all trace callbacks
for mod, cbname in w.variable.trace_vinfo(): for mod, cbname in w.variable.trace_vinfo():
@ -119,7 +119,7 @@ class WizardDialog(MfxDialog):
s.grid(row=row, column=1, sticky='ew', padx=2, pady=2) s.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
elif w.widget == 'check': elif w.widget == 'check':
if w.variable is None: if w.variable is None:
w.variable = Tkinter.BooleanVar() w.variable = tkinter.BooleanVar()
ch = ttk.Checkbutton(frame, variable=w.variable, ch = ttk.Checkbutton(frame, variable=w.variable,
takefocus=False) takefocus=False)
ch.grid(row=row, column=1, sticky='ew', padx=2, pady=2) ch.grid(row=row, column=1, sticky='ew', padx=2, pady=2)

View file

@ -24,7 +24,7 @@
__all__ = ['FontsDialog'] __all__ = ['FontsDialog']
# imports # imports
import Tkinter from six.moves import tkinter
import tkFont import tkFont
# PySol imports # PySol imports
@ -72,36 +72,36 @@ class FontChooserDialog(MfxDialog):
else: else:
raise ValueError('invalid font style: '+init_font[3]) raise ValueError('invalid font style: '+init_font[3])
# self.family_var = Tkinter.StringVar() # self.family_var = tkinter.StringVar()
self.weight_var = Tkinter.BooleanVar() self.weight_var = tkinter.BooleanVar()
self.slant_var = Tkinter.BooleanVar() self.slant_var = tkinter.BooleanVar()
self.size_var = Tkinter.IntVar() self.size_var = tkinter.IntVar()
frame = Tkinter.Frame(top_frame) frame = tkinter.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
# frame.rowconfigure(1, weight=1) # frame.rowconfigure(1, weight=1)
self.entry = Tkinter.Entry(frame, bg='white') self.entry = tkinter.Entry(frame, bg='white')
self.entry.grid(row=0, column=0, columnspan=2, sticky='news') self.entry.grid(row=0, column=0, columnspan=2, sticky='news')
self.entry.insert('end', _('abcdefghABCDEFGH')) self.entry.insert('end', _('abcdefghABCDEFGH'))
self.list_box = Tkinter.Listbox(frame, width=36, exportselection=False) self.list_box = tkinter.Listbox(frame, width=36, exportselection=False)
sb = Tkinter.Scrollbar(frame) sb = tkinter.Scrollbar(frame)
self.list_box.configure(yscrollcommand=sb.set) self.list_box.configure(yscrollcommand=sb.set)
sb.configure(command=self.list_box.yview) sb.configure(command=self.list_box.yview)
self.list_box.grid(row=1, column=0, sticky='news') # rowspan=4 self.list_box.grid(row=1, column=0, sticky='news') # rowspan=4
sb.grid(row=1, column=1, sticky='ns') sb.grid(row=1, column=1, sticky='ns')
bind(self.list_box, '<<ListboxSelect>>', self.fontupdate) bind(self.list_box, '<<ListboxSelect>>', self.fontupdate)
# self.list_box.focus() # self.list_box.focus()
cb1 = Tkinter.Checkbutton(frame, anchor='w', text=_('Bold'), cb1 = tkinter.Checkbutton(frame, anchor='w', text=_('Bold'),
command=self.fontupdate, command=self.fontupdate,
variable=self.weight_var) variable=self.weight_var)
cb1.grid(row=2, column=0, columnspan=2, sticky='we') cb1.grid(row=2, column=0, columnspan=2, sticky='we')
cb2 = Tkinter.Checkbutton(frame, anchor='w', text=_('Italic'), cb2 = tkinter.Checkbutton(frame, anchor='w', text=_('Italic'),
command=self.fontupdate, command=self.fontupdate,
variable=self.slant_var) variable=self.slant_var)
cb2.grid(row=3, column=0, columnspan=2, sticky='we') cb2.grid(row=3, column=0, columnspan=2, sticky='we')
sc = Tkinter.Scale(frame, from_=6, to=40, resolution=1, sc = tkinter.Scale(frame, from_=6, to=40, resolution=1,
# label='Size', # label='Size',
orient='horizontal', orient='horizontal',
command=self.fontupdate, variable=self.size_var) command=self.fontupdate, variable=self.size_var)
@ -164,7 +164,7 @@ class FontsDialog(MfxDialog):
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
frame = Tkinter.Frame(top_frame) frame = tkinter.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
@ -181,15 +181,15 @@ class FontsDialog(MfxDialog):
): ):
font = app.opt.fonts[fn] font = app.opt.fonts[fn]
self.fonts[fn] = font self.fonts[fn] = font
Tkinter.Label(frame, text=title, anchor='w' tkinter.Label(frame, text=title, anchor='w'
).grid(row=row, column=0, sticky='we') ).grid(row=row, column=0, sticky='we')
if font: if font:
title = self._font2title(font) title = self._font2title(font)
elif font is None: elif font is None:
title = 'Default' title = 'Default'
l = Tkinter.Label(frame, font=font, text=title) l = tkinter.Label(frame, font=font, text=title)
l.grid(row=row, column=1) l.grid(row=row, column=1)
b = Tkinter.Button(frame, text=_('Change...'), width=10, b = tkinter.Button(frame, text=_('Change...'), width=10,
command=lambda l=l, command=lambda l=l,
fn=fn: self.selectFont(l, fn)) fn=fn: self.selectFont(l, fn))
b.grid(row=row, column=2) b.grid(row=row, column=2)

View file

@ -24,7 +24,7 @@
__all__ = ['PlayerOptionsDialog'] __all__ = ['PlayerOptionsDialog']
# imports # imports
import Tkinter from six.moves import tkinter
# PySol imports # PySol imports
from pysollib.mygettext import _ from pysollib.mygettext import _
@ -46,9 +46,9 @@ class SelectUserNameDialog(MfxDialog):
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
# #
listbox = Tkinter.Listbox(top_frame) listbox = tkinter.Listbox(top_frame)
listbox.pack(side='left', fill='both', expand=True) listbox.pack(side='left', fill='both', expand=True)
scrollbar = Tkinter.Scrollbar(top_frame) scrollbar = tkinter.Scrollbar(top_frame)
scrollbar.pack(side='right', fill='y') scrollbar.pack(side='right', fill='y')
listbox.configure(yscrollcommand=scrollbar.set) listbox.configure(yscrollcommand=scrollbar.set)
scrollbar.configure(command=listbox.yview) scrollbar.configure(command=listbox.yview)
@ -87,34 +87,34 @@ class PlayerOptionsDialog(MfxDialog):
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
self.app = app self.app = app
# #
self.update_stats_var = Tkinter.BooleanVar() self.update_stats_var = tkinter.BooleanVar()
self.update_stats_var.set(app.opt.update_player_stats != 0) self.update_stats_var.set(app.opt.update_player_stats != 0)
self.confirm_var = Tkinter.BooleanVar() self.confirm_var = tkinter.BooleanVar()
self.confirm_var.set(app.opt.confirm != 0) self.confirm_var.set(app.opt.confirm != 0)
self.win_animation_var = Tkinter.BooleanVar() self.win_animation_var = tkinter.BooleanVar()
self.win_animation_var.set(app.opt.win_animation != 0) self.win_animation_var.set(app.opt.win_animation != 0)
# #
frame = Tkinter.Frame(top_frame) frame = tkinter.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
widget = Tkinter.Label(frame, text=_("\nPlease enter your name"), widget = tkinter.Label(frame, text=_("\nPlease enter your name"),
# justify='left', anchor='w', # justify='left', anchor='w',
takefocus=0) takefocus=0)
widget.grid(row=0, column=0, columnspan=2, sticky='ew', padx=0, pady=5) widget.grid(row=0, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
w = kw.get("e_width", 30) # width in characters w = kw.get("e_width", 30) # width in characters
self.player_var = Tkinter.Entry(frame, exportselection=1, width=w) self.player_var = tkinter.Entry(frame, exportselection=1, width=w)
self.player_var.insert(0, app.opt.player) self.player_var.insert(0, app.opt.player)
self.player_var.grid(row=1, column=0, sticky='ew', padx=0, pady=5) self.player_var.grid(row=1, column=0, sticky='ew', padx=0, pady=5)
widget = Tkinter.Button(frame, text=_('Choose...'), widget = tkinter.Button(frame, text=_('Choose...'),
command=self.selectUserName) command=self.selectUserName)
widget.grid(row=1, column=1, padx=5, pady=5) widget.grid(row=1, column=1, padx=5, pady=5)
widget = Tkinter.Checkbutton(frame, variable=self.confirm_var, widget = tkinter.Checkbutton(frame, variable=self.confirm_var,
anchor='w', text=_("Confirm quit")) anchor='w', text=_("Confirm quit"))
widget.grid(row=2, column=0, columnspan=2, sticky='ew', padx=0, pady=5) widget.grid(row=2, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
widget = Tkinter.Checkbutton(frame, variable=self.update_stats_var, widget = tkinter.Checkbutton(frame, variable=self.update_stats_var,
anchor='w', anchor='w',
text=_("Update statistics and logs")) text=_("Update statistics and logs"))
widget.grid(row=3, column=0, columnspan=2, sticky='ew', padx=0, pady=5) widget.grid(row=3, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
# widget = Tkinter.Checkbutton(frame, variable=self.win_animation_var, # widget = tkinter.Checkbutton(frame, variable=self.win_animation_var,
# text="Win animation") # text="Win animation")
# widget.pack(side='top', padx=kw.padx, pady=kw.pady) # widget.pack(side='top', padx=kw.padx, pady=kw.pady)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
@ -159,7 +159,7 @@ def playeroptionsdialog_main(args):
from pysollib.ui.tktile.tkutil import wm_withdraw from pysollib.ui.tktile.tkutil import wm_withdraw
opt = Struct(player="Test", update_player_stats=1) opt = Struct(player="Test", update_player_stats=1)
app = Struct(opt=opt) app = Struct(opt=opt)
tk = Tkinter.Tk() tk = tkinter.Tk()
wm_withdraw(tk) wm_withdraw(tk)
tk.update() tk.update()
d = PlayerOptionsDialog(tk, "Player options", app) d = PlayerOptionsDialog(tk, "Player options", app)

View file

@ -24,7 +24,7 @@
__all__ = ['PysolProgressBar'] __all__ = ['PysolProgressBar']
# imports # imports
import Tkinter from six.moves import tkinter
# Toolkit imports # Toolkit imports
from pysollib.ui.tktile.tkconst import EVENT_HANDLED from pysollib.ui.tktile.tkconst import EVENT_HANDLED
@ -44,24 +44,24 @@ class PysolProgressBar:
self.top.wm_protocol("WM_DELETE_WINDOW", self.wmDeleteWindow) self.top.wm_protocol("WM_DELETE_WINDOW", self.wmDeleteWindow)
self.top.wm_group(parent) self.top.wm_group(parent)
self.top.wm_resizable(False, False) self.top.wm_resizable(False, False)
self.frame = Tkinter.Frame(self.top, relief='flat', bd=0, self.frame = tkinter.Frame(self.top, relief='flat', bd=0,
takefocus=0) takefocus=0)
self.cframe = Tkinter.Frame(self.frame, relief='sunken', bd=1, self.cframe = tkinter.Frame(self.frame, relief='sunken', bd=1,
takefocus=0) takefocus=0)
self.canvas = Tkinter.Canvas(self.cframe, width=width, height=height, self.canvas = tkinter.Canvas(self.cframe, width=width, height=height,
takefocus=0, bd=0, highlightthickness=0) takefocus=0, bd=0, highlightthickness=0)
self.scale = self.canvas.create_rectangle(-10, -10, 0, height, self.scale = self.canvas.create_rectangle(-10, -10, 0, height,
outline=color, fill=color) outline=color, fill=color)
self.text = -1 self.text = -1
if show_text: if show_text:
self.text = self.canvas.create_text(0, 0, anchor=Tkinter.CENTER) self.text = self.canvas.create_text(0, 0, anchor=tkinter.CENTER)
self.cframe.grid_configure(column=0, row=0, sticky="ew") self.cframe.grid_configure(column=0, row=0, sticky="ew")
if images: if images:
self.f1 = Tkinter.Label(self.frame, image=images[0]) self.f1 = tkinter.Label(self.frame, image=images[0])
self.f1.grid_configure( self.f1.grid_configure(
column=0, row=0, sticky="ew", ipadx=8, ipady=4) column=0, row=0, sticky="ew", ipadx=8, ipady=4)
self.cframe.grid_configure(column=1, row=0, sticky="ew", padx=8) self.cframe.grid_configure(column=1, row=0, sticky="ew", padx=8)
self.f2 = Tkinter.Label(self.frame, image=images[1]) self.f2 = tkinter.Label(self.frame, image=images[1])
self.f2.grid_configure( self.f2.grid_configure(
column=2, row=0, sticky="ew", ipadx=8, ipady=4) column=2, row=0, sticky="ew", ipadx=8, ipady=4)
self.top.config(cursor="watch") self.top.config(cursor="watch")
@ -85,7 +85,7 @@ class PysolProgressBar:
self.top = None self.top = None
def pack(self, **kw): def pack(self, **kw):
self.canvas.pack(fill=Tkinter.X, expand=False) self.canvas.pack(fill=tkinter.X, expand=False)
self.frame.pack(**kw) self.frame.pack(**kw)
def reset(self, percent=0): def reset(self, percent=0):
@ -137,7 +137,7 @@ class TestProgressBar:
def progressbar_main(args): def progressbar_main(args):
from pysollib.ui.tktile.tkutil import wm_withdraw from pysollib.ui.tktile.tkutil import wm_withdraw
tk = Tkinter.Tk() tk = tkinter.Tk()
wm_withdraw(tk) wm_withdraw(tk)
TestProgressBar(tk) TestProgressBar(tk)
tk.mainloop() tk.mainloop()

View file

@ -25,7 +25,7 @@ __all__ = ['SelectCardsetDialogWithPreview']
# imports # imports
import os import os
import Tkinter from six.moves import tkinter
# PySol imports # PySol imports
from pysollib.mygettext import _ from pysollib.mygettext import _
@ -227,10 +227,10 @@ class SelectCardsetDialogWithPreview(MfxDialog):
w1, w2 = 240, 400 w1, w2 = 240, 400
else: else:
w1, w2 = 200, 300 w1, w2 = 200, 300
paned_window = Tkinter.PanedWindow(top_frame) paned_window = tkinter.PanedWindow(top_frame)
paned_window.pack(expand=True, fill='both') paned_window.pack(expand=True, fill='both')
left_frame = Tkinter.Frame(paned_window) left_frame = tkinter.Frame(paned_window)
right_frame = Tkinter.Frame(paned_window) right_frame = tkinter.Frame(paned_window)
paned_window.add(left_frame) paned_window.add(left_frame)
paned_window.add(right_frame) paned_window.add(right_frame)
@ -242,9 +242,9 @@ class SelectCardsetDialogWithPreview(MfxDialog):
padx=padx, pady=pady) padx=padx, pady=pady)
if USE_PIL: if USE_PIL:
# #
var = Tkinter.DoubleVar() var = tkinter.DoubleVar()
var.set(app.opt.scale_x) var.set(app.opt.scale_x)
self.scale_x = Tkinter.Scale( self.scale_x = tkinter.Scale(
left_frame, label=_('Scale X:'), left_frame, label=_('Scale X:'),
from_=0.5, to=4.0, resolution=0.1, from_=0.5, to=4.0, resolution=0.1,
orient='horizontal', variable=var, orient='horizontal', variable=var,
@ -253,9 +253,9 @@ class SelectCardsetDialogWithPreview(MfxDialog):
self.scale_x.grid( self.scale_x.grid(
row=1, column=0, sticky='ew', padx=padx, pady=pady) row=1, column=0, sticky='ew', padx=padx, pady=pady)
# #
var = Tkinter.DoubleVar() var = tkinter.DoubleVar()
var.set(app.opt.scale_y) var.set(app.opt.scale_y)
self.scale_y = Tkinter.Scale( self.scale_y = tkinter.Scale(
left_frame, label=_('Scale Y:'), left_frame, label=_('Scale Y:'),
from_=0.5, to=4.0, resolution=0.1, from_=0.5, to=4.0, resolution=0.1,
orient='horizontal', variable=var, orient='horizontal', variable=var,
@ -264,9 +264,9 @@ class SelectCardsetDialogWithPreview(MfxDialog):
self.scale_y.grid( self.scale_y.grid(
row=2, column=0, sticky='ew', padx=padx, pady=pady) row=2, column=0, sticky='ew', padx=padx, pady=pady)
# #
self.auto_scale = Tkinter.BooleanVar() self.auto_scale = tkinter.BooleanVar()
self.auto_scale.set(app.opt.auto_scale) self.auto_scale.set(app.opt.auto_scale)
check = Tkinter.Checkbutton( check = tkinter.Checkbutton(
left_frame, text=_('Auto scaling'), left_frame, text=_('Auto scaling'),
variable=self.auto_scale, variable=self.auto_scale,
takefocus=False, takefocus=False,
@ -275,9 +275,9 @@ class SelectCardsetDialogWithPreview(MfxDialog):
check.grid(row=3, column=0, columnspan=2, sticky='w', check.grid(row=3, column=0, columnspan=2, sticky='w',
padx=padx, pady=pady) padx=padx, pady=pady)
# #
self.preserve_aspect = Tkinter.BooleanVar() self.preserve_aspect = tkinter.BooleanVar()
self.preserve_aspect.set(app.opt.preserve_aspect_ratio) self.preserve_aspect.set(app.opt.preserve_aspect_ratio)
self.aspect_check = Tkinter.Checkbutton( self.aspect_check = tkinter.Checkbutton(
left_frame, text=_('Preserve aspect ratio'), left_frame, text=_('Preserve aspect ratio'),
variable=self.preserve_aspect, variable=self.preserve_aspect,
takefocus=False, takefocus=False,
@ -427,11 +427,11 @@ class CardsetInfoDialog(MfxDialog):
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default) MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
frame = Tkinter.Frame(top_frame) frame = tkinter.Frame(top_frame)
frame.pack(fill="both", expand=True, padx=5, pady=10) frame.pack(fill="both", expand=True, padx=5, pady=10)
# #
# #
info_frame = Tkinter.LabelFrame(frame, text=_('About cardset')) info_frame = tkinter.LabelFrame(frame, text=_('About cardset'))
info_frame.grid(row=0, column=0, columnspan=2, sticky='ew', info_frame.grid(row=0, column=0, columnspan=2, sticky='ew',
padx=0, pady=5, ipadx=5, ipady=5) padx=0, pady=5, ipadx=5, ipady=5)
styles = nationalities = year = None styles = nationalities = year = None
@ -453,10 +453,10 @@ class CardsetInfoDialog(MfxDialog):
(_('Size:'), '%d x %d' % (cardset.CARDW, cardset.CARDH)), (_('Size:'), '%d x %d' % (cardset.CARDW, cardset.CARDH)),
): ):
if t is not None: if t is not None:
l = Tkinter.Label(info_frame, text=n, l = tkinter.Label(info_frame, text=n,
anchor='w', justify='left') anchor='w', justify='left')
l.grid(row=row, column=0, sticky='nw') l.grid(row=row, column=0, sticky='nw')
l = Tkinter.Label(info_frame, text=t, l = tkinter.Label(info_frame, text=t,
anchor='w', justify='left') anchor='w', justify='left')
l.grid(row=row, column=1, sticky='nw') l.grid(row=row, column=1, sticky='nw')
row += 1 row += 1
@ -466,7 +466,7 @@ class CardsetInfoDialog(MfxDialog):
im = choice(images) im = choice(images)
f = os.path.join(cardset.dir, cardset.backname) f = os.path.join(cardset.dir, cardset.backname)
self.back_image = loadImage(file=f) self.back_image = loadImage(file=f)
canvas = Tkinter.Canvas(info_frame, canvas = tkinter.Canvas(info_frame,
width=2*im.width()+30, width=2*im.width()+30,
height=im.height()+2) height=im.height()+2)
canvas.create_image(10, 1, image=im, anchor='nw') canvas.create_image(10, 1, image=im, anchor='nw')
@ -479,10 +479,10 @@ class CardsetInfoDialog(MfxDialog):
pass pass
# bg = top_frame["bg"] # bg = top_frame["bg"]
bg = 'white' bg = 'white'
text_w = Tkinter.Text(frame, bd=1, relief="sunken", wrap="word", text_w = tkinter.Text(frame, bd=1, relief="sunken", wrap="word",
padx=4, width=64, height=16, bg=bg) padx=4, width=64, height=16, bg=bg)
text_w.grid(row=1, column=0, sticky='nsew') text_w.grid(row=1, column=0, sticky='nsew')
sb = Tkinter.Scrollbar(frame) sb = tkinter.Scrollbar(frame)
sb.grid(row=1, column=1, sticky='ns') sb.grid(row=1, column=1, sticky='ns')
text_w.configure(yscrollcommand=sb.set) text_w.configure(yscrollcommand=sb.set)
sb.configure(command=text_w.yview) sb.configure(command=text_w.yview)

View file

@ -24,7 +24,7 @@
# imports # imports
import os import os
import Tkinter from six.moves import tkinter
from UserList import UserList from UserList import UserList
# PySol imports # PySol imports
@ -367,10 +367,10 @@ class SelectGameDialogWithPreview(SelectGameDialog):
# padx, pady = kw.padx, kw.pady # padx, pady = kw.padx, kw.pady
padx, pady = kw.padx/2, kw.pady/2 padx, pady = kw.padx/2, kw.pady/2
# PanedWindow # PanedWindow
paned_window = Tkinter.PanedWindow(top_frame) paned_window = tkinter.PanedWindow(top_frame)
paned_window.pack(expand=True, fill='both') paned_window.pack(expand=True, fill='both')
left_frame = Tkinter.Frame(paned_window) left_frame = tkinter.Frame(paned_window)
right_frame = Tkinter.Frame(paned_window) right_frame = tkinter.Frame(paned_window)
paned_window.add(left_frame) paned_window.add(left_frame)
paned_window.add(right_frame) paned_window.add(right_frame)
# Tree # Tree
@ -379,8 +379,8 @@ class SelectGameDialogWithPreview(SelectGameDialog):
default=kw.default, font=font, width=w1) default=kw.default, font=font, width=w1)
self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both') self.tree.frame.pack(padx=padx, pady=pady, expand=True, fill='both')
# LabelFrame # LabelFrame
info_frame = Tkinter.LabelFrame(right_frame, text=_('About game')) info_frame = tkinter.LabelFrame(right_frame, text=_('About game'))
stats_frame = Tkinter.LabelFrame(right_frame, text=_('Statistics')) stats_frame = tkinter.LabelFrame(right_frame, text=_('Statistics'))
info_frame.grid(row=0, column=0, padx=padx, pady=pady, info_frame.grid(row=0, column=0, padx=padx, pady=pady,
ipadx=padx, ipady=pady, sticky='nws') ipadx=padx, ipady=pady, sticky='nws')
stats_frame.grid(row=0, column=1, padx=padx, pady=pady, stats_frame.grid(row=0, column=1, padx=padx, pady=pady,
@ -403,9 +403,9 @@ class SelectGameDialogWithPreview(SelectGameDialog):
('moves', _('Moves:'), stats_frame, 4), ('moves', _('Moves:'), stats_frame, 4),
('percent', _('% won:'), stats_frame, 5), ('percent', _('% won:'), stats_frame, 5),
): ):
title_label = Tkinter.Label(f, text=t, justify='left', anchor='w') title_label = tkinter.Label(f, text=t, justify='left', anchor='w')
title_label.grid(row=row, column=0, sticky='nw') title_label.grid(row=row, column=0, sticky='nw')
text_label = Tkinter.Label(f, justify='left', anchor='w') text_label = tkinter.Label(f, justify='left', anchor='w')
text_label.grid(row=row, column=1, sticky='nw') text_label.grid(row=row, column=1, sticky='nw')
self.info_labels[n] = (title_label, text_label) self.info_labels[n] = (title_label, text_label)
# info_frame.columnconfigure(1, weight=1) # info_frame.columnconfigure(1, weight=1)

View file

@ -24,7 +24,7 @@
# imports # imports
import sys import sys
import Tkinter from six.moves import tkinter
import tkColorChooser import tkColorChooser
# PySol imports # PySol imports
@ -128,7 +128,7 @@ class SelectTileDialogWithPreview(MfxDialog):
w1, w2 = 200, 300 w1, w2 = 200, 300
font = app.getFont("default") font = app.getFont("default")
padx, pady = 4, 4 padx, pady = 4, 4
frame = Tkinter.Frame(top_frame) frame = tkinter.Frame(top_frame)
frame.pack(fill='both', expand=True, frame.pack(fill='both', expand=True,
padx=kw.padx-padx, pady=kw.pady-pady) padx=kw.padx-padx, pady=kw.pady-pady)
self.tree = self.Tree_Class(self, frame, key=key, self.tree = self.Tree_Class(self, frame, key=key,
@ -177,7 +177,7 @@ class SelectTileDialogWithPreview(MfxDialog):
c = tkColorChooser.askcolor(master=self.top, c = tkColorChooser.askcolor(master=self.top,
initialcolor=self.table_color, initialcolor=self.table_color,
title=_("Select table color")) title=_("Select table color"))
except Tkinter.TclError: except tkinter.TclError:
pass pass
else: else:
if c and c[1]: if c and c[1]:

View file

@ -31,7 +31,7 @@ __all__ = [
# imports # imports
import sys import sys
import Tkinter from six.moves import tkinter
# PySol imports # PySol imports
from pysollib.mygettext import _ from pysollib.mygettext import _
@ -56,8 +56,8 @@ solver_dialog = solver_dialog
class SolverDialog(BaseSolverDialog, BaseTkMfxDialog): class SolverDialog(BaseSolverDialog, BaseTkMfxDialog):
def _createGamesVar(self, frame, row): def _createGamesVar(self, frame, row):
var = Tkinter.StringVar() var = tkinter.StringVar()
om = Tkinter.OptionMenu(frame, var, command=self.gameSelected, om = tkinter.OptionMenu(frame, var, command=self.gameSelected,
*(self.gamenames)) *(self.gamenames))
om.grid(row=row, column=1, sticky='ew', padx=2, pady=2) om.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
n = len(self.gamenames) n = len(self.gamenames)
@ -68,9 +68,9 @@ class SolverDialog(BaseSolverDialog, BaseTkMfxDialog):
return var return var
def _createPresetVar(self, frame, row): def _createPresetVar(self, frame, row):
var = Tkinter.StringVar() var = tkinter.StringVar()
var.set('none') var.set('none')
om = Tkinter.OptionMenu(frame, var, *(self.presets)) om = tkinter.OptionMenu(frame, var, *(self.presets))
om.grid(row=row, column=1, sticky='ew', padx=2, pady=2) om.grid(row=row, column=1, sticky='ew', padx=2, pady=2)
return var return var

View file

@ -25,7 +25,7 @@ __all__ = ['SoundOptionsDialog']
# imports # imports
import os import os
import Tkinter from six.moves import tkinter
# PySol imports # PySol imports
from pysollib.mygettext import _ from pysollib.mygettext import _
@ -52,74 +52,74 @@ class SoundOptionsDialog(MfxDialog):
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
# #
self.saved_opt = app.opt.copy() self.saved_opt = app.opt.copy()
self.sound = Tkinter.BooleanVar() self.sound = tkinter.BooleanVar()
self.sound.set(app.opt.sound != 0) self.sound.set(app.opt.sound != 0)
self.sound_mode = Tkinter.BooleanVar() self.sound_mode = tkinter.BooleanVar()
self.sound_mode.set(app.opt.sound_mode != 0) self.sound_mode.set(app.opt.sound_mode != 0)
self.sample_volume = Tkinter.IntVar() self.sample_volume = tkinter.IntVar()
self.sample_volume.set(app.opt.sound_sample_volume) self.sample_volume.set(app.opt.sound_sample_volume)
self.music_volume = Tkinter.IntVar() self.music_volume = tkinter.IntVar()
self.music_volume.set(app.opt.sound_music_volume) self.music_volume.set(app.opt.sound_music_volume)
self.samples = [ self.samples = [
('areyousure', _('Are You Sure'), Tkinter.BooleanVar()), ('areyousure', _('Are You Sure'), tkinter.BooleanVar()),
('deal', _('Deal'), Tkinter.BooleanVar()), ('deal', _('Deal'), tkinter.BooleanVar()),
('dealwaste', _('Deal waste'), Tkinter.BooleanVar()), ('dealwaste', _('Deal waste'), tkinter.BooleanVar()),
('turnwaste', _('Turn waste'), Tkinter.BooleanVar()), ('turnwaste', _('Turn waste'), tkinter.BooleanVar()),
('startdrag', _('Start drag'), Tkinter.BooleanVar()), ('startdrag', _('Start drag'), tkinter.BooleanVar()),
('drop', _('Drop'), Tkinter.BooleanVar()), ('drop', _('Drop'), tkinter.BooleanVar()),
('droppair', _('Drop pair'), Tkinter.BooleanVar()), ('droppair', _('Drop pair'), tkinter.BooleanVar()),
('autodrop', _('Auto drop'), Tkinter.BooleanVar()), ('autodrop', _('Auto drop'), tkinter.BooleanVar()),
('flip', _('Flip'), Tkinter.BooleanVar()), ('flip', _('Flip'), tkinter.BooleanVar()),
('autoflip', _('Auto flip'), Tkinter.BooleanVar()), ('autoflip', _('Auto flip'), tkinter.BooleanVar()),
('move', _('Move'), Tkinter.BooleanVar()), ('move', _('Move'), tkinter.BooleanVar()),
('nomove', _('No move'), Tkinter.BooleanVar()), ('nomove', _('No move'), tkinter.BooleanVar()),
('undo', _('Undo'), Tkinter.BooleanVar()), ('undo', _('Undo'), tkinter.BooleanVar()),
('redo', _('Redo'), Tkinter.BooleanVar()), ('redo', _('Redo'), tkinter.BooleanVar()),
('autopilotlost', _('Autopilot lost'), Tkinter.BooleanVar()), ('autopilotlost', _('Autopilot lost'), tkinter.BooleanVar()),
('autopilotwon', _('Autopilot won'), Tkinter.BooleanVar()), ('autopilotwon', _('Autopilot won'), tkinter.BooleanVar()),
('gamefinished', _('Game finished'), Tkinter.BooleanVar()), ('gamefinished', _('Game finished'), tkinter.BooleanVar()),
('gamelost', _('Game lost'), Tkinter.BooleanVar()), ('gamelost', _('Game lost'), tkinter.BooleanVar()),
('gamewon', _('Game won'), Tkinter.BooleanVar()), ('gamewon', _('Game won'), tkinter.BooleanVar()),
('gameperfect', _('Perfect game'), Tkinter.BooleanVar()), ('gameperfect', _('Perfect game'), tkinter.BooleanVar()),
] ]
# #
frame = Tkinter.Frame(top_frame) frame = tkinter.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=5) frame.pack(expand=True, fill='both', padx=5, pady=5)
frame.columnconfigure(1, weight=1) frame.columnconfigure(1, weight=1)
# #
row = 0 row = 0
w = Tkinter.Checkbutton(frame, variable=self.sound, w = tkinter.Checkbutton(frame, variable=self.sound,
text=_("Sound enabled"), anchor='w') text=_("Sound enabled"), anchor='w')
w.grid(row=row, column=0, columnspan=2, sticky='ew') w.grid(row=row, column=0, columnspan=2, sticky='ew')
# #
if os.name == "nt" and pysolsoundserver: if os.name == "nt" and pysolsoundserver:
row += 1 row += 1
w = Tkinter.Checkbutton(frame, variable=self.sound_mode, w = tkinter.Checkbutton(frame, variable=self.sound_mode,
text=_("Use DirectX for sound playing"), text=_("Use DirectX for sound playing"),
command=self.mOptSoundDirectX, anchor='w') command=self.mOptSoundDirectX, anchor='w')
w.grid(row=row, column=0, columnspan=2, sticky='ew') w.grid(row=row, column=0, columnspan=2, sticky='ew')
# #
if app.audio.CAN_PLAY_MUSIC: # and app.startup_opt.sound_mode > 0: if app.audio.CAN_PLAY_MUSIC: # and app.startup_opt.sound_mode > 0:
row += 1 row += 1
w = Tkinter.Label(frame, text=_('Sample volume:')) w = tkinter.Label(frame, text=_('Sample volume:'))
w.grid(row=row, column=0, sticky='w', padx=5) w.grid(row=row, column=0, sticky='w', padx=5)
w = Tkinter.Scale(frame, from_=0, to=128, resolution=1, w = tkinter.Scale(frame, from_=0, to=128, resolution=1,
orient='horizontal', takefocus=0, orient='horizontal', takefocus=0,
length="3i", # label=_('Sample volume'), length="3i", # label=_('Sample volume'),
variable=self.sample_volume) variable=self.sample_volume)
w.grid(row=row, column=1, sticky='ew', padx=5) w.grid(row=row, column=1, sticky='ew', padx=5)
row += 1 row += 1
w = Tkinter.Label(frame, text=_('Music volume:')) w = tkinter.Label(frame, text=_('Music volume:'))
w.grid(row=row, column=0, sticky='w', padx=5) w.grid(row=row, column=0, sticky='w', padx=5)
w = Tkinter.Scale(frame, from_=0, to=128, resolution=1, w = tkinter.Scale(frame, from_=0, to=128, resolution=1,
orient='horizontal', takefocus=0, orient='horizontal', takefocus=0,
length="3i", # label=_('Music volume'), length="3i", # label=_('Music volume'),
variable=self.music_volume) variable=self.music_volume)
@ -129,7 +129,7 @@ class SoundOptionsDialog(MfxDialog):
# remove "Apply" button # remove "Apply" button
kw.strings[1] = None kw.strings[1] = None
# #
frame = Tkinter.LabelFrame(top_frame, text=_('Enable samles'), frame = tkinter.LabelFrame(top_frame, text=_('Enable samles'),
padx=5, pady=5) padx=5, pady=5)
frame.pack(expand=True, fill='both', padx=5, pady=5) frame.pack(expand=True, fill='both', padx=5, pady=5)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
@ -139,7 +139,7 @@ class SoundOptionsDialog(MfxDialog):
col = 0 col = 0
for n, t, v in self.samples: for n, t, v in self.samples:
v.set(app.opt.sound_samples[n]) v.set(app.opt.sound_samples[n])
w = Tkinter.Checkbutton(frame, text=t, anchor='w', variable=v) w = tkinter.Checkbutton(frame, text=t, anchor='w', variable=v)
w.grid(row=row, column=col, sticky='ew') w.grid(row=row, column=col, sticky='ew')
if col == 1: if col == 1:
col = 0 col = 0

View file

@ -27,7 +27,7 @@ __all__ = ['PysolStatusbar',
# imports # imports
import os import os
import sys import sys
import Tkinter from six.moves import tkinter
from pysollib.mygettext import _ from pysollib.mygettext import _
from tkwidget import MfxTooltip from tkwidget import MfxTooltip
from pysollib.settings import WIN_SYSTEM from pysollib.settings import WIN_SYSTEM
@ -61,7 +61,7 @@ class MfxStatusbar:
# #
self.padx = 1 self.padx = 1
self.label_relief = 'sunken' self.label_relief = 'sunken'
self.frame = Tkinter.Frame(self.top, bd=1) self.frame = tkinter.Frame(self.top, bd=1)
self.frame.grid(row=self._row, column=self._column, self.frame.grid(row=self._row, column=self._column,
columnspan=self._columnspan, sticky='ew', columnspan=self._columnspan, sticky='ew',
padx=1, pady=1) padx=1, pady=1)
@ -75,7 +75,7 @@ class MfxStatusbar:
# util # util
def _createLabel(self, name, expand=False, width=0, tooltip=None): def _createLabel(self, name, expand=False, width=0, tooltip=None):
label = Tkinter.Label(self.frame, width=width, label = tkinter.Label(self.frame, width=width,
relief=self.label_relief, bd=1, relief=self.label_relief, bd=1,
highlightbackground='black' highlightbackground='black'
) )
@ -192,7 +192,7 @@ class TestStatusbar(PysolStatusbar):
def statusbar_main(args): def statusbar_main(args):
tk = Tkinter.Tk() tk = tkinter.Tk()
TestStatusbar(tk, args) TestStatusbar(tk, args)
tk.mainloop() tk.mainloop()
return 0 return 0

View file

@ -24,11 +24,10 @@
a couple of classes for implementing partial tabbed-page like behaviour a couple of classes for implementing partial tabbed-page like behaviour
""" """
from Tkinter import EW, FALSE, Frame, Radiobutton, RAISED, RIDGE, StringVar from six.moves import tkinter
from Tkinter import BOTH, Button, Entry, Label, LEFT, NSEW, Tk, TRUE
MYRIDGE, MYRAISED = RAISED, RIDGE MYRIDGE, MYRAISED = tkinter.RAISED, tkinter.RIDGE
# MYRIDGE, MYRAISED = RIDGE, RAISED # MYRIDGE, MYRAISED = tkinter.RIDGE, tkinter.RAISED
class InvalidTabPage(Exception): class InvalidTabPage(Exception):
@ -39,20 +38,20 @@ class AlreadyExists(Exception):
pass pass
class PageTab(Frame): class PageTab(tkinter.Frame):
""" """
a 'page tab' like framed button a 'page tab' like framed button
""" """
def __init__(self, parent): def __init__(self, parent):
Frame.__init__(self, parent, borderwidth=2, relief=MYRIDGE) tkinter.Frame.__init__(self, parent, borderwidth=2, relief=MYRIDGE)
self.button = Radiobutton( self.button = tkinter.Radiobutton(
self, padx=5, pady=5, takefocus=0, self, padx=5, pady=5, takefocus=0,
indicatoron=FALSE, highlightthickness=0, indicatoron=tkinter.FALSE, highlightthickness=0,
borderwidth=0, selectcolor=self.cget('bg')) borderwidth=0, selectcolor=self.cget('bg'))
self.button.pack() self.button.pack()
class TabPageSet(Frame): class TabPageSet(tkinter.Frame):
""" """
a set of 'pages' with TabButtons for controlling their display a set of 'pages' with TabButtons for controlling their display
""" """
@ -63,13 +62,13 @@ class TabPageSet(Frame):
specified in desired page order. The first page will be the default specified in desired page order. The first page will be the default
and first active page. and first active page.
""" """
Frame.__init__(self, parent, kw) tkinter.Frame.__init__(self, parent, kw)
self.grid_location(0, 0) self.grid_location(0, 0)
self.columnconfigure(0, weight=1) self.columnconfigure(0, weight=1)
self.rowconfigure(1, weight=1) self.rowconfigure(1, weight=1)
self.tabBar = Frame(self) self.tabBar = tkinter.Frame(self)
self.tabBar.grid(row=0, column=0, sticky=EW) self.tabBar.grid(row=0, column=0, sticky=tkinter.EW)
self.activePage = StringVar(self) self.activePage = tkinter.StringVar(self)
self.defaultPage = '' self.defaultPage = ''
self.pages = {} self.pages = {}
for name in pageNames: for name in pageNames:
@ -96,7 +95,7 @@ class TabPageSet(Frame):
raise AlreadyExists('TabPage Name Already Exists') raise AlreadyExists('TabPage Name Already Exists')
self.pages[pageName] = { self.pages[pageName] = {
'tab': PageTab(self.tabBar), 'tab': PageTab(self.tabBar),
'page': Frame(self, borderwidth=2, relief=RAISED) 'page': tkinter.Frame(self, borderwidth=2, relief=tkinter.RAISED)
} }
self.pages[pageName]['tab'].button.config( self.pages[pageName]['tab'].button.config(
text=pageName, text=pageName,
@ -104,8 +103,8 @@ class TabPageSet(Frame):
variable=self.activePage, variable=self.activePage,
value=pageName value=pageName
) )
self.pages[pageName]['tab'].pack(side=LEFT) self.pages[pageName]['tab'].pack(side=tkinter.LEFT)
self.pages[pageName]['page'].grid(row=1, column=0, sticky=NSEW) self.pages[pageName]['page'].grid(row=1, column=0, sticky=tkinter.NSEW)
if len(self.pages) == 1: # adding first page if len(self.pages) == 1: # adding first page
self.defaultPage = pageName self.defaultPage = pageName
self.activePage.set(self.defaultPage) self.activePage.set(self.defaultPage)
@ -133,20 +132,20 @@ class TabPageSet(Frame):
if __name__ == '__main__': if __name__ == '__main__':
# test dialog # test dialog
root = Tk() root = tkinter.Tk()
tabPage = TabPageSet(root, pageNames=['Foobar', 'Baz']) tabPage = TabPageSet(root, pageNames=['Foobar', 'Baz'])
tabPage.pack(expand=TRUE, fill=BOTH) tabPage.pack(expand=tkinter.TRUE, fill=tkinter.BOTH)
Label(tabPage.pages['Foobar']['page'], text='Foo', pady=20).pack() tkinter.Label(tabPage.pages['Foobar']['page'], text='Foo', pady=20).pack()
Label(tabPage.pages['Foobar']['page'], text='Bar', pady=20).pack() tkinter.Label(tabPage.pages['Foobar']['page'], text='Bar', pady=20).pack()
Label(tabPage.pages['Baz']['page'], text='Baz').pack() tkinter.Label(tabPage.pages['Baz']['page'], text='Baz').pack()
entryPgName = Entry(root) entryPgName = tkinter.Entry(root)
buttonAdd = Button( buttonAdd = tkinter.Button(
root, text='Add Page', root, text='Add Page',
command=lambda: tabPage.AddPage(entryPgName.get())) command=lambda: tabPage.AddPage(entryPgName.get()))
buttonRemove = Button( buttonRemove = tkinter.Button(
root, text='Remove Page', root, text='Remove Page',
command=lambda: tabPage.RemovePage(entryPgName.get())) command=lambda: tabPage.RemovePage(entryPgName.get()))
labelPgName = Label(root, text='name of page to add/remove:') labelPgName = tkinter.Label(root, text='name of page to add/remove:')
buttonAdd.pack(padx=5, pady=5) buttonAdd.pack(padx=5, pady=5)
buttonRemove.pack(padx=5, pady=5) buttonRemove.pack(padx=5, pady=5)
labelPgName.pack(padx=5) labelPgName.pack(padx=5)

View file

@ -24,7 +24,7 @@
__all__ = ['TimeoutsDialog'] __all__ = ['TimeoutsDialog']
# imports # imports
import Tkinter from six.moves import tkinter
# PySol imports # PySol imports
from pysollib.mygettext import _ from pysollib.mygettext import _
@ -45,25 +45,25 @@ class TimeoutsDialog(MfxDialog):
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
# self.createBitmaps(top_frame, kw) # self.createBitmaps(top_frame, kw)
frame = Tkinter.Frame(top_frame) frame = tkinter.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
self.demo_sleep_var = Tkinter.DoubleVar() self.demo_sleep_var = tkinter.DoubleVar()
self.demo_sleep_var.set(app.opt.timeouts['demo']) self.demo_sleep_var.set(app.opt.timeouts['demo'])
self.hint_sleep_var = Tkinter.DoubleVar() self.hint_sleep_var = tkinter.DoubleVar()
self.hint_sleep_var.set(app.opt.timeouts['hint']) self.hint_sleep_var.set(app.opt.timeouts['hint'])
self.raise_card_sleep_var = Tkinter.DoubleVar() self.raise_card_sleep_var = tkinter.DoubleVar()
self.raise_card_sleep_var.set(app.opt.timeouts['raise_card']) self.raise_card_sleep_var.set(app.opt.timeouts['raise_card'])
self.highlight_piles_sleep_var = Tkinter.DoubleVar() self.highlight_piles_sleep_var = tkinter.DoubleVar()
self.highlight_piles_sleep_var.set(app.opt.timeouts['highlight_piles']) self.highlight_piles_sleep_var.set(app.opt.timeouts['highlight_piles'])
self.highlight_cards_sleep_var = Tkinter.DoubleVar() self.highlight_cards_sleep_var = tkinter.DoubleVar()
self.highlight_cards_sleep_var.set(app.opt.timeouts['highlight_cards']) self.highlight_cards_sleep_var.set(app.opt.timeouts['highlight_cards'])
self.highlight_samerank_sleep_var = Tkinter.DoubleVar() self.highlight_samerank_sleep_var = tkinter.DoubleVar()
self.highlight_samerank_sleep_var.set( self.highlight_samerank_sleep_var.set(
app.opt.timeouts['highlight_samerank']) app.opt.timeouts['highlight_samerank'])
# #
# Tkinter.Label(frame, text='Set delays in seconds').grid( # tkinter.Label(frame, text='Set delays in seconds').grid(
# row=0, column=0, columnspan=2) # row=0, column=0, columnspan=2)
row = 0 row = 0
for title, var in ((_('Demo:'), self.demo_sleep_var), for title, var in ((_('Demo:'), self.demo_sleep_var),
@ -76,9 +76,9 @@ class TimeoutsDialog(MfxDialog):
(_('Highlight same rank:'), (_('Highlight same rank:'),
self.highlight_samerank_sleep_var), self.highlight_samerank_sleep_var),
): ):
Tkinter.Label(frame, text=title, anchor='w' tkinter.Label(frame, text=title, anchor='w'
).grid(row=row, column=0, sticky='we') ).grid(row=row, column=0, sticky='we')
widget = Tkinter.Scale(frame, from_=0.2, to=9.9, widget = tkinter.Scale(frame, from_=0.2, to=9.9,
resolution=0.1, orient='horizontal', resolution=0.1, orient='horizontal',
length="3i", variable=var, takefocus=0) length="3i", variable=var, takefocus=0)
widget.grid(row=row, column=1) widget.grid(row=row, column=1)

View file

@ -26,7 +26,7 @@ __all__ = ['HTMLViewer']
# imports # imports
import os import os
import sys import sys
import Tkinter from six.moves import tkinter
# PySol imports # PySol imports
from pysollib.mygettext import _ from pysollib.mygettext import _
@ -74,30 +74,30 @@ class HTMLViewer(Base_HTMLViewer):
# create buttons # create buttons
button_width = 8 button_width = 8
self.homeButton = Tkinter.Button(parent, text=_("Index"), self.homeButton = tkinter.Button(parent, text=_("Index"),
width=button_width, width=button_width,
command=self.goHome) command=self.goHome)
self.homeButton.grid(row=0, column=0, sticky='w') self.homeButton.grid(row=0, column=0, sticky='w')
self.backButton = Tkinter.Button(parent, text=_("Back"), self.backButton = tkinter.Button(parent, text=_("Back"),
width=button_width, width=button_width,
command=self.goBack) command=self.goBack)
self.backButton.grid(row=0, column=1, sticky='w') self.backButton.grid(row=0, column=1, sticky='w')
self.forwardButton = Tkinter.Button(parent, text=_("Forward"), self.forwardButton = tkinter.Button(parent, text=_("Forward"),
width=button_width, width=button_width,
command=self.goForward) command=self.goForward)
self.forwardButton.grid(row=0, column=2, sticky='w') self.forwardButton.grid(row=0, column=2, sticky='w')
self.closeButton = Tkinter.Button(parent, text=_("Close"), self.closeButton = tkinter.Button(parent, text=_("Close"),
width=button_width, width=button_width,
command=self.destroy) command=self.destroy)
self.closeButton.grid(row=0, column=3, sticky='e') self.closeButton.grid(row=0, column=3, sticky='e')
# create text widget # create text widget
text_frame = Tkinter.Frame(parent) text_frame = tkinter.Frame(parent)
text_frame.grid(row=1, column=0, columnspan=4, sticky='nsew') text_frame.grid(row=1, column=0, columnspan=4, sticky='nsew')
text_frame.grid_propagate(False) text_frame.grid_propagate(False)
vbar = Tkinter.Scrollbar(text_frame) vbar = tkinter.Scrollbar(text_frame)
vbar.pack(side='right', fill='y') vbar.pack(side='right', fill='y')
self.text = Tkinter.Text(text_frame, self.text = tkinter.Text(text_frame,
fg='black', bg='white', fg='black', bg='white',
bd=1, relief='sunken', bd=1, relief='sunken',
cursor=self.defcursor, cursor=self.defcursor,
@ -129,7 +129,7 @@ def tkhtml_main(args):
url = args[1] url = args[1]
except: except:
url = os.path.join(os.pardir, os.pardir, "data", "html", "index.html") url = os.path.join(os.pardir, os.pardir, "data", "html", "index.html")
top = Tkinter.Tk() top = tkinter.Tk()
top.wm_minsize(400, 200) top.wm_minsize(400, 200)
viewer = HTMLViewer(top) viewer = HTMLViewer(top)
viewer.app = None viewer.app = None

View file

@ -33,7 +33,7 @@ __all__ = ['SingleGame_StatsDialog',
# imports # imports
import os import os
import time import time
import Tkinter from six.moves import tkinter
import tkFont import tkFont
# PySol imports # PySol imports
@ -133,14 +133,14 @@ class SingleGame_StatsDialog(MfxDialog):
def _createChartInit(self, text): def _createChartInit(self, text):
w, h = self.tab_x[-1]+20, self.tab_y[-1]+20 w, h = self.tab_x[-1]+20, self.tab_y[-1]+20
c = Tkinter.Canvas(self.top_frame, width=w, height=h) c = tkinter.Canvas(self.top_frame, width=w, height=h)
c.pack(side='top', fill='both', expand=False, padx=20, pady=10) c.pack(side='top', fill='both', expand=False, padx=20, pady=10)
self.canvas = c self.canvas = c
# self.fg = c.cget("insertbackground") # self.fg = c.cget("insertbackground")
self.fg = c.option_get('foreground', '') or c.cget("insertbackground") self.fg = c.option_get('foreground', '') or c.cget("insertbackground")
# #
c.create_rectangle(2, 7, w, h, fill="", outline="#7f7f7f") c.create_rectangle(2, 7, w, h, fill="", outline="#7f7f7f")
l = Tkinter.Label(c, text=text, font=self.font, bd=0, padx=3, pady=1) l = tkinter.Label(c, text=text, font=self.font, bd=0, padx=3, pady=1)
dy = int(self.font_metrics['ascent']) - 10 dy = int(self.font_metrics['ascent']) - 10
dy = dy/2 dy = dy/2
c.create_window(20, -dy, window=l, anchor="nw") c.create_window(20, -dy, window=l, anchor="nw")
@ -682,38 +682,38 @@ class _TopDialog(MfxDialog):
'highlightthickness': 1, 'highlightthickness': 1,
'highlightbackground': 'black', 'highlightbackground': 'black',
} }
frame = Tkinter.Frame(**cnf) frame = tkinter.Frame(**cnf)
frame.pack(expand=True, fill='both', padx=10, pady=10) frame.pack(expand=True, fill='both', padx=10, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
cnf['master'] = frame cnf['master'] = frame
cnf['text'] = _('N') cnf['text'] = _('N')
l = Tkinter.Label(**cnf) l = tkinter.Label(**cnf)
l.grid(row=0, column=0, sticky='ew') l.grid(row=0, column=0, sticky='ew')
cnf['text'] = _('Game number') cnf['text'] = _('Game number')
l = Tkinter.Label(**cnf) l = tkinter.Label(**cnf)
l.grid(row=0, column=1, sticky='ew') l.grid(row=0, column=1, sticky='ew')
cnf['text'] = _('Started at') cnf['text'] = _('Started at')
l = Tkinter.Label(**cnf) l = tkinter.Label(**cnf)
l.grid(row=0, column=2, sticky='ew') l.grid(row=0, column=2, sticky='ew')
cnf['text'] = _('Result') cnf['text'] = _('Result')
l = Tkinter.Label(**cnf) l = tkinter.Label(**cnf)
l.grid(row=0, column=3, sticky='ew') l.grid(row=0, column=3, sticky='ew')
row = 1 row = 1
for i in top: for i in top:
# N # N
cnf['text'] = str(row) cnf['text'] = str(row)
l = Tkinter.Label(**cnf) l = tkinter.Label(**cnf)
l.grid(row=row, column=0, sticky='ew') l.grid(row=row, column=0, sticky='ew')
# Game number # Game number
cnf['text'] = '#'+str(i.game_number) cnf['text'] = '#'+str(i.game_number)
l = Tkinter.Label(**cnf) l = tkinter.Label(**cnf)
l.grid(row=row, column=1, sticky='ew') l.grid(row=row, column=1, sticky='ew')
# Start time # Start time
t = time.strftime( t = time.strftime(
'%Y-%m-%d %H:%M', time.localtime(i.game_start_time)) '%Y-%m-%d %H:%M', time.localtime(i.game_start_time))
cnf['text'] = t cnf['text'] = t
l = Tkinter.Label(**cnf) l = tkinter.Label(**cnf)
l.grid(row=row, column=2, sticky='ew') l.grid(row=row, column=2, sticky='ew')
# Result # Result
if isinstance(i.value, float): if isinstance(i.value, float):
@ -723,7 +723,7 @@ class _TopDialog(MfxDialog):
# moves # moves
s = str(i.value) s = str(i.value)
cnf['text'] = s cnf['text'] = s
l = Tkinter.Label(**cnf) l = tkinter.Label(**cnf)
l.grid(row=row, column=3, sticky='ew') l.grid(row=row, column=3, sticky='ew')
row += 1 row += 1
@ -743,7 +743,7 @@ class Top_StatsDialog(MfxDialog):
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
frame = Tkinter.Frame(top_frame) frame = tkinter.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=10, pady=10) frame.pack(expand=True, fill='both', padx=10, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
@ -751,10 +751,10 @@ class Top_StatsDialog(MfxDialog):
gameid in app.stats.games_stats[player] and gameid in app.stats.games_stats[player] and
app.stats.games_stats[player][gameid].time_result.top): app.stats.games_stats[player][gameid].time_result.top):
Tkinter.Label(frame, text=_('Minimum')).grid(row=0, column=1) tkinter.Label(frame, text=_('Minimum')).grid(row=0, column=1)
Tkinter.Label(frame, text=_('Maximum')).grid(row=0, column=2) tkinter.Label(frame, text=_('Maximum')).grid(row=0, column=2)
Tkinter.Label(frame, text=_('Average')).grid(row=0, column=3) tkinter.Label(frame, text=_('Average')).grid(row=0, column=3)
# Tkinter.Label(frame, text=_('Total')).grid(row=0, column=4) # tkinter.Label(frame, text=_('Total')).grid(row=0, column=4)
s = app.stats.games_stats[player][gameid] s = app.stats.games_stats[player][gameid]
row = 1 row = 1
@ -794,17 +794,17 @@ class Top_StatsDialog(MfxDialog):
# s.score_casino_result.max, # s.score_casino_result.max,
# round(s.score_casino_result.average, 2), )) # round(s.score_casino_result.average, 2), ))
for l, min, max, avr, tot, top in ll: for l, min, max, avr, tot, top in ll:
Tkinter.Label(frame, text=l).grid(row=row, column=0) 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(min)).grid(row=row, column=1)
Tkinter.Label(frame, text=str(max)).grid(row=row, column=2) 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(avr)).grid(row=row, column=3)
# Tkinter.Label(frame, text=str(tot)).grid(row=row, column=4) # tkinter.Label(frame, text=str(tot)).grid(row=row, column=4)
b = Tkinter.Button(frame, text=TOP_TITLE+' ...', width=10, b = tkinter.Button(frame, text=TOP_TITLE+' ...', width=10,
command=lambda top=top: self.showTop(top)) command=lambda top=top: self.showTop(top))
b.grid(row=row, column=5) b.grid(row=row, column=5)
row += 1 row += 1
else: else:
Tkinter.Label(frame, text=_('No TOP for this game')).pack() tkinter.Label(frame, text=_('No TOP for this game')).pack()
focus = self.createButtons(bottom_frame, kw) focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout) self.mainloop(focus, kw.timeout)
@ -846,7 +846,7 @@ class ProgressionDialog(MfxDialog):
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
frame = Tkinter.Frame(top_frame) frame = tkinter.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
@ -861,7 +861,7 @@ class ProgressionDialog(MfxDialog):
self.won_color = '#00dc28' self.won_color = '#00dc28'
self.percent_color = 'blue' self.percent_color = 'blue'
# create canvas # create canvas
self.canvas = canvas = Tkinter.Canvas(frame, bg='#dfe8ff', self.canvas = canvas = tkinter.Canvas(frame, bg='#dfe8ff',
highlightthickness=1, highlightthickness=1,
highlightbackground='black', highlightbackground='black',
width=self.canvas_width, width=self.canvas_width,
@ -918,25 +918,25 @@ class ProgressionDialog(MfxDialog):
canvas.create_text(x, y, anchor='sw', text=_('% won')) canvas.create_text(x, y, anchor='sw', text=_('% won'))
# right frame # right frame
right_frame = Tkinter.Frame(frame) right_frame = tkinter.Frame(frame)
right_frame.pack(side='left', fill='x', padx=5) right_frame.pack(side='left', fill='x', padx=5)
self.all_games_variable = var = Tkinter.StringVar() self.all_games_variable = var = tkinter.StringVar()
var.set('all') var.set('all')
b = Tkinter.Radiobutton(right_frame, text=_('All games'), b = tkinter.Radiobutton(right_frame, text=_('All games'),
variable=var, value='all', variable=var, value='all',
command=self.updateGraph, command=self.updateGraph,
justify='left', anchor='w' justify='left', anchor='w'
) )
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
b = Tkinter.Radiobutton(right_frame, text=_('Current game'), b = tkinter.Radiobutton(right_frame, text=_('Current game'),
variable=var, value='current', variable=var, value='current',
command=self.updateGraph, command=self.updateGraph,
justify='left', anchor='w' justify='left', anchor='w'
) )
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
label_frame = Tkinter.LabelFrame(right_frame, text=_('Statistics for')) label_frame = tkinter.LabelFrame(right_frame, text=_('Statistics for'))
label_frame.pack(side='top', fill='x', pady=10) label_frame.pack(side='top', fill='x', pady=10)
self.variable = var = Tkinter.StringVar() self.variable = var = tkinter.StringVar()
var.set('week') var.set('week')
for v, t in ( for v, t in (
('week', _('Last 7 days')), ('week', _('Last 7 days')),
@ -944,32 +944,32 @@ class ProgressionDialog(MfxDialog):
('year', _('Last year')), ('year', _('Last year')),
('all', _('All time')), ('all', _('All time')),
): ):
b = Tkinter.Radiobutton(label_frame, text=t, variable=var, value=v, b = tkinter.Radiobutton(label_frame, text=t, variable=var, value=v,
command=self.updateGraph, command=self.updateGraph,
justify='left', anchor='w' justify='left', anchor='w'
) )
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
label_frame = Tkinter.LabelFrame(right_frame, text=_('Show graphs')) label_frame = tkinter.LabelFrame(right_frame, text=_('Show graphs'))
label_frame.pack(side='top', fill='x') label_frame.pack(side='top', fill='x')
self.played_graph_var = Tkinter.BooleanVar() self.played_graph_var = tkinter.BooleanVar()
self.played_graph_var.set(True) self.played_graph_var.set(True)
b = Tkinter.Checkbutton(label_frame, text=_('Played'), b = tkinter.Checkbutton(label_frame, text=_('Played'),
command=self.updateGraph, command=self.updateGraph,
variable=self.played_graph_var, variable=self.played_graph_var,
justify='left', anchor='w' justify='left', anchor='w'
) )
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
self.won_graph_var = Tkinter.BooleanVar() self.won_graph_var = tkinter.BooleanVar()
self.won_graph_var.set(True) self.won_graph_var.set(True)
b = Tkinter.Checkbutton(label_frame, text=_('Won'), b = tkinter.Checkbutton(label_frame, text=_('Won'),
command=self.updateGraph, command=self.updateGraph,
variable=self.won_graph_var, variable=self.won_graph_var,
justify='left', anchor='w' justify='left', anchor='w'
) )
b.pack(fill='x', expand=True, padx=3, pady=1) b.pack(fill='x', expand=True, padx=3, pady=1)
self.percent_graph_var = Tkinter.BooleanVar() self.percent_graph_var = tkinter.BooleanVar()
self.percent_graph_var.set(True) self.percent_graph_var.set(True)
b = Tkinter.Checkbutton(label_frame, text=_('% won'), b = tkinter.Checkbutton(label_frame, text=_('% won'),
command=self.updateGraph, command=self.updateGraph,
variable=self.percent_graph_var, variable=self.percent_graph_var,
justify='left', anchor='w' justify='left', anchor='w'

View file

@ -23,7 +23,7 @@
# imports # imports
import os import os
import Tkinter from six.moves import tkinter
# Toolkit imports # Toolkit imports
from pysollib.ui.tktile.tkutil import bind from pysollib.ui.tktile.tkutil import bind
@ -106,7 +106,7 @@ class MfxTreeBaseNode:
try: try:
# _tkinter.TclError: unknown option "-fill" ??? # _tkinter.TclError: unknown option "-fill" ???
canvas.itemconfig(self.textrect_id, fill=bg) canvas.itemconfig(self.textrect_id, fill=bg)
except Tkinter.TclError: except tkinter.TclError:
pass pass
elif self.selected: elif self.selected:
b = canvas.bbox(self.text_id) b = canvas.bbox(self.text_id)
@ -279,7 +279,7 @@ class MfxTreeInCanvas(MfxScrolledCanvas):
# draw # draw
try: try:
lx, ly, nx, ny = node.draw(nx, ny, None, None) lx, ly, nx, ny = node.draw(nx, ny, None, None)
except Tkinter.TclError: except tkinter.TclError:
# FIXME: Tk bug ??? # FIXME: Tk bug ???
raise raise
# set scroll region # set scroll region
@ -401,7 +401,7 @@ class DirectoryBrowser(MfxTreeInCanvas):
if __name__ == "__main__": if __name__ == "__main__":
tk = Tkinter.Tk() tk = tkinter.Tk()
if os.name == "nt": if os.name == "nt":
app = DirectoryBrowser(tk, ("c:\\", "c:\\windows")) app = DirectoryBrowser(tk, ("c:\\", "c:\\windows"))
else: else:

View file

@ -34,7 +34,7 @@ __all__ = ['MfxDialog',
# imports # imports
import sys import sys
import time import time
import Tkinter from six.moves import tkinter
import tkFont import tkFont
import traceback import traceback
@ -84,7 +84,7 @@ class MfxDialog: # ex. _ToplevelDialog
setTransient(self.top, self.parent) setTransient(self.top, self.parent)
try: try:
self.top.grab_set() self.top.grab_set()
except Tkinter.TclError: except tkinter.TclError:
if traceback: if traceback:
traceback.print_exc() traceback.print_exc()
pass pass
@ -171,26 +171,26 @@ class MfxDialog: # ex. _ToplevelDialog
return kw return kw
def createFrames(self, kw): def createFrames(self, kw):
bottom_frame = Tkinter.Frame(self.top) bottom_frame = tkinter.Frame(self.top)
bottom_frame.pack(side='bottom', fill='both', expand=False, bottom_frame.pack(side='bottom', fill='both', expand=False,
ipadx=3, ipady=3) ipadx=3, ipady=3)
if kw.separator: if kw.separator:
separator = Tkinter.Frame( separator = tkinter.Frame(
self.top, relief="sunken", self.top, relief="sunken",
height=2, width=2, borderwidth=1) height=2, width=2, borderwidth=1)
separator.pack(side='bottom', fill='x') separator.pack(side='bottom', fill='x')
top_frame = Tkinter.Frame(self.top) top_frame = tkinter.Frame(self.top)
top_frame.pack(side='top', fill='both', expand=True) top_frame.pack(side='top', fill='both', expand=True)
return top_frame, bottom_frame return top_frame, bottom_frame
def createBitmaps(self, frame, kw): def createBitmaps(self, frame, kw):
if kw.bitmap: # in ("error", "info", "question", "warning") if kw.bitmap: # in ("error", "info", "question", "warning")
img = self.img.get(kw.bitmap) img = self.img.get(kw.bitmap)
b = Tkinter.Label(frame, image=img) b = tkinter.Label(frame, image=img)
b.pack(side=kw.bitmap_side, padx=kw.bitmap_padx, b.pack(side=kw.bitmap_side, padx=kw.bitmap_padx,
pady=kw.bitmap_pady) pady=kw.bitmap_pady)
elif kw.image: elif kw.image:
b = Tkinter.Label(frame, image=kw.image) b = tkinter.Label(frame, image=kw.image)
b.pack(side=kw.image_side, padx=kw.image_padx, pady=kw.image_pady) b.pack(side=kw.image_side, padx=kw.image_padx, pady=kw.image_pady)
def createButtons(self, frame, kw): def createButtons(self, frame, kw):
@ -230,10 +230,10 @@ class MfxDialog: # ex. _ToplevelDialog
accel_indx = s.find('&') accel_indx = s.find('&')
s = s.replace('&', '') s = s.replace('&', '')
if button < 0: if button < 0:
b = Tkinter.Button(frame, text=s, state="disabled") b = tkinter.Button(frame, text=s, state="disabled")
button = xbutton button = xbutton
else: else:
b = Tkinter.Button( b = tkinter.Button(
frame, text=s, default="normal", frame, text=s, default="normal",
command=(lambda self=self, button=button: command=(lambda self=self, button=button:
self.mDone(button))) self.mDone(button)))
@ -277,7 +277,7 @@ class MfxMessageDialog(MfxDialog):
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
# #
self.button = kw.default self.button = kw.default
msg = Tkinter.Label(top_frame, text=kw.text, justify=kw.justify, msg = tkinter.Label(top_frame, text=kw.text, justify=kw.justify,
width=kw.width) width=kw.width)
msg.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady) msg.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
# #
@ -318,15 +318,15 @@ class PysolAboutDialog(MfxMessageDialog):
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
# #
self.button = kw.default self.button = kw.default
frame = Tkinter.Frame(top_frame) frame = tkinter.Frame(top_frame)
frame.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady) frame.pack(fill='both', expand=True, padx=kw.padx, pady=kw.pady)
msg = Tkinter.Label(frame, text=kw.text, justify=kw.justify, msg = tkinter.Label(frame, text=kw.text, justify=kw.justify,
width=kw.width) width=kw.width)
msg.pack(fill='both', expand=True) msg.pack(fill='both', expand=True)
font = tkFont.Font(parent, app.getFont('default')) font = tkFont.Font(parent, app.getFont('default'))
font.configure(underline=True) font.configure(underline=True)
url_label = Tkinter.Label(frame, text=kw.url, font=font, url_label = tkinter.Label(frame, text=kw.url, font=font,
foreground='blue', cursor='hand2') foreground='blue', cursor='hand2')
url_label.pack() url_label.pack()
url_label.bind('<1>', self._urlClicked) url_label.bind('<1>', self._urlClicked)
@ -351,10 +351,10 @@ class MfxSimpleEntry(MfxDialog):
# #
self.value = value self.value = value
if label: if label:
label = Tkinter.Label(top_frame, text=label, takefocus=0) label = tkinter.Label(top_frame, text=label, takefocus=0)
label.pack(pady=5) label.pack(pady=5)
w = kw.get("e_width", 0) # width in characters w = kw.get("e_width", 0) # width in characters
self.var = Tkinter.Entry(top_frame, exportselection=1, width=w) self.var = tkinter.Entry(top_frame, exportselection=1, width=w)
self.var.insert(0, value) self.var.insert(0, value)
self.var.pack(side='top', padx=kw.padx, pady=kw.pady) self.var.pack(side='top', padx=kw.padx, pady=kw.pady)
# #
@ -445,7 +445,7 @@ class MfxTooltip:
self.timer = None self.timer = None
if self.tooltip or not self.text: if self.tooltip or not self.text:
return return
# if isinstance(self.widget, (Tkinter.Button, Tkinter.Checkbutton)): # if isinstance(self.widget, (tkinter.Button, tkinter.Checkbutton)):
# if self.widget["state"] == 'disabled': # if self.widget["state"] == 'disabled':
# return # return
# x = self.widget.winfo_rootx() # x = self.widget.winfo_rootx()
@ -453,11 +453,11 @@ class MfxTooltip:
y = self.widget.winfo_rooty() + self.widget.winfo_height() y = self.widget.winfo_rooty() + self.widget.winfo_height()
x += self.xoffset x += self.xoffset
y += self.yoffset y += self.yoffset
self.tooltip = Tkinter.Toplevel() self.tooltip = tkinter.Toplevel()
self.tooltip.wm_iconify() self.tooltip.wm_iconify()
self.tooltip.wm_overrideredirect(1) self.tooltip.wm_overrideredirect(1)
self.tooltip.wm_protocol("WM_DELETE_WINDOW", self.destroy) self.tooltip.wm_protocol("WM_DELETE_WINDOW", self.destroy)
self.label = Tkinter.Label(self.tooltip, text=self.text, self.label = tkinter.Label(self.tooltip, text=self.text,
relief=self.relief, justify=self.justify, relief=self.relief, justify=self.justify,
fg=self.fg, bg=self.bg, bd=1, takefocus=0) fg=self.fg, bg=self.bg, bd=1, takefocus=0)
self.label.pack(ipadx=1, ipady=1) self.label.pack(ipadx=1, ipady=1)
@ -559,20 +559,20 @@ class MfxScrolledCanvas:
def createFrame(self, kw): def createFrame(self, kw):
width = kw.get("width") width = kw.get("width")
height = kw.get("height") height = kw.get("height")
self.frame = Tkinter.Frame(self.parent, width=width, height=height) self.frame = tkinter.Frame(self.parent, width=width, height=height)
def createCanvas(self, kw): def createCanvas(self, kw):
bd = kw['bd'] bd = kw['bd']
kw['bd'] = 0 kw['bd'] = 0
relief = kw['relief'] relief = kw['relief']
del kw['relief'] del kw['relief']
frame = Tkinter.Frame(self.frame, bd=bd, relief=relief) frame = tkinter.Frame(self.frame, bd=bd, relief=relief)
frame.grid(row=0, column=0, sticky="news") frame.grid(row=0, column=0, sticky="news")
self.canvas = MfxCanvas(frame, **kw) self.canvas = MfxCanvas(frame, **kw)
self.canvas.pack(expand=True, fill='both') self.canvas.pack(expand=True, fill='both')
def createHbar(self): def createHbar(self):
self.hbar = Tkinter.Scrollbar(self.frame, takefocus=0, self.hbar = tkinter.Scrollbar(self.frame, takefocus=0,
orient="horizontal") orient="horizontal")
self.canvas["xscrollcommand"] = self._setHbar self.canvas["xscrollcommand"] = self._setHbar
self.hbar["command"] = self.canvas.xview self.hbar["command"] = self.canvas.xview
@ -580,7 +580,7 @@ class MfxScrolledCanvas:
self.hbar.grid_remove() self.hbar.grid_remove()
def createVbar(self): def createVbar(self):
self.vbar = Tkinter.Scrollbar(self.frame, takefocus=0) self.vbar = tkinter.Scrollbar(self.frame, takefocus=0)
self.canvas["yscrollcommand"] = self._setVbar self.canvas["yscrollcommand"] = self._setVbar
self.vbar["command"] = self.canvas.yview self.vbar["command"] = self.canvas.yview
self.vbar.grid(row=0, column=1, sticky="ns") self.vbar.grid(row=0, column=1, sticky="ns")
@ -704,9 +704,9 @@ class StackDesc:
text = stack.getHelp()+'\n'+stack.getBaseCard() text = stack.getHelp()+'\n'+stack.getBaseCard()
text = text.strip() text = text.strip()
if text: if text:
frame = Tkinter.Frame(self.canvas) frame = tkinter.Frame(self.canvas)
self.frame = frame self.frame = frame
label = Tkinter.Message(frame, font=font, text=text, label = tkinter.Message(frame, font=font, text=text,
width=cardw-8, relief='solid', width=cardw-8, relief='solid',
fg='#000000', bg='#ffffe0', bd=1) fg='#000000', bg='#ffffe0', bd=1)
label.pack() label.pack()

View file

@ -25,7 +25,7 @@ __all__ = ['PysolToolbarTk']
# imports # imports
import os import os
import Tkinter from six.moves import tkinter
# PySol imports # PySol imports
from pysollib.mygettext import _, n_ from pysollib.mygettext import _, n_
@ -74,23 +74,23 @@ class AbstractToolbarButton:
self.grid_forget() self.grid_forget()
class ToolbarCheckbutton(AbstractToolbarButton, Tkinter.Checkbutton): class ToolbarCheckbutton(AbstractToolbarButton, tkinter.Checkbutton):
def __init__(self, parent, toolbar, toolbar_name, position, **kwargs): def __init__(self, parent, toolbar, toolbar_name, position, **kwargs):
Tkinter.Checkbutton.__init__(self, parent, kwargs) tkinter.Checkbutton.__init__(self, parent, kwargs)
AbstractToolbarButton.__init__( AbstractToolbarButton.__init__(
self, parent, toolbar, toolbar_name, position) self, parent, toolbar, toolbar_name, position)
class ToolbarButton(AbstractToolbarButton, Tkinter.Button): class ToolbarButton(AbstractToolbarButton, tkinter.Button):
def __init__(self, parent, toolbar, toolbar_name, position, **kwargs): def __init__(self, parent, toolbar, toolbar_name, position, **kwargs):
Tkinter.Button.__init__(self, parent, kwargs) tkinter.Button.__init__(self, parent, kwargs)
AbstractToolbarButton.__init__( AbstractToolbarButton.__init__(
self, parent, toolbar, toolbar_name, position) self, parent, toolbar, toolbar_name, position)
class ToolbarSeparator(Tkinter.Frame): class ToolbarSeparator(tkinter.Frame):
def __init__(self, parent, toolbar, position, **kwargs): def __init__(self, parent, toolbar, position, **kwargs):
Tkinter.Frame.__init__(self, parent, kwargs) tkinter.Frame.__init__(self, parent, kwargs)
self.toolbar = toolbar self.toolbar = toolbar
self.position = position self.position = position
self.visible = False self.visible = False
@ -127,9 +127,9 @@ class ToolbarFlatSeparator(ToolbarSeparator):
pass pass
class ToolbarLabel(Tkinter.Message): class ToolbarLabel(tkinter.Message):
def __init__(self, parent, toolbar, toolbar_name, position, **kwargs): def __init__(self, parent, toolbar, toolbar_name, position, **kwargs):
Tkinter.Message.__init__(self, parent, kwargs) tkinter.Message.__init__(self, parent, kwargs)
self.toolbar = toolbar self.toolbar = toolbar
self.toolbar_name = toolbar_name self.toolbar_name = toolbar_name
self.position = position self.position = position
@ -178,7 +178,7 @@ class PysolToolbarTk:
self.orient = 'horizontal' self.orient = 'horizontal'
self.button_pad = 2 self.button_pad = 2
# #
self.frame = Tkinter.Frame(top, relief=TkSettings.toolbar_relief, self.frame = tkinter.Frame(top, relief=TkSettings.toolbar_relief,
bd=TkSettings.toolbar_borderwidth) bd=TkSettings.toolbar_borderwidth)
# #
for l, f, t in ( for l, f, t in (
@ -268,7 +268,7 @@ class PysolToolbarTk:
if Image: if Image:
image = ImageTk.PhotoImage(Image.open(file)) image = ImageTk.PhotoImage(Image.open(file))
else: else:
image = Tkinter.PhotoImage(file=file) image = tkinter.PhotoImage(file=file)
break break
return image return image

View file

@ -26,7 +26,7 @@ __all__ = ['WizardDialog']
# imports # imports
import sys import sys
import Tkinter from six.moves import tkinter
from tabpage import TabPageSet from tabpage import TabPageSet
# PySol imports # PySol imports
@ -54,7 +54,7 @@ class WizardDialog(MfxDialog):
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
frame = Tkinter.Frame(top_frame) frame = tkinter.Frame(top_frame)
frame.pack(expand=True, fill='both', padx=10, pady=10) frame.pack(expand=True, fill='both', padx=10, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
@ -64,17 +64,17 @@ class WizardDialog(MfxDialog):
for w in WizardWidgets: for w in WizardWidgets:
if isinstance(w, basestring): if isinstance(w, basestring):
notebook.AddPage(w) notebook.AddPage(w)
frame = Tkinter.Frame(notebook.pages[w]['page']) frame = tkinter.Frame(notebook.pages[w]['page'])
frame.pack(expand=True, fill='both', padx=2, pady=4) frame.pack(expand=True, fill='both', padx=2, pady=4)
frame.columnconfigure(1, weight=1) frame.columnconfigure(1, weight=1)
row = 0 row = 0
continue continue
Tkinter.Label(frame, text=w.label).grid(row=row, column=0, padx=2) tkinter.Label(frame, text=w.label).grid(row=row, column=0, padx=2)
if w.widget == 'preset': if w.widget == 'preset':
if w.variable is None: if w.variable is None:
w.variable = Tkinter.StringVar() w.variable = tkinter.StringVar()
values = [_(v) for v in w.values] values = [_(v) for v in w.values]
default = _(w.default) default = _(w.default)
values.remove(default) values.remove(default)
@ -83,32 +83,32 @@ class WizardDialog(MfxDialog):
def callback(v, w=w): def callback(v, w=w):
return self.presetSelected(v, w) return self.presetSelected(v, w)
om = Tkinter.OptionMenu(frame, w.variable, om = tkinter.OptionMenu(frame, w.variable,
command=callback, *values) command=callback, *values)
om.grid(row=row, column=1, sticky='ew', padx=2) om.grid(row=row, column=1, sticky='ew', padx=2)
elif w.widget == 'entry': elif w.widget == 'entry':
if w.variable is None: if w.variable is None:
w.variable = Tkinter.StringVar() w.variable = tkinter.StringVar()
en = Tkinter.Entry(frame, textvariable=w.variable) en = tkinter.Entry(frame, textvariable=w.variable)
en.grid(row=row, column=1, sticky='ew', padx=2) en.grid(row=row, column=1, sticky='ew', padx=2)
elif w.widget == 'menu': elif w.widget == 'menu':
if w.variable is None: if w.variable is None:
w.variable = Tkinter.StringVar() w.variable = tkinter.StringVar()
values = [_(v) for v in w.values] values = [_(v) for v in w.values]
om = Tkinter.OptionMenu(frame, w.variable, *values) om = tkinter.OptionMenu(frame, w.variable, *values)
om.grid(row=row, column=1, sticky='ew', padx=2) om.grid(row=row, column=1, sticky='ew', padx=2)
elif w.widget == 'spin': elif w.widget == 'spin':
if w.variable is None: if w.variable is None:
w.variable = Tkinter.IntVar() w.variable = tkinter.IntVar()
from_, to = w.values from_, to = w.values
s = Tkinter.Scale(frame, from_=from_, to=to, resolution=1, s = tkinter.Scale(frame, from_=from_, to=to, resolution=1,
orient='horizontal', length=200, orient='horizontal', length=200,
variable=w.variable) variable=w.variable)
s.grid(row=row, column=1, sticky='ew', padx=2) s.grid(row=row, column=1, sticky='ew', padx=2)
elif w.widget == 'check': elif w.widget == 'check':
if w.variable is None: if w.variable is None:
w.variable = Tkinter.BooleanVar() w.variable = tkinter.BooleanVar()
ch = Tkinter.Checkbutton(frame, variable=w.variable, ch = tkinter.Checkbutton(frame, variable=w.variable,
takefocus=False, anchor='w') takefocus=False, anchor='w')
ch.grid(row=row, column=1, sticky='ew', padx=2, pady=2) ch.grid(row=row, column=1, sticky='ew', padx=2, pady=2)

View file

@ -22,7 +22,7 @@
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# imports # imports
import Tkinter from six.moves import tkinter
from tkColorChooser import askcolor from tkColorChooser import askcolor
# PySol imports # PySol imports
@ -55,21 +55,21 @@ class BaseColorsDialog:
frame.pack(expand=True, fill='both', padx=5, pady=10) frame.pack(expand=True, fill='both', padx=5, pady=10)
frame.columnconfigure(0, weight=1) frame.columnconfigure(0, weight=1)
self.text_var = Tkinter.StringVar() self.text_var = tkinter.StringVar()
self.text_var.set(app.opt.colors['text']) self.text_var.set(app.opt.colors['text'])
self.piles_var = Tkinter.StringVar() self.piles_var = tkinter.StringVar()
self.piles_var.set(app.opt.colors['piles']) self.piles_var.set(app.opt.colors['piles'])
self.cards_1_var = Tkinter.StringVar() self.cards_1_var = tkinter.StringVar()
self.cards_1_var.set(app.opt.colors['cards_1']) self.cards_1_var.set(app.opt.colors['cards_1'])
self.cards_2_var = Tkinter.StringVar() self.cards_2_var = tkinter.StringVar()
self.cards_2_var.set(app.opt.colors['cards_2']) self.cards_2_var.set(app.opt.colors['cards_2'])
self.samerank_1_var = Tkinter.StringVar() self.samerank_1_var = tkinter.StringVar()
self.samerank_1_var.set(app.opt.colors['samerank_1']) self.samerank_1_var.set(app.opt.colors['samerank_1'])
self.samerank_2_var = Tkinter.StringVar() self.samerank_2_var = tkinter.StringVar()
self.samerank_2_var.set(app.opt.colors['samerank_2']) self.samerank_2_var.set(app.opt.colors['samerank_2'])
self.hintarrow_var = Tkinter.StringVar() self.hintarrow_var = tkinter.StringVar()
self.hintarrow_var.set(app.opt.colors['hintarrow']) self.hintarrow_var.set(app.opt.colors['hintarrow'])
self.not_matching_var = Tkinter.StringVar() self.not_matching_var = tkinter.StringVar()
self.not_matching_var.set(app.opt.colors['not_matching']) self.not_matching_var.set(app.opt.colors['not_matching'])
# #
row = 0 row = 0
@ -86,7 +86,7 @@ class BaseColorsDialog:
self._calcLabel()( self._calcLabel()(
frame, text=title, anchor='w',).grid( frame, text=title, anchor='w',).grid(
row=row, column=0, sticky='we') row=row, column=0, sticky='we')
l = Tkinter.Label(frame, width=10, height=2, l = tkinter.Label(frame, width=10, height=2,
bg=var.get(), textvariable=var) bg=var.get(), textvariable=var)
l.grid(row=row, column=1, padx=5) l.grid(row=row, column=1, padx=5)
b = self._calcButton()( b = self._calcButton()(

View file

@ -1,4 +1,4 @@
import Tkinter from six.moves import tkinter
from pysollib.mygettext import _ from pysollib.mygettext import _
from pysollib.mfxutil import KwStruct from pysollib.mfxutil import KwStruct
@ -12,7 +12,7 @@ class BaseEditTextDialog:
top_frame, bottom_frame = self.createFrames(kw) top_frame, bottom_frame = self.createFrames(kw)
self.createBitmaps(top_frame, kw) self.createBitmaps(top_frame, kw)
# #
self.text_w = Tkinter.Text(top_frame, bd=1, relief="sunken", self.text_w = tkinter.Text(top_frame, bd=1, relief="sunken",
wrap="word", width=64, height=16) wrap="word", width=64, height=16)
self.text_w.pack(side='left', fill="both", expand=True) self.text_w.pack(side='left', fill="both", expand=True)
# self.text_w.pack(side='top', padx=kw.padx, pady=kw.pady) # self.text_w.pack(side='top', padx=kw.padx, pady=kw.pady)

View file

@ -28,7 +28,7 @@ __all__ = ['create_find_card_dialog',
# imports # imports
import os import os
import Tkinter from six.moves import tkinter
# PySol imports # PySol imports
from pysollib.mygettext import _ from pysollib.mygettext import _
@ -50,11 +50,11 @@ LARGE_EMBLEMS_SIZE = (38, 34)
SMALL_EMBLEMS_SIZE = (31, 21) SMALL_EMBLEMS_SIZE = (31, 21)
class FindCardDialog(Tkinter.Toplevel): class FindCardDialog(tkinter.Toplevel):
CARD_IMAGES = {} # key: (rank, suit) CARD_IMAGES = {} # key: (rank, suit)
def __init__(self, parent, game, dir, size='large'): def __init__(self, parent, game, dir, size='large'):
Tkinter.Toplevel.__init__(self) tkinter.Toplevel.__init__(self)
title = TITLE + ' - ' + _('Find card') title = TITLE + ' - ' + _('Find card')
self.title(title) self.title(title)
self.wm_resizable(False, False) self.wm_resizable(False, False)
@ -201,7 +201,7 @@ class FindCardDialog(Tkinter.Toplevel):
if self.highlight_items: if self.highlight_items:
for i in self.highlight_items: for i in self.highlight_items:
i.delete() i.delete()
Tkinter.Toplevel.destroy(self) tkinter.Toplevel.destroy(self)
find_card_dialog = None find_card_dialog = None

View file

@ -3,7 +3,7 @@ import os
import re import re
import sys import sys
import Tkinter from six.moves import tkinter
import tkFileDialog import tkFileDialog
from pysollib.mfxutil import Struct, kwdefault from pysollib.mfxutil import Struct, kwdefault
@ -73,14 +73,14 @@ def createToolbarMenu(menubar, menu):
# * # *
# ************************************************************************ # ************************************************************************
class MfxMenubar(Tkinter.Menu): class MfxMenubar(tkinter.Menu):
addPath = None addPath = None
def __init__(self, master, **kw): def __init__(self, master, **kw):
self.name = kw["name"] self.name = kw["name"]
tearoff = 0 tearoff = 0
self.n = kw["tearoff"] = int(kw.get("tearoff", tearoff)) self.n = kw["tearoff"] = int(kw.get("tearoff", tearoff))
Tkinter.Menu.__init__(self, master, **kw) tkinter.Menu.__init__(self, master, **kw)
def labeltoname(self, label): def labeltoname(self, label):
# print label, type(label) # print label, type(label)
@ -104,7 +104,7 @@ class MfxMenubar(Tkinter.Menu):
if name and self.addPath: if name and self.addPath:
path = str(self._w) + "." + name path = str(self._w) + "." + name
self.addPath(path, self, self.n, cnf.get("menu")) self.addPath(path, self, self.n, cnf.get("menu"))
Tkinter.Menu.add(self, itemType, cnf) tkinter.Menu.add(self, itemType, cnf)
self.n = self.n + 1 self.n = self.n + 1
@ -152,54 +152,54 @@ class PysolMenubarTkCommon:
def _createTkOpt(self): def _createTkOpt(self):
# structure to convert menu-options to Toolkit variables # structure to convert menu-options to Toolkit variables
self.tkopt = Struct( self.tkopt = Struct(
gameid=Tkinter.IntVar(), gameid=tkinter.IntVar(),
gameid_popular=Tkinter.IntVar(), gameid_popular=tkinter.IntVar(),
comment=Tkinter.BooleanVar(), comment=tkinter.BooleanVar(),
autofaceup=Tkinter.BooleanVar(), autofaceup=tkinter.BooleanVar(),
autodrop=Tkinter.BooleanVar(), autodrop=tkinter.BooleanVar(),
autodeal=Tkinter.BooleanVar(), autodeal=tkinter.BooleanVar(),
quickplay=Tkinter.BooleanVar(), quickplay=tkinter.BooleanVar(),
undo=Tkinter.BooleanVar(), undo=tkinter.BooleanVar(),
bookmarks=Tkinter.BooleanVar(), bookmarks=tkinter.BooleanVar(),
hint=Tkinter.BooleanVar(), hint=tkinter.BooleanVar(),
shuffle=Tkinter.BooleanVar(), shuffle=tkinter.BooleanVar(),
highlight_piles=Tkinter.BooleanVar(), highlight_piles=tkinter.BooleanVar(),
highlight_cards=Tkinter.BooleanVar(), highlight_cards=tkinter.BooleanVar(),
highlight_samerank=Tkinter.BooleanVar(), highlight_samerank=tkinter.BooleanVar(),
highlight_not_matching=Tkinter.BooleanVar(), highlight_not_matching=tkinter.BooleanVar(),
mahjongg_show_removed=Tkinter.BooleanVar(), mahjongg_show_removed=tkinter.BooleanVar(),
shisen_show_hint=Tkinter.BooleanVar(), shisen_show_hint=tkinter.BooleanVar(),
sound=Tkinter.BooleanVar(), sound=tkinter.BooleanVar(),
auto_scale=Tkinter.BooleanVar(), auto_scale=tkinter.BooleanVar(),
cardback=Tkinter.IntVar(), cardback=tkinter.IntVar(),
tabletile=Tkinter.IntVar(), tabletile=tkinter.IntVar(),
animations=Tkinter.IntVar(), animations=tkinter.IntVar(),
redeal_animation=Tkinter.BooleanVar(), redeal_animation=tkinter.BooleanVar(),
win_animation=Tkinter.BooleanVar(), win_animation=tkinter.BooleanVar(),
shadow=Tkinter.BooleanVar(), shadow=tkinter.BooleanVar(),
shade=Tkinter.BooleanVar(), shade=tkinter.BooleanVar(),
shade_filled_stacks=Tkinter.BooleanVar(), shade_filled_stacks=tkinter.BooleanVar(),
shrink_face_down=Tkinter.BooleanVar(), shrink_face_down=tkinter.BooleanVar(),
toolbar=Tkinter.IntVar(), toolbar=tkinter.IntVar(),
toolbar_style=Tkinter.StringVar(), toolbar_style=tkinter.StringVar(),
toolbar_relief=Tkinter.StringVar(), toolbar_relief=tkinter.StringVar(),
toolbar_compound=Tkinter.StringVar(), toolbar_compound=tkinter.StringVar(),
toolbar_size=Tkinter.IntVar(), toolbar_size=tkinter.IntVar(),
statusbar=Tkinter.BooleanVar(), statusbar=tkinter.BooleanVar(),
num_cards=Tkinter.BooleanVar(), num_cards=tkinter.BooleanVar(),
helpbar=Tkinter.BooleanVar(), helpbar=tkinter.BooleanVar(),
save_games_geometry=Tkinter.BooleanVar(), save_games_geometry=tkinter.BooleanVar(),
splashscreen=Tkinter.BooleanVar(), splashscreen=tkinter.BooleanVar(),
demo_logo=Tkinter.BooleanVar(), demo_logo=tkinter.BooleanVar(),
mouse_type=Tkinter.StringVar(), mouse_type=tkinter.StringVar(),
mouse_undo=Tkinter.BooleanVar(), mouse_undo=tkinter.BooleanVar(),
negative_bottom=Tkinter.BooleanVar(), negative_bottom=tkinter.BooleanVar(),
pause=Tkinter.BooleanVar(), pause=tkinter.BooleanVar(),
theme=Tkinter.StringVar(), theme=tkinter.StringVar(),
toolbar_vars={}, toolbar_vars={},
) )
for w in TOOLBAR_BUTTONS: for w in TOOLBAR_BUTTONS:
self.tkopt.toolbar_vars[w] = Tkinter.BooleanVar() self.tkopt.toolbar_vars[w] = tkinter.BooleanVar()
def _setOptions(self): def _setOptions(self):
tkopt, opt = self.tkopt, self.app.opt tkopt, opt = self.tkopt, self.app.opt

View file

@ -1,4 +1,4 @@
import Tkinter from six.moves import tkinter
from pysollib.mygettext import _ from pysollib.mygettext import _
from pysollib.ui.tktile.tkconst import EVENT_HANDLED from pysollib.ui.tktile.tkconst import EVENT_HANDLED
@ -48,18 +48,18 @@ class BaseSolverDialog:
# #
row += 1 row += 1
self.max_iters_var = Tkinter.IntVar() self.max_iters_var = tkinter.IntVar()
self.max_iters_var.set(10e4) self.max_iters_var.set(10e4)
self._calcToolkit().Label( self._calcToolkit().Label(
frame, text=_('Max iterations:'), anchor='w').grid( frame, text=_('Max iterations:'), anchor='w').grid(
row=row, column=0, sticky='ew', padx=2, pady=2) row=row, column=0, sticky='ew', padx=2, pady=2)
spin = Tkinter.Spinbox(frame, bg='white', from_=1000, to=10e6, spin = tkinter.Spinbox(frame, bg='white', from_=1000, to=10e6,
increment=1000, textvariable=self.max_iters_var) increment=1000, textvariable=self.max_iters_var)
spin.grid(row=row, column=1, sticky='w', padx=2, pady=2) spin.grid(row=row, column=1, sticky='w', padx=2, pady=2)
# #
row += 1 row += 1
self.progress_var = Tkinter.BooleanVar() self.progress_var = tkinter.BooleanVar()
self.progress_var.set(True) self.progress_var.set(True)
w = self._createShowProgressButton(frame) w = self._createShowProgressButton(frame)
w.grid(row=row, column=0, columnspan=2, sticky='ew', padx=2, pady=2) w.grid(row=row, column=0, columnspan=2, sticky='ew', padx=2, pady=2)

View file

@ -29,7 +29,7 @@ __all__ = ['MfxCanvasGroup',
'MfxCanvas'] 'MfxCanvas']
# imports # imports
import Tkinter from six.moves import tkinter
import Canvas import Canvas
# PySol imports # PySol imports
@ -129,9 +129,9 @@ class MfxCanvasText(Canvas.CanvasText):
# * canvas # * canvas
# ************************************************************************ # ************************************************************************
class MfxCanvas(Tkinter.Canvas): class MfxCanvas(tkinter.Canvas):
def __init__(self, *args, **kw): def __init__(self, *args, **kw):
Tkinter.Canvas.__init__(self, *args, **kw) tkinter.Canvas.__init__(self, *args, **kw)
self.preview = 0 self.preview = 0
self.busy = False self.busy = False
# this is also used by lib-tk/Canvas.py # this is also used by lib-tk/Canvas.py
@ -219,11 +219,11 @@ class MfxCanvas(Tkinter.Canvas):
# #
def _x_create(self, itemType, *args, **kw): def _x_create(self, itemType, *args, **kw):
return Tkinter.Canvas._create(self, itemType, args, kw) return tkinter.Canvas._create(self, itemType, args, kw)
def _create(self, itemType, args, kw): def _create(self, itemType, args, kw):
# print "_create:", itemType, args, kw # print "_create:", itemType, args, kw
id = Tkinter.Canvas._create(self, itemType, args, kw) id = tkinter.Canvas._create(self, itemType, args, kw)
if self.__tops: if self.__tops:
self.tk.call(self._w, "lower", id, self.__tops[0]) self.tk.call(self._w, "lower", id, self.__tops[0])
return id return id
@ -340,7 +340,7 @@ class MfxCanvas(Tkinter.Canvas):
try: try:
if image and isinstance(image, str): if image and isinstance(image, str):
image = loadImage(file=image) image = loadImage(file=image)
except Tkinter.TclError: except tkinter.TclError:
return 0 return 0
if len(self.__tops) == 1 and image is self.__tops[0]: if len(self.__tops) == 1 and image is self.__tops[0]:
return 1 return 1
@ -391,7 +391,7 @@ class MfxCanvas(Tkinter.Canvas):
return funcid return funcid
def _substitute(self, *args): def _substitute(self, *args):
e = Tkinter.Event() e = tkinter.Event()
try: try:
# Tk changed behavior in 8.4.2, returning "??" rather more often. # Tk changed behavior in 8.4.2, returning "??" rather more often.
e.x = int(args[0]) e.x = int(args[0])

View file

@ -39,7 +39,7 @@ __all__ = ['EVENT_HANDLED',
] ]
# imports # imports
import Tkinter from six.moves import tkinter
from pysollib.mygettext import n_ from pysollib.mygettext import n_
@ -54,23 +54,23 @@ CURSOR_DRAG = "hand1"
CURSOR_WATCH = "watch" CURSOR_WATCH = "watch"
CURSOR_DOWN_ARROW = 'sb_down_arrow' CURSOR_DOWN_ARROW = 'sb_down_arrow'
ANCHOR_CENTER = Tkinter.CENTER ANCHOR_CENTER = tkinter.CENTER
ANCHOR_N = Tkinter.N ANCHOR_N = tkinter.N
ANCHOR_NW = Tkinter.NW ANCHOR_NW = tkinter.NW
ANCHOR_NE = Tkinter.NE ANCHOR_NE = tkinter.NE
ANCHOR_S = Tkinter.S ANCHOR_S = tkinter.S
ANCHOR_SW = Tkinter.SW ANCHOR_SW = tkinter.SW
ANCHOR_SE = Tkinter.SE ANCHOR_SE = tkinter.SE
ANCHOR_W = Tkinter.W ANCHOR_W = tkinter.W
ANCHOR_E = Tkinter.E ANCHOR_E = tkinter.E
COMPOUNDS = ( COMPOUNDS = (
# (Tkinter.BOTTOM, 'bottom'), # (tkinter.BOTTOM, 'bottom'),
# (Tkinter.CENTER, 'center'), # (tkinter.CENTER, 'center'),
# (Tkinter.RIGHT, 'right'), # (tkinter.RIGHT, 'right'),
(Tkinter.NONE, n_('Icons only')), (tkinter.NONE, n_('Icons only')),
(Tkinter.TOP, n_('Text below icons')), (tkinter.TOP, n_('Text below icons')),
(Tkinter.LEFT, n_('Text beside icons')), (tkinter.LEFT, n_('Text beside icons')),
('text', n_('Text only')), ('text', n_('Text only')),
) )

View file

@ -24,7 +24,7 @@
import os import os
import htmllib import htmllib
import formatter import formatter
import Tkinter from six.moves import tkinter
from pysollib.ui.tktile.tkutil import bind, unbind_destroy from pysollib.ui.tktile.tkutil import bind, unbind_destroy
from pysollib.mygettext import _ from pysollib.mygettext import _
@ -289,7 +289,7 @@ class Base_HTMLViewer:
def display(self, url, add=1, relpath=1, xview=0, yview=0): def display(self, url, add=1, relpath=1, xview=0, yview=0):
# for some reason we have to stop the PySol demo # for some reason we have to stop the PySol demo
# (is this a multithread problem with Tkinter ?) # (is this a multithread problem with tkinter ?)
if self.app and self.app.game: if self.app and self.app.game:
self.app.game.stopDemo() self.app.game.stopDemo()
# self.app.game._cancelDrag() # self.app.game._cancelDrag()
@ -425,7 +425,7 @@ to open the following URL:
if fn in self.images: if fn in self.images:
return self.images[fn] return self.images[fn]
try: try:
img = Tkinter.PhotoImage(master=self.parent, file=fn) img = tkinter.PhotoImage(master=self.parent, file=fn)
except: except:
img = None img = None
self.images[fn] = img self.images[fn] = img

View file

@ -47,7 +47,7 @@ __all__ = ['wm_withdraw',
# imports # imports
import re import re
import Tkinter from six.moves import tkinter
from tkFont import Font from tkFont import Font
# PySol imports # PySol imports
@ -82,7 +82,7 @@ def wm_get_geometry(window):
g = window.wm_geometry() g = window.wm_geometry()
m = __wm_get_geometry_re.search(g) m = __wm_get_geometry_re.search(g)
if not m: if not m:
raise Tkinter.TclError("invalid geometry "+str(g)) raise tkinter.TclError("invalid geometry "+str(g))
l = map(int, m.groups()) l = map(int, m.groups())
if window.wm_state() == "zoomed": if window.wm_state() == "zoomed":
# workaround as Tk returns the "unzoomed" origin # workaround as Tk returns the "unzoomed" origin
@ -120,7 +120,7 @@ def makeToplevel(parent, title=None):
# #
# This is a shortcut for a Toplevel() instantiation plus calls to # This is a shortcut for a Toplevel() instantiation plus calls to
# set the title and icon name of the window. # set the title and icon name of the window.
window = Tkinter.Toplevel(parent) # , class_=TITLE) window = tkinter.Toplevel(parent) # , class_=TITLE)
# window.wm_group(parent) # window.wm_group(parent)
# window.wm_command("") # window.wm_command("")
if WIN_SYSTEM == "x11": if WIN_SYSTEM == "x11":
@ -135,7 +135,7 @@ def makeToplevel(parent, title=None):
def make_help_toplevel(app, title=None): def make_help_toplevel(app, title=None):
# Create an independent Toplevel window. # Create an independent Toplevel window.
from pysollib.winsystems import init_root_window from pysollib.winsystems import init_root_window
window = Tkinter.Tk(className=TITLE) window = tkinter.Tk(className=TITLE)
init_root_window(window, app) init_root_window(window, app)
return window return window
@ -198,7 +198,7 @@ def __getWidgetXY(widget, parent, relx=None, rely=None,
# ************************************************************************ # ************************************************************************
# * bind wrapper - Tkinter doesn't properly delete all bindings # * bind wrapper - tkinter doesn't properly delete all bindings
# ************************************************************************ # ************************************************************************
__mfx_bindings = {} __mfx_bindings = {}
@ -235,7 +235,7 @@ def unbind_destroy(widget):
# widget.deletecommand(funcid) # widget.deletecommand(funcid)
else: else:
widget.unbind(sequence, funcid) widget.unbind(sequence, funcid)
except Tkinter.TclError: except tkinter.TclError:
pass pass
del __mfx_bindings[k] del __mfx_bindings[k]
# for k in __mfx_bindings.keys(): print __mfx_bindings[k] # for k in __mfx_bindings.keys(): print __mfx_bindings[k]
@ -243,7 +243,7 @@ def unbind_destroy(widget):
# ************************************************************************ # ************************************************************************
# * timer wrapper - Tkinter doesn't properly delete all commands # * timer wrapper - tkinter doesn't properly delete all commands
# ************************************************************************ # ************************************************************************
def after(widget, ms, func, *args): def after(widget, ms, func, *args):
@ -261,7 +261,7 @@ def after_cancel(t):
t[2].after_cancel(t[0]) t[2].after_cancel(t[0])
try: try:
t[2].deletecommand(t[1]) t[2].deletecommand(t[1])
except Tkinter.TclError: except tkinter.TclError:
pass pass
@ -311,8 +311,8 @@ def makeImage(file=None, data=None, dither=None, alpha=None):
return im return im
# fromstring(mode, size, data, decoder_name='raw', *args) # fromstring(mode, size, data, decoder_name='raw', *args)
else: else:
return Tkinter.PhotoImage(data=data) return tkinter.PhotoImage(data=data)
return Tkinter.PhotoImage(**kw) return tkinter.PhotoImage(**kw)
loadImage = makeImage loadImage = makeImage
@ -323,7 +323,7 @@ def copyImage(image, x, y, width, height):
if isinstance(image, PIL_Image): if isinstance(image, PIL_Image):
return ImageTk.PhotoImage( return ImageTk.PhotoImage(
image._pil_image.crop((x, y, x+width, y+height))) image._pil_image.crop((x, y, x+width, y+height)))
dest = Tkinter.PhotoImage(width=width, height=height) dest = tkinter.PhotoImage(width=width, height=height)
assert dest.width() == width assert dest.width() == width
assert dest.height() == height assert dest.height() == height
dest.blank() dest.blank()
@ -366,7 +366,7 @@ def fillImage(image, fill, outline=None):
def createImage(width, height, fill, outline=None): def createImage(width, height, fill, outline=None):
image = Tkinter.PhotoImage(width=width, height=height) image = tkinter.PhotoImage(width=width, height=height)
assert image.width() == width assert image.width() == width
assert image.height() == height assert image.height() == height
image.blank() image.blank()

View file

@ -25,9 +25,9 @@ __all__ = ['TclError',
'MfxRoot'] 'MfxRoot']
# imports # imports
import Tkinter from six.moves import tkinter
from pysollib.ui.tktile.tkconst import EVENT_PROPAGATE from pysollib.ui.tktile.tkconst import EVENT_PROPAGATE
TclError = Tkinter.TclError TclError = tkinter.TclError
# PySol imports # PySol imports
@ -37,13 +37,13 @@ TclError = Tkinter.TclError
# * Required so that a Game will get properly destroyed. # * Required so that a Game will get properly destroyed.
# ************************************************************************ # ************************************************************************
class MfxRoot(Tkinter.Tk): class MfxRoot(tkinter.Tk):
def __init__(self, **kw): def __init__(self, **kw):
Tkinter.Tk.__init__(self, **kw) tkinter.Tk.__init__(self, **kw)
self.app = None self.app = None
self.wm_protocol('WM_DELETE_WINDOW', self.wmDeleteWindow) self.wm_protocol('WM_DELETE_WINDOW', self.wmDeleteWindow)
# for interruptible sleep # for interruptible sleep
# self.sleep_var = Tkinter.IntVar(self) # self.sleep_var = tkinter.IntVar(self)
# self.sleep_var.set(0) # self.sleep_var.set(0)
self.sleep_var = 0 self.sleep_var = 0
self.after_id = None self.after_id = None
@ -78,7 +78,7 @@ class MfxRoot(Tkinter.Tk):
def setCursor(self, cursor): def setCursor(self, cursor):
if 0: if 0:
# FIXME: this causes ugly resizes ! # FIXME: this causes ugly resizes !
Tkinter.Tk.config(self, cursor=cursor) tkinter.Tk.config(self, cursor=cursor)
elif 0: elif 0:
# and this is even worse # and this is even worse
# print self.children # print self.children
@ -138,7 +138,7 @@ class MfxRoot(Tkinter.Tk):
# #
def update(self): def update(self):
Tkinter.Tk.update(self) tkinter.Tk.update(self)
def wmDeleteWindow(self): def wmDeleteWindow(self):
if self.app and self.app.menubar: if self.app and self.app.menubar:

View file

@ -6,10 +6,7 @@ import sys
import os import os
from glob import glob from glob import glob
from math import sqrt, sin, cos, pi from math import sqrt, sin, cos, pi
from Tkinter import BOTH, Button, Frame, PhotoImage, NW, Text, Toplevel, X, YES from six.moves import tkinter
from Tkinter import RIGHT, Tk, Listbox, NS, END, Scrollbar, Canvas, NSEW
from Tkinter import HORIZONTAL, Label, EW, IntVar, StringVar, LEFT, Checkbutton
from Tkinter import OptionMenu
try: try:
from PIL import Image, ImageTk from PIL import Image, ImageTk
except ImportError: except ImportError:
@ -136,9 +133,9 @@ def show_cardset(*args):
else: else:
zoom_label.config(text='') zoom_label.config(text='')
image = ImageTk.PhotoImage(im) image = ImageTk.tkinter.PhotoImage(im)
else: else:
image = PhotoImage(file=f) image = tkinter.PhotoImage(file=f)
tk_images.append(image) tk_images.append(image)
ff = os.path.split(f)[1] ff = os.path.split(f)[1]
if pf is None: if pf is None:
@ -150,7 +147,7 @@ def show_cardset(*args):
y += image.height()+10 y += image.height()+10
else: else:
x += image.width()+10 x += image.width()+10
canvas.create_image(x, y, image=image, anchor=NW) canvas.create_image(x, y, image=image, anchor=tkinter.NW)
# canvas.create_rectangle(x, y, x+image.width(), y+image.height()) # canvas.create_rectangle(x, y, x+image.width(), y+image.height())
width = max(width, x) width = max(width, x)
height = max(height, y) height = max(height, y)
@ -186,81 +183,83 @@ def show_info(*args):
cs_name = list_box.get(list_box.curselection()) cs_name = list_box.get(list_box.curselection())
cs = cardsets_dict[cs_name] cs = cardsets_dict[cs_name]
fn = os.path.join(cs.dir, 'COPYRIGHT') fn = os.path.join(cs.dir, 'COPYRIGHT')
top = Toplevel() top = tkinter.Toplevel()
text = Text(top) text = tkinter.Text(top)
text.insert('insert', open(fn).read()) text.insert('insert', open(fn).read())
text.pack(expand=YES, fill=BOTH) text.pack(expand=tkinter.YES, fill=tkinter.BOTH)
b_frame = Frame(top) b_frame = tkinter.Frame(top)
b_frame.pack(fill=X) b_frame.pack(fill=tkinter.X)
button = Button(b_frame, text='Close', command=top.destroy) button = tkinter.Button(b_frame, text='Close', command=top.destroy)
button.pack(side=RIGHT) button.pack(side=tkinter.RIGHT)
def create_widgets(): def create_widgets():
global list_box, canvas, label, zoom_label global list_box, canvas, label, zoom_label
# #
root = Tk() root = tkinter.Tk()
# #
list_box = Listbox(root, exportselection=False) list_box = tkinter.Listbox(root, exportselection=False)
list_box.grid(row=0, column=0, rowspan=2, sticky=NS) list_box.grid(row=0, column=0, rowspan=2, sticky=tkinter.NS)
cardsets_list = list(cardsets_dict) cardsets_list = list(cardsets_dict)
cardsets_list.sort() cardsets_list.sort()
for cs in cardsets_list: for cs in cardsets_list:
list_box.insert(END, cs) list_box.insert(tkinter.END, cs)
list_box.bind('<<ListboxSelect>>', show_cardset) list_box.bind('<<ListboxSelect>>', show_cardset)
# #
sb = Scrollbar(root) sb = tkinter.Scrollbar(root)
sb.grid(row=0, column=1, rowspan=2, sticky=NS) sb.grid(row=0, column=1, rowspan=2, sticky=tkinter.NS)
list_box.config(yscrollcommand=sb.set) list_box.config(yscrollcommand=sb.set)
sb.config(command=list_box.yview) sb.config(command=list_box.yview)
# #
canvas = Canvas(root, bg='#5eab6b') canvas = tkinter.Canvas(root, bg='#5eab6b')
canvas.grid(row=0, column=2, sticky=NSEW) canvas.grid(row=0, column=2, sticky=tkinter.NSEW)
canvas.bind('<4>', lambda e: canvas.yview_scroll(-5, 'unit')) canvas.bind('<4>', lambda e: canvas.yview_scroll(-5, 'unit'))
canvas.bind('<5>', lambda e: canvas.yview_scroll(5, 'unit')) canvas.bind('<5>', lambda e: canvas.yview_scroll(5, 'unit'))
# #
sb = Scrollbar(root) sb = tkinter.Scrollbar(root)
sb.grid(row=0, column=3, sticky=NS) sb.grid(row=0, column=3, sticky=tkinter.NS)
canvas.config(yscrollcommand=sb.set) canvas.config(yscrollcommand=sb.set)
sb.config(command=canvas.yview) sb.config(command=canvas.yview)
# #
if True: if True:
sb = Scrollbar(root, orient=HORIZONTAL) sb = tkinter.Scrollbar(root, orient=tkinter.HORIZONTAL)
sb.grid(row=1, column=2, sticky=EW) sb.grid(row=1, column=2, sticky=tkinter.EW)
canvas.config(xscrollcommand=sb.set) canvas.config(xscrollcommand=sb.set)
sb.config(command=canvas.xview) sb.config(command=canvas.xview)
# #
label = Label(root) label = tkinter.Label(root)
label.grid(row=2, column=0, columnspan=4) label.grid(row=2, column=0, columnspan=4)
# #
b_frame = Frame(root) b_frame = tkinter.Frame(root)
b_frame.grid(row=3, column=0, columnspan=4, sticky=EW) b_frame.grid(row=3, column=0, columnspan=4, sticky=tkinter.EW)
button = Button(b_frame, text='Quit', command=root.quit, width=8) button = tkinter.Button(b_frame, text='Quit', command=root.quit, width=8)
button.pack(side=RIGHT) button.pack(side=tkinter.RIGHT)
button = Button(b_frame, text='Info', command=show_info, width=8) button = tkinter.Button(b_frame, text='Info', command=show_info, width=8)
button.pack(side=RIGHT) button.pack(side=tkinter.RIGHT)
if Image: if Image:
global rotate_var, filter_var global rotate_var, filter_var
rotate_var = IntVar(root) rotate_var = tkinter.IntVar(root)
filter_var = StringVar(root) filter_var = tkinter.StringVar(root)
button = Button(b_frame, text=' + ', command=zoom_in) button = tkinter.Button(b_frame, text=' + ', command=zoom_in)
button.pack(side=LEFT) button.pack(side=tkinter.LEFT)
button = Button(b_frame, text=' - ', command=zoom_out) button = tkinter.Button(b_frame, text=' - ', command=zoom_out)
button.pack(side=LEFT) button.pack(side=tkinter.LEFT)
button = Button(b_frame, text=' = ', command=zoom_cancel) button = tkinter.Button(b_frame, text=' = ', command=zoom_cancel)
button.pack(side=LEFT) button.pack(side=tkinter.LEFT)
button = Checkbutton(b_frame, text='Rotate', indicatoron=0, button = tkinter.Checkbutton(
selectcolor=b_frame['bg'], width=8, b_frame, text='Rotate', indicatoron=0,
variable=rotate_var, command=show_cardset) selectcolor=b_frame['bg'], width=8,
button.pack(side=LEFT, fill='y') variable=rotate_var, command=show_cardset)
om = OptionMenu(b_frame, filter_var, button.pack(side=tkinter.LEFT, fill='y')
'NEAREST', 'BILINEAR', 'BICUBIC', 'ANTIALIAS', om = tkinter.OptionMenu(
command=show_cardset) b_frame, filter_var,
'NEAREST', 'BILINEAR', 'BICUBIC', 'ANTIALIAS',
command=show_cardset)
filter_var.set('NEAREST') filter_var.set('NEAREST')
om.pack(side=LEFT, fill='y') om.pack(side=tkinter.LEFT, fill='y')
zoom_label = Label(b_frame) zoom_label = tkinter.Label(b_frame)
zoom_label.pack(side=LEFT) zoom_label.pack(side=tkinter.LEFT)
# #
root.columnconfigure(2, weight=1) root.columnconfigure(2, weight=1)
root.rowconfigure(0, weight=1) root.rowconfigure(0, weight=1)

View file

@ -6,7 +6,7 @@ Usage:
import os import os
import sys import sys
import shutil import shutil
import Tkinter from six.moves import tkinter
from subprocess import call from subprocess import call
from setuptools import setup from setuptools import setup
from pysollib.settings import PACKAGE, VERSION from pysollib.settings import PACKAGE, VERSION
@ -28,7 +28,7 @@ call("./scripts/all_games.py > docs/all_games.html", shell=True)
# Use Tile widgets, if they are installed. # Use Tile widgets, if they are installed.
# http://tktable.sourceforge.net/tile/ # http://tktable.sourceforge.net/tile/
root = Tkinter.Tk() root = tkinter.Tk()
root.withdraw() root.withdraw()
try: try:
root.tk.call('package', 'require', 'tile', '0.7.8') root.tk.call('package', 'require', 'tile', '0.7.8')
@ -39,7 +39,7 @@ else:
TCL_EXTENSION_PATH = "/Library/Tcl" TCL_EXTENSION_PATH = "/Library/Tcl"
finally: finally:
root.destroy() root.destroy()
del root, Tkinter del root, tkinter
# Use Freecell Solver, if it is installed. # Use Freecell Solver, if it is installed.
# http://fc-solve.berlios.de/ # http://fc-solve.berlios.de/