mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake8
This commit is contained in:
parent
a4bea50ad1
commit
7a3ceb97bb
3 changed files with 19 additions and 20 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- mode: python; coding: utf-8; -*-
|
# -*- mode: python; coding: utf-8; -*-
|
||||||
# ---------------------------------------------------------------------------##
|
# ---------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
|
# Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer
|
||||||
# Copyright (C) 2003 Mt. Hood Playing Card Co.
|
# Copyright (C) 2003 Mt. Hood Playing Card Co.
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
# ---------------------------------------------------------------------------##
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
__all__ = ['FontsDialog']
|
__all__ = ['FontsDialog']
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ import tkFont
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.mfxutil import KwStruct
|
from pysollib.mfxutil import KwStruct
|
||||||
from pysollib.mygettext import _, n_
|
from pysollib.mygettext import _
|
||||||
|
|
||||||
# Toolkit imports
|
# Toolkit imports
|
||||||
from tkwidget import MfxDialog
|
from tkwidget import MfxDialog
|
||||||
|
@ -44,14 +44,14 @@ from tkwidget import PysolScale
|
||||||
|
|
||||||
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'
|
||||||
|
|
||||||
|
@ -74,7 +74,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.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()
|
||||||
|
@ -85,7 +85,7 @@ class FontChooserDialog(MfxDialog):
|
||||||
frame = ttk.Frame(top_frame)
|
frame = ttk.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 = 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'))
|
||||||
|
@ -93,10 +93,10 @@ class FontChooserDialog(MfxDialog):
|
||||||
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)
|
||||||
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 = ttk.Checkbutton(frame, text=_('Bold'),
|
cb1 = ttk.Checkbutton(frame, text=_('Bold'),
|
||||||
command=self.fontupdate,
|
command=self.fontupdate,
|
||||||
variable=self.weight_var)
|
variable=self.weight_var)
|
||||||
|
@ -151,6 +151,7 @@ class FontChooserDialog(MfxDialog):
|
||||||
# *
|
# *
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
|
|
||||||
class FontsDialog(MfxDialog):
|
class FontsDialog(MfxDialog):
|
||||||
def __init__(self, parent, title, app, **kw):
|
def __init__(self, parent, title, app, **kw):
|
||||||
kw = self.initKw(kw)
|
kw = self.initKw(kw)
|
||||||
|
@ -164,7 +165,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,7 +179,8 @@ class FontsDialog(MfxDialog):
|
||||||
ttk.Label(frame, text=title, anchor='w'
|
ttk.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 = ' '.join(
|
||||||
|
[str(i) for i in font if i not in ('roman', 'normal')])
|
||||||
elif font is None:
|
elif font is None:
|
||||||
title = 'Default'
|
title = 'Default'
|
||||||
l = ttk.Label(frame, font=font, text=title)
|
l = ttk.Label(frame, font=font, text=title)
|
||||||
|
@ -191,22 +193,17 @@ class FontsDialog(MfxDialog):
|
||||||
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 = ' '.join(
|
||||||
|
[str(i) for i in d.font if i not in ('roman', 'normal')])
|
||||||
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,5 +27,7 @@ __all__ = ['GameInfoDialog']
|
||||||
import pysollib.ui.tktile.gameinfodialog
|
import pysollib.ui.tktile.gameinfodialog
|
||||||
from pysollib.tile.basetilemfxdialog import BaseTileMfxDialog
|
from pysollib.tile.basetilemfxdialog import BaseTileMfxDialog
|
||||||
|
|
||||||
class GameInfoDialog(pysollib.ui.tktile.gameinfodialog.BaseGameInfoDialog, BaseTileMfxDialog):
|
|
||||||
|
class GameInfoDialog(pysollib.ui.tktile.gameinfodialog.BaseGameInfoDialog,
|
||||||
|
BaseTileMfxDialog):
|
||||||
True
|
True
|
||||||
|
|
|
@ -10,7 +10,7 @@ use String::ShellQuote qw/ shell_quote /;
|
||||||
|
|
||||||
# my $cmd = shell_quote( 'flake8', '.' );
|
# my $cmd = shell_quote( 'flake8', '.' );
|
||||||
my $cmd = shell_quote( 'flake8',
|
my $cmd = shell_quote( 'flake8',
|
||||||
grep { not($_ eq './pysollib/pysoltk.py') } glob('./pysollib/*.py ./pysollib/[cmp]*/*.py ./pysollib/tile/[b-e]*.py') );
|
grep { not($_ eq './pysollib/pysoltk.py') } glob('./pysollib/*.py ./pysollib/[cmp]*/*.py ./pysollib/tile/[a-g]*.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