pep8 compliance: E302 expected 2 blank lines
This commit is contained in:
parent
422264e81d
commit
623dcf524d
@ -10,6 +10,7 @@ import resource
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class Control(object):
|
||||
|
||||
highlighted = overridable_property('highlighted')
|
||||
@ -52,6 +53,7 @@ class Control(object):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class AttrRef(object):
|
||||
|
||||
def __init__(self, obj, attr):
|
||||
@ -66,6 +68,7 @@ class AttrRef(object):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class ItemRef(object):
|
||||
|
||||
def __init__(self, obj, item):
|
||||
@ -80,6 +83,7 @@ class ItemRef(object):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class Label(Widget):
|
||||
|
||||
text = overridable_property('text')
|
||||
@ -180,13 +184,17 @@ class Label(Widget):
|
||||
surface.blit(image, r)
|
||||
y += dy
|
||||
|
||||
|
||||
class GLLabel(Label):
|
||||
pass
|
||||
|
||||
|
||||
class SmallLabel(Label):
|
||||
"""Small text size. See theme.py"""
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class ButtonBase(Control):
|
||||
|
||||
align = 'c'
|
||||
@ -213,6 +221,7 @@ class ButtonBase(Control):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class Button(ButtonBase, Label):
|
||||
|
||||
def __init__(self, text, action=None, enable=None, **kwds):
|
||||
@ -224,6 +233,7 @@ class Button(ButtonBase, Label):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class Image(Widget):
|
||||
# image Image to display
|
||||
|
||||
@ -264,11 +274,13 @@ class Image(Widget):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class ImageButton(ButtonBase, Image):
|
||||
pass
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class ValueDisplay(Control, Label):
|
||||
|
||||
format = "%s"
|
||||
@ -294,8 +306,10 @@ class ValueDisplay(Control, Label):
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
class SmallValueDisplay(ValueDisplay): pass
|
||||
|
||||
|
||||
class ValueButton(ButtonBase, ValueDisplay):
|
||||
|
||||
align = 'c'
|
||||
@ -304,6 +318,7 @@ class ValueButton(ButtonBase, ValueDisplay):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class CheckControl(Control):
|
||||
|
||||
def mouse_down(self, e):
|
||||
@ -314,6 +329,7 @@ class CheckControl(Control):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class CheckWidget(Widget):
|
||||
|
||||
default_size = (16, 16)
|
||||
@ -341,11 +357,13 @@ class CheckWidget(Widget):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class CheckBox(CheckControl, CheckWidget):
|
||||
pass
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class RadioControl(Control):
|
||||
|
||||
setting = None
|
||||
@ -358,5 +376,6 @@ class RadioControl(Control):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class RadioButton(RadioControl, CheckWidget):
|
||||
pass
|
||||
|
@ -6,6 +6,7 @@ from controls import Label, Button
|
||||
from layout import Row, Column
|
||||
from fields import TextField
|
||||
|
||||
|
||||
class Modal(object):
|
||||
|
||||
enter_response = True
|
||||
@ -58,6 +59,7 @@ class Dialog(Modal, Widget):
|
||||
if response is not None:
|
||||
self.dismiss(response)
|
||||
|
||||
|
||||
class QuickDialog(Dialog):
|
||||
""" Dialog that closes as soon as you click outside or press a key"""
|
||||
def mouse_down(self, evt):
|
||||
@ -70,6 +72,7 @@ class QuickDialog(Dialog):
|
||||
self.dismiss()
|
||||
event.post(evt)
|
||||
|
||||
|
||||
def wrapped_label(text, wrap_width, **kwds):
|
||||
paras = text.split("\n")
|
||||
text = "\n".join([textwrap.fill(para, wrap_width) for para in paras])
|
||||
@ -84,9 +87,11 @@ def wrapped_label(text, wrap_width, **kwds):
|
||||
# box.shrink_wrap()
|
||||
# return box.present()
|
||||
|
||||
|
||||
def alert(mess, **kwds):
|
||||
ask(mess, ["OK"], **kwds)
|
||||
|
||||
|
||||
def ask(mess, responses = ["OK", "Cancel"], default = 0, cancel = -1,
|
||||
wrap_width = 60, **kwds):
|
||||
box = Dialog(**kwds)
|
||||
@ -114,6 +119,7 @@ def ask(mess, responses = ["OK", "Cancel"], default = 0, cancel = -1,
|
||||
box.shrink_wrap()
|
||||
return box.present()
|
||||
|
||||
|
||||
def input_text(prompt, width, initial = None, **kwds):
|
||||
box = Dialog(**kwds)
|
||||
d = box.margin
|
||||
|
@ -10,6 +10,7 @@ from controls import Control
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class TextEditor(Widget):
|
||||
|
||||
upper = False
|
||||
@ -179,6 +180,7 @@ class TextEditor(Widget):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class Field(Control, TextEditor):
|
||||
# type func(string) -> value
|
||||
# editing boolean
|
||||
@ -288,10 +290,12 @@ class Field(Control, TextEditor):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class TextField(Field):
|
||||
type = unicode
|
||||
_value = u""
|
||||
|
||||
|
||||
class IntField(Field):
|
||||
tooltipText = "Point here and use mousewheel to adjust"
|
||||
def type(self, i):
|
||||
@ -408,6 +412,7 @@ class TimeField(Field):
|
||||
from pygame import key
|
||||
from pygame.locals import KMOD_SHIFT
|
||||
|
||||
|
||||
class FloatField(Field):
|
||||
type = float
|
||||
_increment = 1.0
|
||||
|
@ -14,6 +14,7 @@ from albow.layout import Row, Column
|
||||
from albow.palette_view import PaletteView
|
||||
from albow.theme import ThemeProperty
|
||||
|
||||
|
||||
class DirPathView(Widget):
|
||||
|
||||
def __init__(self, width, client, **kwds):
|
||||
@ -311,6 +312,7 @@ def request_new_filename(prompt = None, suffix = None, extra_suffixes = None,
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def request_old_filename(suffixes = None, directory = None):
|
||||
dlog = FileOpenDialog(suffixes = suffixes)
|
||||
if directory:
|
||||
@ -320,6 +322,7 @@ def request_old_filename(suffixes = None, directory = None):
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
def look_for_file_or_directory(target, prompt = None, directory = None):
|
||||
dlog = LookForFileDialog(target = target, prompt = prompt)
|
||||
if directory:
|
||||
|
@ -1,6 +1,7 @@
|
||||
from pygame import Rect
|
||||
from widget import Widget
|
||||
|
||||
|
||||
class GridView(Widget):
|
||||
# cell_size (width, height) size of each cell
|
||||
#
|
||||
|
@ -1,6 +1,7 @@
|
||||
from pygame import Rect
|
||||
from albow.resource import get_image
|
||||
|
||||
|
||||
class ImageArray(object):
|
||||
|
||||
def __init__(self, image, shape):
|
||||
@ -41,6 +42,7 @@ class ImageArray(object):
|
||||
|
||||
image_array_cache = {}
|
||||
|
||||
|
||||
def get_image_array(name, shape, **kwds):
|
||||
result = image_array_cache.get(name)
|
||||
if not result:
|
||||
|
@ -5,6 +5,7 @@
|
||||
from pygame import Rect
|
||||
from widget import Widget
|
||||
|
||||
|
||||
class RowOrColumn(Widget):
|
||||
|
||||
_is_gl_container = True
|
||||
@ -63,6 +64,7 @@ class RowOrColumn(Widget):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class Row(RowOrColumn):
|
||||
|
||||
d = (1, 0)
|
||||
@ -84,6 +86,7 @@ class Row(RowOrColumn):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class Column(RowOrColumn):
|
||||
|
||||
d = (0, 1)
|
||||
@ -105,6 +108,7 @@ class Column(RowOrColumn):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class Grid(Widget):
|
||||
|
||||
_is_gl_container = True
|
||||
@ -140,6 +144,7 @@ class Grid(Widget):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class Frame(Widget):
|
||||
# margin int spacing between border and widget
|
||||
|
||||
|
@ -11,6 +11,7 @@ from theme import ThemeProperty
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class MenuItem(object):
|
||||
|
||||
keyname = ""
|
||||
@ -47,6 +48,7 @@ class MenuItem(object):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class Menu(Dialog):
|
||||
|
||||
disabled_color = ThemeProperty('disabled_color')
|
||||
|
@ -5,6 +5,7 @@
|
||||
from pygame import Rect
|
||||
from widget import Widget, overridable_property
|
||||
|
||||
|
||||
class MenuBar(Widget):
|
||||
|
||||
menus = overridable_property('menus', "List of Menu instances")
|
||||
|
@ -35,6 +35,7 @@ next_change_delay = 0
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
class PlayList(object):
|
||||
"""A collection of music filenames to be played sequentially or
|
||||
randomly. If random is true, items will be played in a random order.
|
||||
@ -64,12 +65,14 @@ class PlayList(object):
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
|
||||
|
||||
def get_music(*names, **kwds):
|
||||
"""Return the full pathname of a music file from the "music" resource
|
||||
subdirectory."""
|
||||
prefix = kwds.pop('prefix', "music")
|
||||
return resource_path(prefix, *names)
|
||||
|
||||
|
||||
def get_playlist(*names, **kwds):
|
||||
prefix = kwds.pop('prefix', "music")
|
||||
dirpath = get_music(*names, **{'prefix': prefix})
|
||||
@ -79,6 +82,7 @@ def get_playlist(*names, **kwds):
|
||||
items.sort()
|
||||
return PlayList(items, **kwds)
|
||||
|
||||
|
||||
def change_playlist(new_playlist):
|
||||
"""Fade out any currently playing music and start playing from the given
|
||||
playlist."""
|
||||
@ -93,6 +97,7 @@ def change_playlist(new_playlist):
|
||||
else:
|
||||
current_music = None
|
||||
|
||||
|
||||
def change_music(new_music, repeat = False):
|
||||
"""Fade out any currently playing music and start playing the given
|
||||
music file."""
|
||||
@ -104,16 +109,19 @@ def change_music(new_music, repeat = False):
|
||||
new_playlist = None
|
||||
change_playlist(new_playlist)
|
||||
|
||||
|
||||
def music_end():
|
||||
#print "albow.music: music_end" ###
|
||||
schedule(next_change_delay, jog_music)
|
||||
|
||||
|
||||
def jog_music():
|
||||
"""If no music is currently playing, start playing the next item
|
||||
from the current playlist."""
|
||||
if music_enabled and not music.get_busy():
|
||||
start_next_music()
|
||||
|
||||
|
||||
def start_next_music():
|
||||
"""Start playing the next item from the current playlist immediately."""
|
||||
#print "albow.music: start_next_music" ###
|
||||
@ -127,9 +135,11 @@ def start_next_music():
|
||||
next_change_delay = change_delay
|
||||
current_music = next_music
|
||||
|
||||
|
||||
def get_music_enabled():
|
||||
return music_enabled
|
||||
|
||||
|
||||
def set_music_enabled(state):
|
||||
global music_enabled
|
||||
if music_enabled != state:
|
||||
@ -157,6 +167,7 @@ from albow.controls import Label, Button, CheckBox
|
||||
from albow.layout import Row, Column, Grid
|
||||
from albow.dialogs import Dialog
|
||||
|
||||
|
||||
class EnableMusicControl(CheckBox):
|
||||
|
||||
def get_value(self):
|
||||
@ -165,6 +176,7 @@ class EnableMusicControl(CheckBox):
|
||||
def set_value(self, x):
|
||||
set_music_enabled(x)
|
||||
|
||||
|
||||
class MusicVolumeControl(Widget):
|
||||
|
||||
def __init__(self, **kwds):
|
||||
@ -185,6 +197,7 @@ class MusicVolumeControl(Widget):
|
||||
music.set_volume(x)
|
||||
self.invalidate()
|
||||
|
||||
|
||||
class MusicOptionsDialog(Dialog):
|
||||
|
||||
def __init__(self):
|
||||
@ -201,6 +214,7 @@ class MusicOptionsDialog(Dialog):
|
||||
self.add(contents)
|
||||
self.shrink_wrap()
|
||||
|
||||
|
||||
def show_music_options_dialog():
|
||||
dlog = MusicOptionsDialog()
|
||||
dlog.present()
|
||||
|
@ -8,6 +8,7 @@ from __future__ import division
|
||||
from OpenGL import GL, GLU
|
||||
from widget import Widget
|
||||
|
||||
|
||||
class GLViewport(Widget):
|
||||
|
||||
is_gl_container = True
|
||||
@ -66,6 +67,7 @@ import numpy
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
class GLOrtho(GLViewport):
|
||||
|
||||
def __init__(self, rect=None,
|
||||
@ -83,6 +85,7 @@ class GLOrtho(GLViewport):
|
||||
GL.glOrtho(self.xmin, self.xmax, self.ymin, self.ymax,
|
||||
self.near, self.far)
|
||||
|
||||
|
||||
class GLPixelOrtho(GLOrtho):
|
||||
def __init__(self, rect=None, near= -1, far=1, **kwds):
|
||||
GLOrtho.__init__(self, rect, near, far, **kwds)
|
||||
@ -94,6 +97,7 @@ class GLPixelOrtho(GLOrtho):
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
|
||||
class GLPerspective(GLViewport):
|
||||
|
||||
def __init__(self, rect=None, fovy=20,
|
||||
|
@ -6,6 +6,7 @@ from widget import Widget
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
|
||||
class Screen(Widget):
|
||||
|
||||
def __init__(self, shell, **kwds):
|
||||
|
Reference in New Issue
Block a user