1 2 3 4 5 6 | class WTable(GTK.Container): def __init__(self, maxsize=None): GTK.Container.__init__(self) self.gChildren = [] self.maxsize = maxsize or (gdk.screen_width(), gdk.screen_height()) |
1 | def attach(self, widget, leftright=(0,1), topbottom=(0,1), glue=None): |
1 2 3 4 5 6 7 | class Child: "Child of WTable. Adoption data" def __init__(self, w, leftright=(0,1), topbottom=(0,1), glue=None): self.widget = w # lrtb: 2x2 tuple Cols[begin, end), Rows[Begin, end) ) self.lrtb = (leftright, topbottom) self.glue = glue |
1 2 3 4 | class Glue: "2-Dimensional Glue" def __init__(self, xglue=None, yglue=None): self.xy = (xglue or Glue1D(), yglue or Glue1D()) |
1 2 3 4 5 | class Glue1D: "1-Dimensional Glue" def __init__(self, preSpring=None, postSpring=None, wGrow=1): self.springs = (preSpring or Spring(), postSpring or Spring()) self.wGrow = wGrow # of owning widget |
1 2 3 4 5 | class Spring: "One side attachment requirement" def __init__(self, pad=0, wGrow=0): self.pad = pad self.wGrow = wGrow |
1 2 | def total_grow_weight(self): return self.wGrow + self.springs[0].wGrow + self.springs[1].wGrow |
1 2 3 4 5 6 7 8 9 10 11 12 13 | def attach(self, widget, leftright=(0,1), topbottom=(0,1), glue=None): if glue == None: glue = Glue() # Conveniently change possible single n value to (n,n+1) lrtb = map(lambda x: (type(x) == types.IntType) and (x, x+1) or x, (leftright, topbottom)) child = Child(widget, lrtb[0], lrtb[1], glue) self.gChildren.append(child) if self.flags() & GTK.REALIZED: widget.set_parent_window(self.window) widget.set_parent(self) self.queue_resize() return child |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |