mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake8
This commit is contained in:
parent
e3c557b1d0
commit
69fd04c6dc
2 changed files with 19 additions and 18 deletions
|
@ -63,10 +63,12 @@ class MfxTreeBaseNode:
|
||||||
def draw(self, x, y, lastx=None, lasty=None):
|
def draw(self, x, y, lastx=None, lasty=None):
|
||||||
canvas, style = self.tree.canvas, self.tree.style
|
canvas, style = self.tree.canvas, self.tree.style
|
||||||
topleftx = x + style.distx
|
topleftx = x + style.distx
|
||||||
toplefty = y - style.height / 2 #+++
|
toplefty = y - style.height / 2 # +++
|
||||||
# draw the horizontal line
|
# draw the horizontal line
|
||||||
if lastx is not None:
|
if lastx is not None:
|
||||||
canvas.create_line(x, y, topleftx, y, stipple=style.linestyle, fill=style.linecolor)
|
canvas.create_line(
|
||||||
|
x, y, topleftx, y, stipple=style.linestyle,
|
||||||
|
fill=style.linecolor)
|
||||||
# draw myself - ugly, ugly...
|
# draw myself - ugly, ugly...
|
||||||
self.selected = 0
|
self.selected = 0
|
||||||
self.symbol_id = -1
|
self.symbol_id = -1
|
||||||
|
@ -93,7 +95,7 @@ class MfxTreeBaseNode:
|
||||||
# note: I don't use Label + canvas.create_window here
|
# note: I don't use Label + canvas.create_window here
|
||||||
# because it doesn't propagate events to the canvas
|
# because it doesn't propagate events to the canvas
|
||||||
# and has some other re-display annoyances
|
# and has some other re-display annoyances
|
||||||
##print 'style.font:', style.font
|
# print 'style.font:', style.font
|
||||||
self.text_id = canvas.create_text(x+1, y, text=self.text,
|
self.text_id = canvas.create_text(x+1, y, text=self.text,
|
||||||
anchor="w", justify="left",
|
anchor="w", justify="left",
|
||||||
font=style.font,
|
font=style.font,
|
||||||
|
@ -108,8 +110,9 @@ class MfxTreeBaseNode:
|
||||||
pass
|
pass
|
||||||
elif self.selected:
|
elif self.selected:
|
||||||
b = canvas.bbox(self.text_id)
|
b = canvas.bbox(self.text_id)
|
||||||
self.textrect_id = canvas.create_rectangle(b[0]-1, b[1]-1, b[2]+1, b[3]+1,
|
self.textrect_id = canvas.create_rectangle(
|
||||||
fill=bg, outline="")
|
b[0]-1, b[1]-1, b[2]+1, b[3]+1,
|
||||||
|
fill=bg, outline="")
|
||||||
canvas.tag_lower(self.textrect_id, self.text_id)
|
canvas.tag_lower(self.textrect_id, self.text_id)
|
||||||
self.tree.nodes[self.textrect_id] = self
|
self.tree.nodes[self.textrect_id] = self
|
||||||
|
|
||||||
|
@ -179,7 +182,6 @@ class MfxTreeNode(MfxTreeBaseNode):
|
||||||
fill=style.linecolor)
|
fill=style.linecolor)
|
||||||
return ny
|
return ny
|
||||||
|
|
||||||
|
|
||||||
def draw(self, x, y, ilastx=None, ilasty=None):
|
def draw(self, x, y, ilastx=None, ilasty=None):
|
||||||
# draw myself
|
# draw myself
|
||||||
lx, ly, nx, ny = MfxTreeBaseNode.draw(self, x, y, ilastx, ilasty)
|
lx, ly, nx, ny = MfxTreeBaseNode.draw(self, x, y, ilastx, ilasty)
|
||||||
|
@ -188,7 +190,7 @@ class MfxTreeNode(MfxTreeBaseNode):
|
||||||
childx = nx + style.distx + style.width / 2
|
childx = nx + style.distx + style.width / 2
|
||||||
childy = ny
|
childy = ny
|
||||||
clastx = nx + style.distx + style.width / 2
|
clastx = nx + style.distx + style.width / 2
|
||||||
clasty = ly + style.height /2
|
clasty = ly + style.height / 2
|
||||||
ny = self.drawChildren(childx, childy, clastx, clasty)
|
ny = self.drawChildren(childx, childy, clastx, clasty)
|
||||||
return lx, ly, x, ny
|
return lx, ly, x, ny
|
||||||
|
|
||||||
|
@ -239,13 +241,14 @@ class MfxTreeInCanvas(MfxScrolledCanvas):
|
||||||
self.keys = {}
|
self.keys = {}
|
||||||
#
|
#
|
||||||
self.style = self.Style()
|
self.style = self.Style()
|
||||||
##self.style.text_normal_fg = self.canvas.cget("insertbackground")
|
# self.style.text_normal_fg = self.canvas.cget("insertbackground")
|
||||||
self.style.text_normal_fg = self.canvas.option_get('foreground', '') or self.canvas.cget("insertbackground")
|
self.style.text_normal_fg = self.canvas.option_get('foreground', '') \
|
||||||
|
or self.canvas.cget("insertbackground")
|
||||||
self.style.text_normal_bg = bg
|
self.style.text_normal_bg = bg
|
||||||
#
|
#
|
||||||
bind(self.canvas, "<ButtonPress-1>", self.singleClick)
|
bind(self.canvas, "<ButtonPress-1>", self.singleClick)
|
||||||
bind(self.canvas, "<Double-Button-1>", self.doubleClick)
|
bind(self.canvas, "<Double-Button-1>", self.doubleClick)
|
||||||
##bind(self.canvas, "<ButtonRelease-1>", xxx)
|
# bind(self.canvas, "<ButtonRelease-1>", xxx)
|
||||||
self.pack(fill='both', expand=True)
|
self.pack(fill='both', expand=True)
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
|
@ -281,8 +284,8 @@ class MfxTreeInCanvas(MfxScrolledCanvas):
|
||||||
raise
|
raise
|
||||||
# set scroll region
|
# set scroll region
|
||||||
bbox = self.canvas.bbox("all")
|
bbox = self.canvas.bbox("all")
|
||||||
##self.canvas.config(scrollregion=bbox)
|
# self.canvas.config(scrollregion=bbox)
|
||||||
self.canvas.config(scrollregion=(0,0,bbox[2],bbox[3]))
|
self.canvas.config(scrollregion=(0, 0, bbox[2], bbox[3]))
|
||||||
self.canvas.config(yscrollincrement=self.style.disty)
|
self.canvas.config(yscrollincrement=self.style.disty)
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
|
@ -372,7 +375,7 @@ class DirectoryBrowser(MfxTreeInCanvas):
|
||||||
return node.subnodes
|
return node.subnodes
|
||||||
#
|
#
|
||||||
dir = node.key
|
dir = node.key
|
||||||
print "Getting %s" % dir
|
print("Getting %s" % dir)
|
||||||
try:
|
try:
|
||||||
filenames = os.listdir(dir)
|
filenames = os.listdir(dir)
|
||||||
filenames.sort()
|
filenames.sort()
|
||||||
|
@ -381,14 +384,14 @@ class DirectoryBrowser(MfxTreeInCanvas):
|
||||||
contents = []
|
contents = []
|
||||||
for filename in filenames:
|
for filename in filenames:
|
||||||
self.addNode(contents, node, os.path.join(dir, filename), filename)
|
self.addNode(contents, node, os.path.join(dir, filename), filename)
|
||||||
##print "gotten"
|
# print "gotten"
|
||||||
return contents
|
return contents
|
||||||
|
|
||||||
def singleClick(self, event=None):
|
def singleClick(self, event=None):
|
||||||
node = self.findNode(event)
|
node = self.findNode(event)
|
||||||
if not node:
|
if not node:
|
||||||
return
|
return
|
||||||
print "Clicked node %s %s" % (node.text, node.key)
|
print("Clicked node %s %s" % (node.text, node.key))
|
||||||
if isinstance(node, MfxTreeLeaf):
|
if isinstance(node, MfxTreeLeaf):
|
||||||
self.updateSelection(key=node.key)
|
self.updateSelection(key=node.key)
|
||||||
elif isinstance(node, MfxTreeNode):
|
elif isinstance(node, MfxTreeNode):
|
||||||
|
@ -404,5 +407,3 @@ if __name__ == "__main__":
|
||||||
else:
|
else:
|
||||||
app = DirectoryBrowser(tk, ("/", "/home"))
|
app = DirectoryBrowser(tk, ("/", "/home"))
|
||||||
tk.mainloop()
|
tk.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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-sw],ta,ti,to,tkhtml,tkstats}*.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-sw],ta,ti,to,tkhtml,tkstats,tktree}*.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