mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake8
This commit is contained in:
parent
7a3ceb97bb
commit
85e604b912
4 changed files with 26 additions and 32 deletions
|
@ -24,27 +24,20 @@
|
||||||
__all__ = ['PysolMenubarTk']
|
__all__ = ['PysolMenubarTk']
|
||||||
|
|
||||||
# imports
|
# imports
|
||||||
import Tkinter
|
|
||||||
import ttk
|
import ttk
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.mygettext import _, n_
|
from pysollib.mygettext import _, n_
|
||||||
from pysollib.util import CARDSET
|
from pysollib.util import CARDSET
|
||||||
from pysollib.settings import WIN_SYSTEM
|
|
||||||
from pysollib.settings import SELECT_GAME_MENU
|
|
||||||
from pysollib.settings import USE_FREECELL_SOLVER
|
|
||||||
from pysollib.settings import DEBUG
|
|
||||||
from pysollib.settings import TITLE
|
from pysollib.settings import TITLE
|
||||||
from pysollib.gamedb import GI
|
|
||||||
|
|
||||||
# toolkit imports
|
# toolkit imports
|
||||||
from pysollib.ui.tktile.tkconst import EVENT_HANDLED, EVENT_PROPAGATE, CURSOR_WATCH, COMPOUNDS
|
|
||||||
from pysollib.ui.tktile.tkutil import bind, after_idle
|
|
||||||
from tkwidget import MfxMessageDialog
|
from tkwidget import MfxMessageDialog
|
||||||
from selectgame import SelectGameDialog, SelectGameDialogWithPreview
|
from selectgame import SelectGameDialog, SelectGameDialogWithPreview
|
||||||
from soundoptionsdialog import SoundOptionsDialog
|
from soundoptionsdialog import SoundOptionsDialog
|
||||||
from selecttile import SelectTileDialogWithPreview
|
from selecttile import SelectTileDialogWithPreview
|
||||||
from pysollib.ui.tktile.findcarddialog import connect_game_find_card_dialog, destroy_find_card_dialog
|
from pysollib.ui.tktile.findcarddialog import connect_game_find_card_dialog, \
|
||||||
|
destroy_find_card_dialog
|
||||||
from solverdialog import connect_game_solver_dialog
|
from solverdialog import connect_game_solver_dialog
|
||||||
|
|
||||||
from pysollib.ui.tktile.menubar import MfxMenu, PysolMenubarTkCommon
|
from pysollib.ui.tktile.menubar import MfxMenu, PysolMenubarTkCommon
|
||||||
|
@ -54,6 +47,7 @@ from pysollib.ui.tktile.menubar import MfxMenu, PysolMenubarTkCommon
|
||||||
# * - menu actions
|
# * - menu actions
|
||||||
# ************************************************************************
|
# ************************************************************************
|
||||||
|
|
||||||
|
|
||||||
class PysolMenubarTk(PysolMenubarTkCommon):
|
class PysolMenubarTk(PysolMenubarTkCommon):
|
||||||
def __init__(self, app, top, progress=None):
|
def __init__(self, app, top, progress=None):
|
||||||
PysolMenubarTkCommon.__init__(self, app, top, progress)
|
PysolMenubarTkCommon.__init__(self, app, top, progress)
|
||||||
|
@ -95,9 +89,9 @@ class PysolMenubarTk(PysolMenubarTkCommon):
|
||||||
# create the menubar
|
# create the menubar
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
def mSelectCardsetDialog(self, *event):
|
def mSelectCardsetDialog(self, *event):
|
||||||
if self._cancelDrag(break_pause=False): return
|
if self._cancelDrag(break_pause=False):
|
||||||
|
return
|
||||||
key = self.app.nextgame.cardset.index
|
key = self.app.nextgame.cardset.index
|
||||||
cs = self.app.selectCardset(_("Select ")+CARDSET, key)
|
cs = self.app.selectCardset(_("Select ")+CARDSET, key)
|
||||||
if not cs:
|
if not cs:
|
||||||
|
@ -114,12 +108,13 @@ class PysolMenubarTk(PysolMenubarTkCommon):
|
||||||
def mOptTheme(self, *event):
|
def mOptTheme(self, *event):
|
||||||
theme = self.tkopt.theme.get()
|
theme = self.tkopt.theme.get()
|
||||||
self.app.opt.tile_theme = theme
|
self.app.opt.tile_theme = theme
|
||||||
d = self._calc_MfxMessageDialog()(self.top, title=_("Change theme"),
|
self._calc_MfxMessageDialog()(
|
||||||
text=_("""\
|
self.top, title=_("Change theme"),
|
||||||
|
text=_("""\
|
||||||
This settings will take effect
|
This settings will take effect
|
||||||
the next time you restart """)+TITLE,
|
the next time you restart """)+TITLE,
|
||||||
bitmap="warning",
|
bitmap="warning",
|
||||||
default=0, strings=(_("&OK"),))
|
default=0, strings=(_("&OK"),))
|
||||||
|
|
||||||
def createThemesMenu(self, menu):
|
def createThemesMenu(self, menu):
|
||||||
submenu = MfxMenu(menu, label=n_("Set t&heme"))
|
submenu = MfxMenu(menu, label=n_("Set t&heme"))
|
||||||
|
@ -141,4 +136,3 @@ the next time you restart """)+TITLE,
|
||||||
n = t.capitalize()
|
n = t.capitalize()
|
||||||
submenu.add_radiobutton(label=n, variable=self.tkopt.theme,
|
submenu.add_radiobutton(label=n, variable=self.tkopt.theme,
|
||||||
value=t, command=self.mOptTheme)
|
value=t, command=self.mOptTheme)
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ import Tkinter
|
||||||
import ttk
|
import ttk
|
||||||
|
|
||||||
# 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
|
||||||
|
@ -72,9 +72,9 @@ class PlayerOptionsDialog(MfxDialog):
|
||||||
widget = ttk.Checkbutton(frame, variable=self.update_stats_var,
|
widget = ttk.Checkbutton(frame, variable=self.update_stats_var,
|
||||||
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 = ttk.Checkbutton(frame, variable=self.win_animation_var,
|
# widget = ttk.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)
|
||||||
#
|
#
|
||||||
self.player = self.player_var.get()
|
self.player = self.player_var.get()
|
||||||
|
@ -99,4 +99,3 @@ class PlayerOptionsDialog(MfxDialog):
|
||||||
padx=10, pady=10,
|
padx=10, pady=10,
|
||||||
)
|
)
|
||||||
return MfxDialog.initKw(self, kw)
|
return MfxDialog.initKw(self, kw)
|
||||||
|
|
||||||
|
|
|
@ -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__ = ['PysolProgressBar']
|
__all__ = ['PysolProgressBar']
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ class PysolProgressBar:
|
||||||
#
|
#
|
||||||
self.frame = ttk.Frame(self.top, relief='flat', borderwidth=0)
|
self.frame = ttk.Frame(self.top, relief='flat', borderwidth=0)
|
||||||
self.progress = ttk.Progressbar(self.frame, maximum=100, length=250)
|
self.progress = ttk.Progressbar(self.frame, maximum=100, length=250)
|
||||||
##style = ttk.Style(self.progress)
|
# style = ttk.Style(self.progress)
|
||||||
##style.configure('TProgressbar', background=color)
|
# style.configure('TProgressbar', background=color)
|
||||||
if images:
|
if images:
|
||||||
self.f1 = ttk.Label(self.frame, image=images[0])
|
self.f1 = ttk.Label(self.frame, image=images[0])
|
||||||
self.f1.pack(side='left', ipadx=8, ipady=4)
|
self.f1.pack(side='left', ipadx=8, ipady=4)
|
||||||
|
@ -83,7 +83,7 @@ class PysolProgressBar:
|
||||||
|
|
||||||
def update(self, percent=None, step=1):
|
def update(self, percent=None, step=1):
|
||||||
self.steps_sum += step
|
self.steps_sum += step
|
||||||
##print self.steps_sum
|
# print self.steps_sum
|
||||||
step = step/self.norm
|
step = step/self.norm
|
||||||
if self.top is None: # already destroyed
|
if self.top is None: # already destroyed
|
||||||
return
|
return
|
||||||
|
@ -95,7 +95,7 @@ class PysolProgressBar:
|
||||||
return
|
return
|
||||||
self.percent = min(100, max(0, self.percent))
|
self.percent = min(100, max(0, self.percent))
|
||||||
self.progress.config(value=self.percent)
|
self.progress.config(value=self.percent)
|
||||||
##self.top.update_idletasks()
|
# self.top.update_idletasks()
|
||||||
self.top.update()
|
self.top.update()
|
||||||
|
|
||||||
|
|
||||||
|
@ -107,7 +107,8 @@ class PysolProgressBar:
|
||||||
class TestProgressBar:
|
class TestProgressBar:
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
self.progress = PysolProgressBar(None, parent, title="Progress", color="#008200")
|
self.progress = PysolProgressBar(
|
||||||
|
None, parent, title="Progress", color="#008200")
|
||||||
self.progress.pack(ipadx=10, ipady=10)
|
self.progress.pack(ipadx=10, ipady=10)
|
||||||
self.progress.frame.after(1000, self.update)
|
self.progress.frame.after(1000, self.update)
|
||||||
|
|
||||||
|
@ -118,16 +119,16 @@ class TestProgressBar:
|
||||||
self.progress.update(step=1)
|
self.progress.update(step=1)
|
||||||
self.progress.frame.after(30, self.update)
|
self.progress.frame.after(30, self.update)
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
pb = TestProgressBar(tk)
|
TestProgressBar(tk)
|
||||||
tk.mainloop()
|
tk.mainloop()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
sys.exit(progressbar_main(sys.argv))
|
sys.exit(progressbar_main(sys.argv))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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/[a-g]*.py') );
|
grep { not($_ eq './pysollib/pysoltk.py') } glob('./pysollib/*.py ./pysollib/[cmp]*/*.py ./pysollib/tile/[a-p]*.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