mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake8
This commit is contained in:
parent
85afebeaaf
commit
bf5d8b91a1
2 changed files with 20 additions and 19 deletions
|
@ -28,7 +28,7 @@ import Tkinter
|
||||||
import tkFont
|
import tkFont
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.mygettext import _, n_
|
from pysollib.mygettext import _
|
||||||
from pysollib.mfxutil import KwStruct
|
from pysollib.mfxutil import KwStruct
|
||||||
|
|
||||||
# Toolkit imports
|
# Toolkit imports
|
||||||
|
@ -39,16 +39,17 @@ from pysollib.ui.tktile.tkutil import bind
|
||||||
# *
|
# *
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
|
|
||||||
class FontChooserDialog(MfxDialog):
|
class FontChooserDialog(MfxDialog):
|
||||||
def __init__(self, parent, title, init_font, **kw):
|
def __init__(self, parent, title, init_font, **kw):
|
||||||
##print init_font
|
# print init_font
|
||||||
kw = self.initKw(kw)
|
kw = self.initKw(kw)
|
||||||
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)
|
||||||
|
|
||||||
self.font_family = 'Helvetica'
|
self.font_family = 'Helvetica'
|
||||||
self.font_size = 12
|
self.font_size = 12
|
||||||
self.font_weight = 'normal'
|
self.font_weight = 'normal'
|
||||||
self.font_slant = 'roman'
|
self.font_slant = 'roman'
|
||||||
|
|
||||||
|
@ -71,7 +72,7 @@ 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()
|
||||||
|
@ -79,7 +80,7 @@ class FontChooserDialog(MfxDialog):
|
||||||
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'))
|
||||||
|
@ -87,10 +88,10 @@ class FontChooserDialog(MfxDialog):
|
||||||
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)
|
||||||
|
@ -101,7 +102,7 @@ class FontChooserDialog(MfxDialog):
|
||||||
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)
|
||||||
sc.grid(row=4, column=0, columnspan=2, sticky='news')
|
sc.grid(row=4, column=0, columnspan=2, sticky='news')
|
||||||
|
@ -151,7 +152,12 @@ class FontChooserDialog(MfxDialog):
|
||||||
# *
|
# *
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
|
|
||||||
class FontsDialog(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):
|
def __init__(self, parent, title, app, **kw):
|
||||||
kw = self.initKw(kw)
|
kw = self.initKw(kw)
|
||||||
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
|
MfxDialog.__init__(self, parent, title, kw.resizable, kw.default)
|
||||||
|
@ -164,7 +170,7 @@ class FontsDialog(MfxDialog):
|
||||||
|
|
||||||
self.fonts = {}
|
self.fonts = {}
|
||||||
row = 0
|
row = 0
|
||||||
for fn, title in (##('default', _('Default')),
|
for fn, title in ( # ('default', _('Default')),
|
||||||
('sans', _('HTML: ')),
|
('sans', _('HTML: ')),
|
||||||
('small', _('Small: ')),
|
('small', _('Small: ')),
|
||||||
('fixed', _('Fixed: ')),
|
('fixed', _('Fixed: ')),
|
||||||
|
@ -178,35 +184,30 @@ class FontsDialog(MfxDialog):
|
||||||
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 = ' '.join([str(i) for i in font if i not in ('roman', 'normal')])
|
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, fn=fn: self.selectFont(l, fn))
|
command=lambda l=l,
|
||||||
|
fn=fn: self.selectFont(l, fn))
|
||||||
b.grid(row=row, column=2)
|
b.grid(row=row, column=2)
|
||||||
row += 1
|
row += 1
|
||||||
#
|
#
|
||||||
focus = self.createButtons(bottom_frame, kw)
|
focus = self.createButtons(bottom_frame, kw)
|
||||||
self.mainloop(focus, kw.timeout)
|
self.mainloop(focus, kw.timeout)
|
||||||
|
|
||||||
|
|
||||||
def selectFont(self, label, fn):
|
def selectFont(self, label, fn):
|
||||||
d = FontChooserDialog(self.top, _('Select font'), self.fonts[fn])
|
d = FontChooserDialog(self.top, _('Select font'), self.fonts[fn])
|
||||||
if d.status == 0 and d.button == 0:
|
if d.status == 0 and d.button == 0:
|
||||||
self.fonts[fn] = d.font
|
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)
|
label.configure(font=d.font, text=title)
|
||||||
|
|
||||||
|
|
||||||
def initKw(self, kw):
|
def initKw(self, kw):
|
||||||
kw = KwStruct(kw,
|
kw = KwStruct(kw,
|
||||||
strings=(_('&OK'), _('&Cancel')),
|
strings=(_('&OK'), _('&Cancel')),
|
||||||
default=0,
|
default=0,
|
||||||
)
|
)
|
||||||
return MfxDialog.initKw(self, kw)
|
return MfxDialog.initKw(self, kw)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ my %skip =
|
||||||
|
|
||||||
# my $cmd = shell_quote( 'flake8', '.' );
|
# my $cmd = shell_quote( 'flake8', '.' );
|
||||||
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
|
# TEST
|
||||||
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
||||||
|
|
Loading…
Add table
Reference in a new issue