ocarina/src/extra/gtknodes/box.py

54 lines
1.1 KiB
Python

#! /usr/bin/python
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="bjschuma"
__date__ ="$May 13, 2010 11:46:36 AM$"
from gtknodes.node import Node
import gtk
class BoxNode(Node):
def __init__(self, elm, box):
Node.__init__(self, elm)
self["pack"] = "start"
self["expand"] = "false"
self["fill"] = "false"
self["pad"] = 0
self.part = box()
self.setattrs()
self.pack()
def packval(self,key,node):
if ( key in node.keys() ) == True:
return node[key]
return self[key]
def pack(self):
for child in self.children:
pack = self.packval("pack", child)
expand = self.packval("expand", child) == "true"
fill = self.packval("fill", child) == "true"
pad = int( self.packval("pad", child) )
if pack == "start":
self.part.pack_start(child.part, expand, fill, pad)
else:
self.part.pack_end(child.part, expand, fill, pad)
class HBox(BoxNode):
def __init__(self,elm):
BoxNode.__init__(self, elm, gtk.HBox)
class VBox(BoxNode):
def __init__(self,elm):
BoxNode.__init__(self, elm, gtk.VBox)