mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
sixify tkfont.
This commit is contained in:
parent
72a2591ec1
commit
ce6f5613a3
10 changed files with 24 additions and 26 deletions
|
@ -27,7 +27,6 @@ __all__ = []
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
# from tkFont import Font
|
|
||||||
from gettext import ungettext
|
from gettext import ungettext
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
|
|
|
@ -25,7 +25,6 @@ __all__ = []
|
||||||
|
|
||||||
# Imports
|
# Imports
|
||||||
import sys
|
import sys
|
||||||
# from tkFont import Font
|
|
||||||
from gettext import ungettext
|
from gettext import ungettext
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
|
|
|
@ -26,7 +26,7 @@ __all__ = ['FontsDialog']
|
||||||
# imports
|
# imports
|
||||||
from six.moves import tkinter
|
from six.moves import tkinter
|
||||||
import ttk
|
import ttk
|
||||||
import tkFont
|
from six.moves import tkinter_font
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.mfxutil import KwStruct
|
from pysollib.mfxutil import KwStruct
|
||||||
|
@ -111,7 +111,7 @@ class FontChooserDialog(MfxDialog):
|
||||||
command=self.fontupdate, variable=self.size_var)
|
command=self.fontupdate, variable=self.size_var)
|
||||||
sc.grid(row=4, column=0, columnspan=2, sticky='news')
|
sc.grid(row=4, column=0, columnspan=2, sticky='news')
|
||||||
#
|
#
|
||||||
font_families = list(tkFont.families())
|
font_families = list(tkinter_font.families())
|
||||||
font_families.sort()
|
font_families.sort()
|
||||||
selected = -1
|
selected = -1
|
||||||
n = 0
|
n = 0
|
||||||
|
|
|
@ -35,7 +35,7 @@ import os
|
||||||
import time
|
import time
|
||||||
from six.moves import tkinter
|
from six.moves import tkinter
|
||||||
import ttk
|
import ttk
|
||||||
import tkFont
|
from six.moves import tkinter_font
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.mygettext import _
|
from pysollib.mygettext import _
|
||||||
|
@ -64,11 +64,11 @@ class StatsDialog(MfxDialog):
|
||||||
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
|
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
|
||||||
|
|
||||||
self.font = app.getFont('default')
|
self.font = app.getFont('default')
|
||||||
self.tkfont = tkFont.Font(parent, self.font)
|
self.tkfont = tkinter_font.Font(parent, self.font)
|
||||||
self.font_metrics = self.tkfont.metrics()
|
self.font_metrics = self.tkfont.metrics()
|
||||||
style = ttk.Style(parent)
|
style = ttk.Style(parent)
|
||||||
heading_font = style.lookup('Heading', 'font') # treeview heading
|
heading_font = style.lookup('Heading', 'font') # treeview heading
|
||||||
self.heading_tkfont = tkFont.Font(parent, heading_font)
|
self.heading_tkfont = tkinter_font.Font(parent, heading_font)
|
||||||
|
|
||||||
self.selected_game = None
|
self.selected_game = None
|
||||||
|
|
||||||
|
@ -509,10 +509,10 @@ class LogDialog(MfxDialog):
|
||||||
def __init__(self, parent, title, app, player, **kw):
|
def __init__(self, parent, title, app, player, **kw):
|
||||||
|
|
||||||
self.font = app.getFont('default')
|
self.font = app.getFont('default')
|
||||||
self.tkfont = tkFont.Font(parent, self.font)
|
self.tkfont = tkinter_font.Font(parent, self.font)
|
||||||
style = ttk.Style(parent)
|
style = ttk.Style(parent)
|
||||||
heading_font = style.lookup('Heading', 'font') # treeview heading
|
heading_font = style.lookup('Heading', 'font') # treeview heading
|
||||||
self.heading_tkfont = tkFont.Font(parent, heading_font)
|
self.heading_tkfont = tkinter_font.Font(parent, heading_font)
|
||||||
self.font_metrics = self.tkfont.metrics()
|
self.font_metrics = self.tkfont.metrics()
|
||||||
|
|
||||||
self.CHAR_H = self.font_metrics['linespace']
|
self.CHAR_H = self.font_metrics['linespace']
|
||||||
|
|
|
@ -38,7 +38,7 @@ import time
|
||||||
import locale
|
import locale
|
||||||
from six.moves import tkinter
|
from six.moves import tkinter
|
||||||
import ttk
|
import ttk
|
||||||
import tkFont
|
from six.moves import tkinter_font
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
|
@ -328,10 +328,10 @@ class PysolAboutDialog(MfxMessageDialog):
|
||||||
if sys.version_info >= (2, 4):
|
if sys.version_info >= (2, 4):
|
||||||
# font_name = msg.lookup('TLabel', 'font')
|
# font_name = msg.lookup('TLabel', 'font')
|
||||||
font_name = 'TkDefaultFont'
|
font_name = 'TkDefaultFont'
|
||||||
font = tkFont.Font(parent, name=font_name, exists=True)
|
font = tkinter_font.Font(parent, name=font_name, exists=True)
|
||||||
font = font.copy()
|
font = font.copy()
|
||||||
else:
|
else:
|
||||||
font = tkFont.Font(parent, app.getFont('default'))
|
font = tkinter_font.Font(parent, app.getFont('default'))
|
||||||
font.configure(underline=True)
|
font.configure(underline=True)
|
||||||
url_label = ttk.Label(frame, text=kw.url, font=font,
|
url_label = ttk.Label(frame, text=kw.url, font=font,
|
||||||
foreground='blue', cursor='hand2')
|
foreground='blue', cursor='hand2')
|
||||||
|
|
|
@ -25,7 +25,7 @@ __all__ = ['FontsDialog']
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
from six.moves import tkinter
|
from six.moves import tkinter
|
||||||
import tkFont
|
from six.moves import tkinter_font
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.mygettext import _
|
from pysollib.mygettext import _
|
||||||
|
@ -110,7 +110,7 @@ class FontChooserDialog(MfxDialog):
|
||||||
self.size_var.set(self.font_size)
|
self.size_var.set(self.font_size)
|
||||||
self.weight_var.set(self.font_weight == 'bold')
|
self.weight_var.set(self.font_weight == 'bold')
|
||||||
self.slant_var.set(self.font_slant == 'italic')
|
self.slant_var.set(self.font_slant == 'italic')
|
||||||
font_families = list(tkFont.families())
|
font_families = list(tkinter_font.families())
|
||||||
font_families.sort()
|
font_families.sort()
|
||||||
selected = -1
|
selected = -1
|
||||||
n = 0
|
n = 0
|
||||||
|
|
|
@ -34,7 +34,7 @@ __all__ = ['SingleGame_StatsDialog',
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from six.moves import tkinter
|
from six.moves import tkinter
|
||||||
import tkFont
|
from six.moves import tkinter_font
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.mygettext import _
|
from pysollib.mygettext import _
|
||||||
|
@ -79,7 +79,7 @@ class SingleGame_StatsDialog(MfxDialog):
|
||||||
# createChart = self.createSimpleChart
|
# createChart = self.createSimpleChart
|
||||||
#
|
#
|
||||||
self.font = self.app.getFont("default")
|
self.font = self.app.getFont("default")
|
||||||
self.tk_font = tkFont.Font(self.top, self.font)
|
self.tk_font = tkinter_font.Font(self.top, self.font)
|
||||||
self.font_metrics = self.tk_font.metrics()
|
self.font_metrics = self.tk_font.metrics()
|
||||||
self._calc_tabs()
|
self._calc_tabs()
|
||||||
#
|
#
|
||||||
|
@ -335,7 +335,7 @@ class CanvasFormatter(PysolStatsFormatter):
|
||||||
tw = 15*self.w
|
tw = 15*self.w
|
||||||
# tw = 160
|
# tw = 160
|
||||||
self._tabs = [tw]
|
self._tabs = [tw]
|
||||||
font = tkFont.Font(self.canvas, self.font)
|
font = tkinter_font.Font(self.canvas, self.font)
|
||||||
for t in arg[1:]:
|
for t in arg[1:]:
|
||||||
tw = font.measure(t)+20
|
tw = font.measure(t)+20
|
||||||
self._tabs.append(tw)
|
self._tabs.append(tw)
|
||||||
|
@ -481,7 +481,7 @@ class AllGames_StatsDialog(MfxDialog):
|
||||||
# lines = 20
|
# lines = 20
|
||||||
#
|
#
|
||||||
self.font = app.getFont(self.FONT_TYPE)
|
self.font = app.getFont(self.FONT_TYPE)
|
||||||
font = tkFont.Font(parent, self.font)
|
font = tkinter_font.Font(parent, self.font)
|
||||||
self.font_metrics = font.metrics()
|
self.font_metrics = font.metrics()
|
||||||
self.CHAR_H = self.font_metrics['linespace']
|
self.CHAR_H = self.font_metrics['linespace']
|
||||||
self.CHAR_W = font.measure('M')
|
self.CHAR_W = font.measure('M')
|
||||||
|
@ -831,8 +831,8 @@ class ProgressionDialog(MfxDialog):
|
||||||
def __init__(self, parent, title, app, player, gameid, **kw):
|
def __init__(self, parent, title, app, player, gameid, **kw):
|
||||||
|
|
||||||
font_name = app.getFont('default')
|
font_name = app.getFont('default')
|
||||||
font = tkFont.Font(parent, font_name)
|
font = tkinter_font.Font(parent, font_name)
|
||||||
tkfont = tkFont.Font(parent, font)
|
tkfont = tkinter_font.Font(parent, font)
|
||||||
font_metrics = font.metrics()
|
font_metrics = font.metrics()
|
||||||
measure = tkfont.measure
|
measure = tkfont.measure
|
||||||
self.text_height = font_metrics['linespace']
|
self.text_height = font_metrics['linespace']
|
||||||
|
|
|
@ -35,7 +35,7 @@ __all__ = ['MfxDialog',
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
from six.moves import tkinter
|
from six.moves import tkinter
|
||||||
import tkFont
|
from six.moves import tkinter_font
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
|
@ -324,7 +324,7 @@ class PysolAboutDialog(MfxMessageDialog):
|
||||||
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 = tkinter_font.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')
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
import tkFont
|
from six.moves import tkinter_font
|
||||||
|
|
||||||
|
|
||||||
class BaseSelectDialogTreeLeaf:
|
class BaseSelectDialogTreeLeaf:
|
||||||
|
@ -110,7 +110,7 @@ class BaseSelectDialogTreeCanvas:
|
||||||
self.style.height = 14 # height of symbol
|
self.style.height = 14 # height of symbol
|
||||||
if font:
|
if font:
|
||||||
self.style.font = font
|
self.style.font = font
|
||||||
f = tkFont.Font(parent, font)
|
f = tkinter_font.Font(parent, font)
|
||||||
h = f.metrics()["linespace"]
|
h = f.metrics()["linespace"]
|
||||||
self.style.disty = max(self.style.width, h)
|
self.style.disty = max(self.style.width, h)
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ __all__ = ['wm_withdraw',
|
||||||
# imports
|
# imports
|
||||||
import re
|
import re
|
||||||
from six.moves import tkinter
|
from six.moves import tkinter
|
||||||
from tkFont import Font
|
from six.moves import tkinter_font
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.mfxutil import Image, ImageTk, ImageOps
|
from pysollib.mfxutil import Image, ImageTk, ImageOps
|
||||||
|
@ -444,4 +444,4 @@ def resizeBottom(image, maskimage, color='white', backfile=None):
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
def get_text_width(text, font, root=None):
|
def get_text_width(text, font, root=None):
|
||||||
return Font(root=root, font=font).measure(text)
|
return tkinter_font.Font(root=root, font=font).measure(text)
|
||||||
|
|
Loading…
Add table
Reference in a new issue