diff options
-rw-r--r-- | lvc/widgets/gtk/layout.py | 56 |
1 files changed, 35 insertions, 21 deletions
diff --git a/lvc/widgets/gtk/layout.py b/lvc/widgets/gtk/layout.py index 549311c..5c19671 100644 --- a/lvc/widgets/gtk/layout.py +++ b/lvc/widgets/gtk/layout.py @@ -34,6 +34,7 @@ import gtk from lvc.utils import Matrix from .base import Widget, Bin + class Box(Widget): def __init__(self, spacing=0): Widget.__init__(self) @@ -42,18 +43,18 @@ class Box(Widget): def pack_start(self, widget, expand=False, padding=0): self._widget.pack_start(widget._widget, expand, fill=True, - padding=padding) + padding=padding) widget._widget.show() self.children.add(widget) def pack_end(self, widget, expand=False, padding=0): self._widget.pack_end(widget._widget, expand, fill=True, - padding=padding) + padding=padding) widget._widget.show() self.children.add(widget) def remove(self, widget): - widget._widget.hide() # otherwise gtkmozembed gets confused + widget._widget.hide() # otherwise gtkmozembed gets confused self._widget.remove(widget._widget) self.children.remove(widget) @@ -65,15 +66,18 @@ class Box(Widget): for mem in self.children: mem.disable() + class HBox(Box): WIDGET_CLASS = gtk.HBox + class VBox(Box): WIDGET_CLASS = gtk.VBox + class Alignment(Bin): def __init__(self, xalign=0, yalign=0, xscale=0, yscale=0, - top_pad=0, bottom_pad=0, left_pad=0, right_pad=0): + top_pad=0, bottom_pad=0, left_pad=0, right_pad=0): Bin.__init__(self) self.set_widget(gtk.Alignment(xalign, yalign, xscale, yscale)) self.set_padding(top_pad, bottom_pad, left_pad, right_pad) @@ -84,10 +88,12 @@ class Alignment(Bin): def set_padding(self, top_pad=0, bottom_pad=0, left_pad=0, right_pad=0): self._widget.set_padding(top_pad, bottom_pad, left_pad, right_pad) + class DetachedWindowHolder(Alignment): def __init__(self): Alignment.__init__(self, xscale=1, yscale=1) + class Splitter(Widget): def __init__(self): """Create a new splitter.""" @@ -109,14 +115,14 @@ class Splitter(Widget): def remove_left(self): """Remove the left child widget.""" if self.left is not None: - self.left._widget.hide() # otherwise gtkmozembed gets confused + self.left._widget.hide() # otherwise gtkmozembed gets confused self._widget.remove(self.left._widget) self.left = None def remove_right(self): """Remove the right child widget.""" if self.right is not None: - self.right._widget.hide() # otherwise gtkmozembed gets confused + self.right._widget.hide() # otherwise gtkmozembed gets confused self._widget.remove(self.right._widget) self.right = None @@ -131,6 +137,7 @@ class Splitter(Widget): # We should take into account the width of the bar, but this seems # good enough. + class Table(Widget): """Lays out widgets in a table. It works very similar to the GTK Table widget, or an HTML table. @@ -145,11 +152,11 @@ class Table(Widget): """ self.children[column, row] = widget self._widget.attach(widget._widget, column, column + column_span, - row, row + row_span) + row, row + row_span) widget._widget.show() def remove(self, widget): - widget._widget.hide() # otherwise gtkmozembed gets confused + widget._widget.hide() # otherwise gtkmozembed gets confused self.children.remove(widget) self._widget.remove(widget._widget) @@ -160,36 +167,43 @@ class Table(Widget): self._widget.set_row_spacings(spacing) def enable(self, row=None, column=None): - if row != None and column != None: + if row is not None and column is not None: if self.children[column, row]: self.children[column, row].enable() - elif row != None: + elif row is not None: for mem in self.children.row(row): - if mem: mem.enable() - elif column != None: + if mem: + mem.enable() + elif column is not None: for mem in self.children.column(column): - if mem: mem.enable() + if mem: + mem.enable() else: for mem in self.children: - if mem: mem.enable() + if mem: + mem.enable() def disable(self, row=None, column=None): - if row != None and column != None: + if row is not None and column is not None: if self.children[column, row]: self.children[column, row].disable() - elif row != None: + elif row is not None: for mem in self.children.row(row): - if mem: mem.disable() - elif column != None: + if mem: + mem.disable() + elif column is not None: for mem in self.children.column(column): - if mem: mem.disable() + if mem: + mem.disable() else: for mem in self.children: - if mem: mem.disable() + if mem: + mem.disable() + class TabContainer(Widget): def __init__(self, xalign=0, yalign=0, xscale=0, yscale=0, - top_pad=0, bottom_pad=0, left_pad=0, right_pad=0): + top_pad=0, bottom_pad=0, left_pad=0, right_pad=0): Widget.__init__(self) self.set_widget(gtk.Notebook()) self._widget.set_tab_pos(gtk.POS_TOP) |