From 85e604b912e6ab9187d99ec650f349d5a9347b0d Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Mon, 17 Apr 2017 15:01:39 +0300 Subject: [PATCH] flake8 --- pysollib/tile/menubar.py | 26 ++++++++++---------------- pysollib/tile/playeroptionsdialog.py | 9 ++++----- pysollib/tile/progressbar.py | 21 +++++++++++---------- tests/style/py-flake8.t | 2 +- 4 files changed, 26 insertions(+), 32 deletions(-) diff --git a/pysollib/tile/menubar.py b/pysollib/tile/menubar.py index 8549698f..d01bf4e4 100644 --- a/pysollib/tile/menubar.py +++ b/pysollib/tile/menubar.py @@ -24,27 +24,20 @@ __all__ = ['PysolMenubarTk'] # imports -import Tkinter import ttk # PySol imports from pysollib.mygettext import _, n_ 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.gamedb import GI # 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 selectgame import SelectGameDialog, SelectGameDialogWithPreview from soundoptionsdialog import SoundOptionsDialog 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 pysollib.ui.tktile.menubar import MfxMenu, PysolMenubarTkCommon @@ -54,6 +47,7 @@ from pysollib.ui.tktile.menubar import MfxMenu, PysolMenubarTkCommon # * - menu actions # ************************************************************************ + class PysolMenubarTk(PysolMenubarTkCommon): def __init__(self, app, top, progress=None): PysolMenubarTkCommon.__init__(self, app, top, progress) @@ -95,9 +89,9 @@ class PysolMenubarTk(PysolMenubarTkCommon): # create the menubar # - def mSelectCardsetDialog(self, *event): - if self._cancelDrag(break_pause=False): return + if self._cancelDrag(break_pause=False): + return key = self.app.nextgame.cardset.index cs = self.app.selectCardset(_("Select ")+CARDSET, key) if not cs: @@ -114,12 +108,13 @@ class PysolMenubarTk(PysolMenubarTkCommon): def mOptTheme(self, *event): theme = self.tkopt.theme.get() self.app.opt.tile_theme = theme - d = self._calc_MfxMessageDialog()(self.top, title=_("Change theme"), - text=_("""\ + self._calc_MfxMessageDialog()( + self.top, title=_("Change theme"), + text=_("""\ This settings will take effect the next time you restart """)+TITLE, - bitmap="warning", - default=0, strings=(_("&OK"),)) + bitmap="warning", + default=0, strings=(_("&OK"),)) def createThemesMenu(self, menu): submenu = MfxMenu(menu, label=n_("Set t&heme")) @@ -141,4 +136,3 @@ the next time you restart """)+TITLE, n = t.capitalize() submenu.add_radiobutton(label=n, variable=self.tkopt.theme, value=t, command=self.mOptTheme) - diff --git a/pysollib/tile/playeroptionsdialog.py b/pysollib/tile/playeroptionsdialog.py index 49b6d2d2..cd4b5463 100644 --- a/pysollib/tile/playeroptionsdialog.py +++ b/pysollib/tile/playeroptionsdialog.py @@ -28,7 +28,7 @@ import Tkinter import ttk # PySol imports -from pysollib.mygettext import _, n_ +from pysollib.mygettext import _ from pysollib.mfxutil import KwStruct # Toolkit imports @@ -72,9 +72,9 @@ class PlayerOptionsDialog(MfxDialog): widget = ttk.Checkbutton(frame, variable=self.update_stats_var, text=_("Update statistics and logs")) widget.grid(row=3, column=0, columnspan=2, sticky='ew', padx=0, pady=5) -### widget = ttk.Checkbutton(frame, variable=self.win_animation_var, -### text="Win animation") -### widget.pack(side='top', padx=kw.padx, pady=kw.pady) + # widget = ttk.Checkbutton(frame, variable=self.win_animation_var, + # text="Win animation") + # widget.pack(side='top', padx=kw.padx, pady=kw.pady) frame.columnconfigure(0, weight=1) # self.player = self.player_var.get() @@ -99,4 +99,3 @@ class PlayerOptionsDialog(MfxDialog): padx=10, pady=10, ) return MfxDialog.initKw(self, kw) - diff --git a/pysollib/tile/progressbar.py b/pysollib/tile/progressbar.py index af52dc21..7fe1a963 100644 --- a/pysollib/tile/progressbar.py +++ b/pysollib/tile/progressbar.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- mode: python; coding: utf-8; -*- -# ---------------------------------------------------------------------------## +# --------------------------------------------------------------------------- # # Copyright (C) 1998-2003 Markus Franz Xaver Johannes Oberhumer # Copyright (C) 2003 Mt. Hood Playing Card Co. @@ -19,7 +19,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -# ---------------------------------------------------------------------------## +# --------------------------------------------------------------------------- __all__ = ['PysolProgressBar'] @@ -49,8 +49,8 @@ class PysolProgressBar: # self.frame = ttk.Frame(self.top, relief='flat', borderwidth=0) self.progress = ttk.Progressbar(self.frame, maximum=100, length=250) - ##style = ttk.Style(self.progress) - ##style.configure('TProgressbar', background=color) + # style = ttk.Style(self.progress) + # style.configure('TProgressbar', background=color) if images: self.f1 = ttk.Label(self.frame, image=images[0]) self.f1.pack(side='left', ipadx=8, ipady=4) @@ -83,7 +83,7 @@ class PysolProgressBar: def update(self, percent=None, step=1): self.steps_sum += step - ##print self.steps_sum + # print self.steps_sum step = step/self.norm if self.top is None: # already destroyed return @@ -95,7 +95,7 @@ class PysolProgressBar: return self.percent = min(100, max(0, self.percent)) self.progress.config(value=self.percent) - ##self.top.update_idletasks() + # self.top.update_idletasks() self.top.update() @@ -107,7 +107,8 @@ class PysolProgressBar: class TestProgressBar: def __init__(self, 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.frame.after(1000, self.update) @@ -118,16 +119,16 @@ class TestProgressBar: self.progress.update(step=1) self.progress.frame.after(30, self.update) + def progressbar_main(args): from pysollib.ui.tktile.tkutil import wm_withdraw tk = Tkinter.Tk() wm_withdraw(tk) - pb = TestProgressBar(tk) + TestProgressBar(tk) tk.mainloop() return 0 + if __name__ == "__main__": import sys sys.exit(progressbar_main(sys.argv)) - - diff --git a/tests/style/py-flake8.t b/tests/style/py-flake8.t index 1b16e3a1..cc23a137 100644 --- a/tests/style/py-flake8.t +++ b/tests/style/py-flake8.t @@ -10,7 +10,7 @@ use String::ShellQuote qw/ shell_quote /; # 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 eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );