mirror of
https://github.com/shlomif/PySolFC.git
synced 2025-04-05 00:02:29 -04:00
flake8
This commit is contained in:
parent
c65a948357
commit
899dfe677f
4 changed files with 89 additions and 96 deletions
|
@ -24,9 +24,9 @@
|
|||
__all__ = ['TimeoutsDialog']
|
||||
|
||||
# imports
|
||||
## import os, sys
|
||||
from pysollib.mygettext import _, n_
|
||||
import gtk, gobject, pango
|
||||
# import os, sys
|
||||
from pysollib.mygettext import _
|
||||
import gtk
|
||||
import gtk.glade
|
||||
|
||||
|
||||
|
@ -57,6 +57,7 @@ class TimeoutsDialog:
|
|||
sc = self.widgets_tree.get_widget(n+'_scale')
|
||||
sp.set_value(sc.get_value())
|
||||
dic[n+'_scale_value_changed'] = callback
|
||||
|
||||
def callback(w, n=n):
|
||||
sp = self.widgets_tree.get_widget(n+'_spinbutton')
|
||||
sc = self.widgets_tree.get_widget(n+'_scale')
|
||||
|
@ -97,7 +98,6 @@ class TimeoutsDialog:
|
|||
'label28',
|
||||
'label29',
|
||||
'label30',
|
||||
):
|
||||
):
|
||||
w = self.widgets_tree.get_widget(n)
|
||||
w.set_text(_(w.get_text()))
|
||||
|
||||
|
|
|
@ -41,18 +41,18 @@
|
|||
|
||||
|
||||
# imports
|
||||
import os, sys, types
|
||||
|
||||
import gobject, gtk
|
||||
gdk = gtk.gdk
|
||||
import gobject
|
||||
import gtk
|
||||
try:
|
||||
import gnomecanvas
|
||||
except ImportError:
|
||||
import gnome.canvas as gnomecanvas
|
||||
|
||||
# toolkit imports
|
||||
from tkutil import anchor_tk2gtk, loadImage, bind, create_pango_font_desc
|
||||
from tkutil import anchor_tk2gtk, bind, create_pango_font_desc
|
||||
|
||||
gdk = gtk.gdk
|
||||
|
||||
# ************************************************************************
|
||||
# * canvas items
|
||||
|
@ -64,6 +64,7 @@ from tkutil import anchor_tk2gtk, loadImage, bind, create_pango_font_desc
|
|||
# * classes for then ?
|
||||
# ************************************************************************
|
||||
|
||||
|
||||
class _CanvasItem:
|
||||
|
||||
def __init__(self, canvas):
|
||||
|
@ -74,24 +75,24 @@ class _CanvasItem:
|
|||
self._group = None
|
||||
|
||||
def addtag(self, group):
|
||||
##print self, 'addtag'
|
||||
##~ assert isinstance(group._item, CanvasGroup)
|
||||
# print self, 'addtag'
|
||||
# ~ assert isinstance(group._item, CanvasGroup)
|
||||
self._item.reparent(group._item)
|
||||
if self._group == group:
|
||||
print 'addtag: new_group == old_group'
|
||||
print('addtag: new_group == old_group')
|
||||
self._group = group
|
||||
|
||||
def dtag(self, group):
|
||||
##print self, 'dtag'
|
||||
##~ assert isinstance(group._item, CanvasGroup)
|
||||
##self._item.reparent(self.canvas.root())
|
||||
# print self, 'dtag'
|
||||
# ~ assert isinstance(group._item, CanvasGroup)
|
||||
# self._item.reparent(self.canvas.root())
|
||||
pass
|
||||
|
||||
def bind(self, sequence, func, add=None):
|
||||
bind(self._item, sequence, func, add)
|
||||
|
||||
def bbox(self):
|
||||
## FIXME
|
||||
# FIXME
|
||||
return (0, 0, 0, 0)
|
||||
|
||||
def delete(self):
|
||||
|
@ -100,25 +101,25 @@ class _CanvasItem:
|
|||
self._item = None
|
||||
|
||||
def lower(self, positions=None):
|
||||
print 'lower', self, positions
|
||||
return # don't need?
|
||||
## if positions is None:
|
||||
## pass
|
||||
## ##self._item.lower_to_bottom()
|
||||
## ##self._item.get_property('parent').lower_to_bottom()
|
||||
## else:
|
||||
## print self, positions
|
||||
## self._item.lower(positions)
|
||||
print('lower', self, positions)
|
||||
return # don't need?
|
||||
# if positions is None:
|
||||
# pass
|
||||
# ##self._item.lower_to_bottom()
|
||||
# ##self._item.get_property('parent').lower_to_bottom()
|
||||
# else:
|
||||
# print self, positions
|
||||
# self._item.lower(positions)
|
||||
|
||||
def tkraise(self, positions=None):
|
||||
##print 'tkraise', positions
|
||||
# print 'tkraise', positions
|
||||
if positions is None:
|
||||
self._item.raise_to_top()
|
||||
self._item.get_property('parent').raise_to_top()
|
||||
else:
|
||||
#print self, 'tkraise', positions
|
||||
#self._item.raise_to_top()
|
||||
self._item.raise_to_top() #positions)
|
||||
# print self, 'tkraise', positions
|
||||
# self._item.raise_to_top()
|
||||
self._item.raise_to_top() # positions)
|
||||
|
||||
def move(self, x, y):
|
||||
self._item.move(x, y)
|
||||
|
@ -132,17 +133,17 @@ class _CanvasItem:
|
|||
if self._item:
|
||||
self._item.show()
|
||||
self._is_hidden = False
|
||||
|
||||
def hide(self):
|
||||
if self._item:
|
||||
self._item.hide()
|
||||
self._is_hidden = True
|
||||
|
||||
def connect(self, signal, func, args):
|
||||
#print '_CanvasItem.connect:', self, signal
|
||||
# print '_CanvasItem.connect:', self, signal
|
||||
self._item.connect('event', func, args)
|
||||
|
||||
|
||||
|
||||
class MfxCanvasGroup(_CanvasItem):
|
||||
def __init__(self, canvas):
|
||||
_CanvasItem.__init__(self, canvas)
|
||||
|
@ -169,7 +170,7 @@ class MfxCanvasImage(_CanvasItem):
|
|||
self._item.show()
|
||||
|
||||
def config(self, image):
|
||||
##~ assert isinstance(image.im, GdkImlib.Image)
|
||||
# ~ assert isinstance(image.im, GdkImlib.Image)
|
||||
self._item.set(pixbuf=image.pixbuf)
|
||||
|
||||
|
||||
|
@ -209,9 +210,12 @@ class MfxCanvasRectangle(_CanvasItem):
|
|||
_CanvasItem.__init__(self, canvas)
|
||||
self._x, self._y = x1, y1
|
||||
kw = {'x1': x1, 'x2': x2, 'y1': y1, 'y2': y2}
|
||||
if width: kw['width_pixels'] = width
|
||||
if fill: kw['fill_color'] = fill
|
||||
if outline: kw['outline_color'] = outline
|
||||
if width:
|
||||
kw['width_pixels'] = width
|
||||
if fill:
|
||||
kw['fill_color'] = fill
|
||||
if outline:
|
||||
kw['outline_color'] = outline
|
||||
if group:
|
||||
self._group = group
|
||||
group = group._item
|
||||
|
@ -243,7 +247,7 @@ class MfxCanvasText(_CanvasItem):
|
|||
kw['fill'] = canvas._text_color
|
||||
for k, v in kw.items():
|
||||
self[k] = v
|
||||
##~ self.text_format = None
|
||||
# ~ self.text_format = None
|
||||
canvas._text_items.append(self)
|
||||
self._item.show()
|
||||
|
||||
|
@ -251,13 +255,13 @@ class MfxCanvasText(_CanvasItem):
|
|||
if key == 'fill':
|
||||
self._item.set(fill_color=value)
|
||||
elif key == 'font':
|
||||
##print 'set font:', value
|
||||
# print 'set font:', value
|
||||
font_desc = create_pango_font_desc(value)
|
||||
self._item.set(font_desc=font_desc)
|
||||
elif key == 'text':
|
||||
self._item.set(text=value)
|
||||
else:
|
||||
raise AttributeError, key
|
||||
raise AttributeError(key)
|
||||
|
||||
def config(self, **kw):
|
||||
for k, v in kw.items():
|
||||
|
@ -267,7 +271,7 @@ class MfxCanvasText(_CanvasItem):
|
|||
if key == 'text':
|
||||
return self._item.get_property('text')
|
||||
else:
|
||||
raise AttributeError, key
|
||||
raise AttributeError(key)
|
||||
cget = __getitem__
|
||||
|
||||
|
||||
|
@ -304,43 +308,43 @@ class MfxCanvas(gnomecanvas.Canvas):
|
|||
self.xmargin, self.ymargin = 0, 0
|
||||
|
||||
self.connect('size-allocate', self._sizeAllocate)
|
||||
##self.connect('destroy', self.destroyEvent)
|
||||
|
||||
# self.connect('destroy', self.destroyEvent)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
self.__dict__[name] = value
|
||||
|
||||
def _sizeAllocate(self, w, rect):
|
||||
##print '_sizeAllocate', rect.x, rect.y, rect.width, rect.height
|
||||
# print '_sizeAllocate', rect.x, rect.y, rect.width, rect.height
|
||||
if self._width > 0:
|
||||
w = self._width
|
||||
h = min(self._height, rect.height)
|
||||
self.set_scroll_region(0,0,w,h)
|
||||
self.set_scroll_region(0, 0, w, h)
|
||||
if self._tile and self._tile.filename:
|
||||
self._setTile()
|
||||
|
||||
def bind(self, sequence=None, func=None, add=None):
|
||||
assert add is None
|
||||
# FIXME
|
||||
print 'TkCanvas bind:', sequence
|
||||
print('TkCanvas bind:', sequence)
|
||||
return
|
||||
|
||||
def cget(self, attr):
|
||||
if attr == 'cursor':
|
||||
# FIXME
|
||||
return gdk.LEFT_PTR
|
||||
return self.get_window().get_cursor(v)
|
||||
# return self.get_window().get_cursor(v)
|
||||
elif attr == 'width':
|
||||
return self.get_size()[0]
|
||||
elif attr == 'height':
|
||||
return self.get_size()[1]
|
||||
print 'TkCanvas cget:', attr
|
||||
raise AttributeError, attr
|
||||
print('TkCanvas cget:', attr)
|
||||
raise AttributeError(attr)
|
||||
|
||||
def xview(self):
|
||||
w, h = self.get_size()
|
||||
dx, dy = self.world_to_window(0, 0)
|
||||
return -float(dx)/w, 1.0
|
||||
|
||||
def yview(self):
|
||||
w, h = self.get_size()
|
||||
dx, dy = self.world_to_window(0, 0)
|
||||
|
@ -348,6 +352,7 @@ class MfxCanvas(gnomecanvas.Canvas):
|
|||
|
||||
def winfo_width(self):
|
||||
return self.get_size()[0]
|
||||
|
||||
def winfo_height(self):
|
||||
return self.get_size()[1]
|
||||
|
||||
|
@ -367,8 +372,8 @@ class MfxCanvas(gnomecanvas.Canvas):
|
|||
elif k == 'width':
|
||||
width = v
|
||||
else:
|
||||
print 'TkCanvas', k, v
|
||||
raise AttributeError, k
|
||||
print('TkCanvas', k, v)
|
||||
raise AttributeError(k)
|
||||
if height > 0 and width > 0:
|
||||
self.set_size_request(width, height)
|
||||
|
||||
|
@ -380,7 +385,7 @@ class MfxCanvas(gnomecanvas.Canvas):
|
|||
for i in self._all_items:
|
||||
if i._item:
|
||||
i._item.destroy()
|
||||
##i._item = None
|
||||
# i._item = None
|
||||
self._all_items = []
|
||||
|
||||
def hideAllItems(self):
|
||||
|
@ -398,8 +403,8 @@ class MfxCanvas(gnomecanvas.Canvas):
|
|||
# PySol extension
|
||||
def findCard(self, stack, event):
|
||||
# FIXME
|
||||
##w = self.get_item_at(event.x, event.y)
|
||||
##print w
|
||||
# w = self.get_item_at(event.x, event.y)
|
||||
# print w
|
||||
return stack._findCardXY(event.x, event.y)
|
||||
|
||||
def pack(self, **kw):
|
||||
|
@ -414,7 +419,7 @@ class MfxCanvas(gnomecanvas.Canvas):
|
|||
|
||||
# PySol extension - set a tiled background image
|
||||
def setTile(self, app, i, force=False):
|
||||
##print 'setTile:', i
|
||||
# print 'setTile:', i
|
||||
tile = app.tabletile_manager.get(i)
|
||||
if tile is None or tile.error:
|
||||
return False
|
||||
|
@ -427,7 +432,7 @@ class MfxCanvas(gnomecanvas.Canvas):
|
|||
assert tile.basename
|
||||
if not force:
|
||||
if (i == app.tabletile_index and
|
||||
tile.color == app.opt.colors['table']):
|
||||
tile.color == app.opt.colors['table']):
|
||||
return False
|
||||
if self._tile is tile:
|
||||
return False
|
||||
|
@ -436,7 +441,7 @@ class MfxCanvas(gnomecanvas.Canvas):
|
|||
if i == 0:
|
||||
self.setBackgroundImage(None)
|
||||
self.configure(bg=tile.color)
|
||||
##app.top.config(bg=tile.color)
|
||||
# app.top.config(bg=tile.color)
|
||||
else:
|
||||
self._setTile()
|
||||
self.configure(bg=self.top_bg)
|
||||
|
@ -445,27 +450,26 @@ class MfxCanvas(gnomecanvas.Canvas):
|
|||
|
||||
return True
|
||||
|
||||
|
||||
### FIXME: should use style.bg_pixmap ????
|
||||
# FIXME: should use style.bg_pixmap ????
|
||||
def _setTile(self):
|
||||
if not self._tile:
|
||||
return
|
||||
##print '_setTile:', self.get_size(), self._tile.filename
|
||||
# print '_setTile:', self.get_size(), self._tile.filename
|
||||
#
|
||||
filename = self._tile.filename
|
||||
stretch = self._tile.stretch
|
||||
|
||||
if not filename:
|
||||
return False
|
||||
if not self.window: # not realized yet
|
||||
if not self.window:
|
||||
# not realized yet
|
||||
self.realize()
|
||||
##return False
|
||||
# return False
|
||||
|
||||
gobject.idle_add(self.setBackgroundImage, filename, stretch)
|
||||
|
||||
|
||||
def setBackgroundImage(self, filename, stretch=False):
|
||||
##print 'setBackgroundImage', filename
|
||||
# print 'setBackgroundImage', filename
|
||||
if filename is None:
|
||||
if self.__tileimage:
|
||||
self.__tileimage.destroy()
|
||||
|
@ -504,7 +508,6 @@ class MfxCanvas(gnomecanvas.Canvas):
|
|||
w.lower_to_bottom()
|
||||
self.__tileimage = w
|
||||
|
||||
|
||||
def setTopImage(self, image, cw=0, ch=0):
|
||||
if self.__topimage:
|
||||
self.__topimage.destroy()
|
||||
|
@ -523,60 +526,54 @@ class MfxCanvas(gnomecanvas.Canvas):
|
|||
self.__topimage = self.root().add(gnomecanvas.CanvasPixbuf,
|
||||
pixbuf=pixbuf, x=x-dx, y=y-dy)
|
||||
|
||||
|
||||
def update_idletasks(self):
|
||||
##print 'MfxCanvas.update_idletasks'
|
||||
#gdk.window_process_all_updates()
|
||||
#self.show_now()
|
||||
# print 'MfxCanvas.update_idletasks'
|
||||
# gdk.window_process_all_updates()
|
||||
# self.show_now()
|
||||
# FIXME
|
||||
##if self.__topimage:
|
||||
## self.__topimage.raise_to_top()
|
||||
# if self.__topimage:
|
||||
# self.__topimage.raise_to_top()
|
||||
self.update_now()
|
||||
pass
|
||||
|
||||
def updateAll(self):
|
||||
print 'Canvas - updateAll',
|
||||
print('Canvas - updateAll')
|
||||
for i in self._all_items:
|
||||
i._item.hide()
|
||||
self.update_now()
|
||||
n = 0
|
||||
for i in self._all_items:
|
||||
i._item.show()
|
||||
print n, i
|
||||
print(n, i)
|
||||
n += 1
|
||||
self.update_now()
|
||||
#self.window.invalidate_rect((0, 0, 400, 400), True)
|
||||
|
||||
# self.window.invalidate_rect((0, 0, 400, 400), True)
|
||||
|
||||
def grid(self, *args, **kw):
|
||||
self.top.table.attach(self,
|
||||
self.top.table.attach(
|
||||
self,
|
||||
1, 2, 2, 3,
|
||||
gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL | gtk.SHRINK,
|
||||
0, 0)
|
||||
self.show()
|
||||
|
||||
|
||||
def setInitialSize(self, width, height):
|
||||
##print 'setInitialSize:', width, height
|
||||
# print 'setInitialSize:', width, height
|
||||
self._width, self._height = width, height
|
||||
self.set_size_request(width, height)
|
||||
#self.set_size(width, height)
|
||||
#self.queue_resize()
|
||||
|
||||
# self.set_size(width, height)
|
||||
# self.queue_resize()
|
||||
|
||||
def destroyEvent(self, w):
|
||||
#print 'MfxCanvas.destroyEvent'
|
||||
# print 'MfxCanvas.destroyEvent'
|
||||
self.hide()
|
||||
## self.deleteAllItems()
|
||||
## if self.__topimage:
|
||||
## self.__topimage.destroy()
|
||||
## self.__topimage = None
|
||||
|
||||
# self.deleteAllItems()
|
||||
# if self.__topimage:
|
||||
# self.__topimage.destroy()
|
||||
# self.__topimage = None
|
||||
|
||||
|
||||
class MfxScrolledCanvas(MfxCanvas):
|
||||
def __init__(self, parent, hbar=2, vbar=2, **kw):
|
||||
MfxCanvas.__init__(self, parent)
|
||||
self.canvas = self
|
||||
|
||||
|
||||
|
|
|
@ -23,22 +23,19 @@
|
|||
|
||||
|
||||
# imports
|
||||
##import sys
|
||||
# import sys
|
||||
|
||||
from gtk import gdk
|
||||
|
||||
from gtk import ANCHOR_NW, ANCHOR_SW, ANCHOR_NE, ANCHOR_SE
|
||||
|
||||
|
||||
# ************************************************************************
|
||||
# * constants
|
||||
# ************************************************************************
|
||||
|
||||
EVENT_HANDLED = 1
|
||||
EVENT_HANDLED = 1
|
||||
EVENT_PROPAGATE = 0
|
||||
|
||||
CURSOR_DRAG = gdk.HAND1
|
||||
CURSOR_WATCH = gdk.WATCH
|
||||
CURSOR_DRAG = gdk.HAND1
|
||||
CURSOR_WATCH = gdk.WATCH
|
||||
CURSOR_DOWN_ARROW = gdk.SB_DOWN_ARROW
|
||||
|
||||
TOOLBAR_BUTTONS = (
|
||||
|
@ -56,4 +53,3 @@ TOOLBAR_BUTTONS = (
|
|||
"quit",
|
||||
"player",
|
||||
)
|
||||
|
||||
|
|
|
@ -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/[cm]*/*.py ./pysollib/pysolgtk/[a-s]*.py') );
|
||||
grep { not($_ eq './pysollib/pysoltk.py') } glob('./pysollib/*.py ./pysollib/[cm]*/*.py ./pysollib/pysolgtk/{[a-s]*,t[a-i]*,tkc*}.py') );
|
||||
|
||||
# TEST
|
||||
eq_or_diff( scalar(`$cmd`), '', "flake8 is happy with the code." );
|
||||
|
|
Loading…
Add table
Reference in a new issue