1
0
Fork 0
mirror of https://github.com/shlomif/PySolFC.git synced 2025-04-05 00:02:29 -04:00
This commit is contained in:
Shlomi Fish 2017-04-18 18:44:49 +03:00
parent 85afebeaaf
commit bf5d8b91a1
2 changed files with 20 additions and 19 deletions

View file

@ -28,7 +28,7 @@ import Tkinter
import tkFont
# PySol imports
from pysollib.mygettext import _, n_
from pysollib.mygettext import _
from pysollib.mfxutil import KwStruct
# Toolkit imports
@ -39,9 +39,10 @@ from pysollib.ui.tktile.tkutil import bind
# *
# ************************************************************************
class FontChooserDialog(MfxDialog):
def __init__(self, parent, title, init_font, **kw):
##print init_font
# print init_font
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
top_frame, bottom_frame = self.createFrames(kw)
@ -90,7 +91,7 @@ class FontChooserDialog(MfxDialog):
self.list_box.grid(row=1, column=0, sticky='news') # rowspan=4
sb.grid(row=1, column=1, sticky='ns')
bind(self.list_box, '<<ListboxSelect>>', self.fontupdate)
##self.list_box.focus()
# self.list_box.focus()
cb1 = Tkinter.Checkbutton(frame, anchor='w', text=_('Bold'),
command=self.fontupdate,
variable=self.weight_var)
@ -151,7 +152,12 @@ class FontChooserDialog(MfxDialog):
# *
# ************************************************************************
class FontsDialog(MfxDialog):
def _font2title(self, font):
return ' '.join(
[str(i) for i in font if i not in ('roman', 'normal')])
def __init__(self, parent, title, app, **kw):
kw = self.initKw(kw)
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
@ -164,7 +170,7 @@ class FontsDialog(MfxDialog):
self.fonts = {}
row = 0
for fn, title in (##('default', _('Default')),
for fn, title in ( # ('default', _('Default')),
('sans', _('HTML: ')),
('small', _('Small: ')),
('fixed', _('Fixed: ')),
@ -178,35 +184,30 @@ class FontsDialog(MfxDialog):
Tkinter.Label(frame, text=title, anchor='w'
).grid(row=row, column=0, sticky='we')
if font:
title = ' '.join([str(i) for i in font if i not in ('roman', 'normal')])
title = self._font2title(font)
elif font is None:
title = 'Default'
l = Tkinter.Label(frame, font=font, text=title)
l.grid(row=row, column=1)
b = Tkinter.Button(frame, text=_('Change...'), width=10,
command=lambda l=l, fn=fn: self.selectFont(l, fn))
command=lambda l=l,
fn=fn: self.selectFont(l, fn))
b.grid(row=row, column=2)
row += 1
#
focus = self.createButtons(bottom_frame, kw)
self.mainloop(focus, kw.timeout)
def selectFont(self, label, fn):
d = FontChooserDialog(self.top, _('Select font'), self.fonts[fn])
if d.status == 0 and d.button == 0:
self.fonts[fn] = d.font
title = ' '.join([str(i) for i in d.font if i not in ('roman', 'normal')])
title = self._font2title(d.font)
label.configure(font=d.font, text=title)
def initKw(self, kw):
kw = KwStruct(kw,
strings=(_('&OK'), _('&Cancel')),
default=0,
)
return MfxDialog.initKw(self, kw)

View file

@ -27,7 +27,7 @@ my %skip =
# my $cmd = shell_quote( 'flake8', '.' );
my $cmd = shell_quote( 'flake8',
grep { not exists $skip{$_} } glob('./*.py ./scripts/*.py ./tests/board_gen/*.py ./pysollib/*.py ./pysollib/[cmgpuw]*/{*/*.py,*.py} ./pysollib/tile/*.py ./pysollib/tk/[a-e]*.py ./pysollib/ui/tktile/*.py') );
grep { not exists $skip{$_} } glob('./*.py ./scripts/*.py ./tests/board_gen/*.py ./pysollib/*.py ./pysollib/[cmgpuw]*/{*/*.py,*.py} ./pysollib/tile/*.py ./pysollib/tk/[a-f]*.py ./pysollib/ui/tktile/*.py') );
# TEST
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );