Added a copy of SGC
This commit is contained in:
parent
90ff7ceba8
commit
52eb18994d
22 changed files with 3283 additions and 0 deletions
74
sgc/widgets/boxes.py
Normal file
74
sgc/widgets/boxes.py
Normal file
|
@ -0,0 +1,74 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2011-2012 Sam Bull
|
||||
|
||||
"""
|
||||
Boxes are container widgets with automatic positioning/padding of widgets.
|
||||
|
||||
"""
|
||||
|
||||
from container import Container
|
||||
|
||||
class VBox(Container):
|
||||
|
||||
"""
|
||||
VBox is a container widget which sorts widgets into a vertical
|
||||
structure.
|
||||
|
||||
If ``surf`` is not given, container will be the right size to fit all
|
||||
widgets.
|
||||
|
||||
"""
|
||||
|
||||
_settings_default = {"border": 5, "spacing": 5, "col": 0, "widgets": None}
|
||||
|
||||
def _config(self, **kwargs):
|
||||
"""
|
||||
widgets: ``list`` Contains widgets to pack into box.
|
||||
The order of widgets in the list denotes order they are packed.
|
||||
border: ``int`` Number of pixels to space around edges when ``surf``
|
||||
is not given.
|
||||
col: ``tuple`` (r,g,b) Colour for background, 0 is transparent.
|
||||
spacing: ``int`` Number of pixels to space between widgets.
|
||||
|
||||
"""
|
||||
if "spacing" in kwargs:
|
||||
self._settings["spacing"] = kwargs["spacing"]
|
||||
if "widgets" in kwargs:
|
||||
pos = 0
|
||||
for w in kwargs["widgets"]:
|
||||
w.pos = (0, pos)
|
||||
pos += w.rect.h + self._settings["spacing"]
|
||||
Container._config(self, **kwargs)
|
||||
|
||||
class HBox(Container):
|
||||
|
||||
"""
|
||||
HBox is a container widget which sorts widgets into a horizontal
|
||||
structure.
|
||||
|
||||
If ``surf`` is not given, container will be the right size to fit all
|
||||
widgets.
|
||||
|
||||
"""
|
||||
|
||||
_settings_default = {"border": 5, "spacing": 5, "col": 0, "widgets": None}
|
||||
|
||||
def _config(self, **kwargs):
|
||||
"""
|
||||
widgets: ``list`` Contains widgets to pack into box.
|
||||
The order of widgets in the list denotes order they are packed.
|
||||
border: ``int`` Number of pixels to space around edges when ``surf``
|
||||
is not given.
|
||||
col: ``tuple`` (r,g,b) Colour for background, 0 is transparent.
|
||||
spacing: ``int`` Number of pixels to space between widgets.
|
||||
|
||||
"""
|
||||
if "spacing" in kwargs:
|
||||
self._settings["spacing"] = kwargs["spacing"]
|
||||
if "widgets" in kwargs:
|
||||
pos = 0
|
||||
for w in kwargs["widgets"]:
|
||||
w.pos = (pos, 0)
|
||||
pos += w.rect.w + self._settings["spacing"]
|
||||
Container._config(self, **kwargs)
|
Loading…
Add table
Add a link
Reference in a new issue