mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake8
This commit is contained in:
parent
4c3e99d9a6
commit
2d3dece823
3 changed files with 22 additions and 20 deletions
|
@ -27,7 +27,7 @@ __all__ = ['PlayerOptionsDialog']
|
||||||
import Tkinter
|
import Tkinter
|
||||||
|
|
||||||
# PySol imports
|
# PySol imports
|
||||||
from pysollib.mygettext import _, n_
|
from pysollib.mygettext import _
|
||||||
from pysollib.mfxutil import KwStruct, Struct
|
from pysollib.mfxutil import KwStruct, Struct
|
||||||
|
|
||||||
# Toolkit imports
|
# Toolkit imports
|
||||||
|
@ -62,7 +62,7 @@ class SelectUserNameDialog(MfxDialog):
|
||||||
focus = self.createButtons(bottom_frame, kw)
|
focus = self.createButtons(bottom_frame, kw)
|
||||||
self.mainloop(focus, kw.timeout)
|
self.mainloop(focus, kw.timeout)
|
||||||
|
|
||||||
#if listbox.curselection():
|
# if listbox.curselection():
|
||||||
# self.username = listbox.get(listbox.curselection())
|
# self.username = listbox.get(listbox.curselection())
|
||||||
|
|
||||||
def updateUserName(self, *args):
|
def updateUserName(self, *args):
|
||||||
|
@ -79,7 +79,6 @@ class SelectUserNameDialog(MfxDialog):
|
||||||
return MfxDialog.initKw(self, kw)
|
return MfxDialog.initKw(self, kw)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PlayerOptionsDialog(MfxDialog):
|
class PlayerOptionsDialog(MfxDialog):
|
||||||
def __init__(self, parent, title, app, **kw):
|
def __init__(self, parent, title, app, **kw):
|
||||||
kw = self.initKw(kw)
|
kw = self.initKw(kw)
|
||||||
|
@ -98,7 +97,7 @@ class PlayerOptionsDialog(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)
|
||||||
widget = Tkinter.Label(frame, text=_("\nPlease enter your name"),
|
widget = Tkinter.Label(frame, text=_("\nPlease enter your name"),
|
||||||
#justify='left', anchor='w',
|
# justify='left', anchor='w',
|
||||||
takefocus=0)
|
takefocus=0)
|
||||||
widget.grid(row=0, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
|
widget.grid(row=0, column=0, columnspan=2, sticky='ew', padx=0, pady=5)
|
||||||
w = kw.get("e_width", 30) # width in characters
|
w = kw.get("e_width", 30) # width in characters
|
||||||
|
@ -115,9 +114,9 @@ class PlayerOptionsDialog(MfxDialog):
|
||||||
anchor='w',
|
anchor='w',
|
||||||
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 = Tkinter.Checkbutton(frame, variable=self.win_animation_var,
|
# widget = Tkinter.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()
|
||||||
|
@ -164,10 +163,10 @@ def playeroptionsdialog_main(args):
|
||||||
wm_withdraw(tk)
|
wm_withdraw(tk)
|
||||||
tk.update()
|
tk.update()
|
||||||
d = PlayerOptionsDialog(tk, "Player options", app)
|
d = PlayerOptionsDialog(tk, "Player options", app)
|
||||||
print d.status, d.button, ":", d.player, d.update_stats
|
print(d.status, d.button, ":", d.player, d.update_stats)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
import sys
|
import sys
|
||||||
sys.exit(playeroptionsdialog_main(sys.argv))
|
sys.exit(playeroptionsdialog_main(sys.argv))
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class PysolProgressBar:
|
||||||
self.frame = Tkinter.Frame(self.top, relief='flat', bd=0,
|
self.frame = Tkinter.Frame(self.top, relief='flat', bd=0,
|
||||||
takefocus=0)
|
takefocus=0)
|
||||||
self.cframe = Tkinter.Frame(self.frame, relief='sunken', bd=1,
|
self.cframe = Tkinter.Frame(self.frame, relief='sunken', bd=1,
|
||||||
takefocus=0)
|
takefocus=0)
|
||||||
self.canvas = Tkinter.Canvas(self.cframe, width=width, height=height,
|
self.canvas = Tkinter.Canvas(self.cframe, width=width, height=height,
|
||||||
takefocus=0, bd=0, highlightthickness=0)
|
takefocus=0, bd=0, highlightthickness=0)
|
||||||
self.scale = self.canvas.create_rectangle(-10, -10, 0, height,
|
self.scale = self.canvas.create_rectangle(-10, -10, 0, height,
|
||||||
|
@ -58,10 +58,12 @@ class PysolProgressBar:
|
||||||
self.cframe.grid_configure(column=0, row=0, sticky="ew")
|
self.cframe.grid_configure(column=0, row=0, sticky="ew")
|
||||||
if images:
|
if images:
|
||||||
self.f1 = Tkinter.Label(self.frame, image=images[0])
|
self.f1 = Tkinter.Label(self.frame, image=images[0])
|
||||||
self.f1.grid_configure(column=0, row=0, sticky="ew", ipadx=8, ipady=4)
|
self.f1.grid_configure(
|
||||||
|
column=0, row=0, sticky="ew", ipadx=8, ipady=4)
|
||||||
self.cframe.grid_configure(column=1, row=0, sticky="ew", padx=8)
|
self.cframe.grid_configure(column=1, row=0, sticky="ew", padx=8)
|
||||||
self.f2 = Tkinter.Label(self.frame, image=images[1])
|
self.f2 = Tkinter.Label(self.frame, image=images[1])
|
||||||
self.f2.grid_configure(column=2, row=0, sticky="ew", ipadx=8, ipady=4)
|
self.f2.grid_configure(
|
||||||
|
column=2, row=0, sticky="ew", ipadx=8, ipady=4)
|
||||||
self.top.config(cursor="watch")
|
self.top.config(cursor="watch")
|
||||||
self.pack()
|
self.pack()
|
||||||
if 1:
|
if 1:
|
||||||
|
@ -91,8 +93,8 @@ 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 /= self.norm
|
||||||
if self.top is None: # already destroyed
|
if self.top is None: # already destroyed
|
||||||
return
|
return
|
||||||
if percent is None:
|
if percent is None:
|
||||||
|
@ -105,7 +107,7 @@ class PysolProgressBar:
|
||||||
c = self.canvas
|
c = self.canvas
|
||||||
width, height = c.winfo_reqwidth(), c.winfo_reqheight()
|
width, height = c.winfo_reqwidth(), c.winfo_reqheight()
|
||||||
c.coords(self.scale, -10, -10,
|
c.coords(self.scale, -10, -10,
|
||||||
(self.percent * width ) / 100.0, height)
|
(self.percent * width) / 100.0, height)
|
||||||
if self.text >= 0:
|
if self.text >= 0:
|
||||||
c.coords(self.text, width/2, height/2)
|
c.coords(self.text, width/2, height/2)
|
||||||
c.itemconfig(self.text, text="%d %%" % int(round(self.percent)))
|
c.itemconfig(self.text, text="%d %%" % int(round(self.percent)))
|
||||||
|
@ -120,7 +122,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)
|
||||||
|
|
||||||
|
@ -131,16 +134,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))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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-m]*.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-p]*.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