我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用gtk.FILL。
def __init__(self,servers): self.servers = servers; self.serverInfo = {}; table = gtk.Table(60,50); self.window = gtk.Window(); inputEntry = self.build_InputEntry(); menuBar = self.build_Menu(); self.noteBook = self.build_Note(); self.messageView = self.build_MessageView(); table.attach(menuBar,0,60,0,10); table.attach(self.noteBook,0,50,11,50, gtk.EXPAND, gtk.FILL); table.attach(self.messageView, 51, 60, 11, 50); table.attach(inputEntry,0,60,51,60) self.window.set_default_size(1000,700); self.window.add(table); self.window.show_all(); self.window.connect("delete_event", self.delete_event) self.window.connect("destroy", self.destroy) gtk.main();
def __init__(self, max_depth_value): self.on_max_depth_changed = None max_depth_entry = self.max_depth_entry = gtk.SpinButton( gtk.Adjustment(value=max_depth_value, lower=1, upper=100, step_incr=1, page_incr=10), digits=0) max_depth_entry.get_adjustment().connect('value_changed', self._max_depth_changed, max_depth_entry) max_depth_entry.set_alignment(0) max_depth_label = gtk.Label() max_depth_label.set_alignment(1, 0.5) max_depth_label.set_text_with_mnemonic('Maximum _Depth') max_depth_label.set_mnemonic_widget(max_depth_entry) legend = self._create_legend() table = self.view = gtk.Table(2, 3) table.set_border_width(8) table.set_row_spacings(8) table.set_col_spacings(8) table.attach(max_depth_label, 0, 1, 0, 1, gtk.FILL, gtk.FILL) table.attach(max_depth_entry, 1, 2, 0, 1, gtk.SHRINK, gtk.FILL) table.attach(gtk.Label(), 2, 3, 0, 1) # space filler table.attach(legend, 0, 3, 1, 2)
def _add(self, tab, row, name, editor, text, colindex=0): label = gtk.Label(text + ":") label.set_alignment(0.0, 0.5) label.show() tab.attach(label, colindex, colindex + 1, row, row + 1, xoptions=gtk.FILL, yoptions=0, xpadding=6, ypadding=3) widget = editor.get_widget() widget.show() tab.attach(widget, colindex + 1, colindex + 2, row, row + 1, xoptions=gtk.FILL, yoptions=0, xpadding=3, ypadding=3) img = gtk.Image() img.set_size_request(16, -1) img.show() tab.attach(img, colindex + 2, colindex + 3, row, row + 1, xoptions=gtk.FILL, yoptions=0, xpadding=3, ypadding=3) self._editors[name] = label, editor, img return label, editor, img
def new_table(wids): """Creates a gtk.Table with two rows, use it for forms""" p = gtk.Table(rows=len(wids) or 1, columns=2, homogeneous=False) p.set_col_spacings(5) p.set_row_spacings(5) if len(wids) < 1: wid = gtk.Label("Empty") p.attach(wid, 0, 2, 0, 1) p.show_all() return p for i, row in enumerate(wids): if isinstance(row, basestring): wid = Label("<b>%s</b>" % row) p.attach(wid, 0, 2, i, i+1) wid.show() if i > 0: p.set_row_spacing(i-1, 10) elif isinstance(row, (tuple, list)): label, field = row wid = new_label_for(label, field) p.attach(wid, 0, 1, i, i+1, xoptions=gtk.FILL) p.attach(field, 1, 2, i, i+1) wid.show() field.show() sw = gtk.ScrolledWindow() sw.set_shadow_type(gtk.SHADOW_NONE) sw.set_policy(hscrollbar_policy=gtk.POLICY_NEVER, vscrollbar_policy=gtk.POLICY_AUTOMATIC) sw.add_with_viewport(p) p.show() sw.show() return sw # new_table()
def _add(self, tab, row, name, editor, text): label, editor, img = super(MultiMemoryDetailEditor, self)._add( tab, row, name, editor, text, 1) selector = gtk.CheckButton() tab.attach(selector, 0, 1, row, row + 1, xoptions=gtk.FILL, yoptions=0, xpadding=0, ypadding=3) selector.show() self._toggle_selector(selector, label, editor, img) selector.connect("toggled", self._toggle_selector, label, editor, img) self._selections[name] = selector
def addParam(self, name, field, ptype, *args): x = self.tblGeneral.rows self.tblGeneral.rows += 1 value = eval(field) if ptype==bool: obj = gtk.CheckButton() obj.set_label(name) obj.set_active(value) obj.set_alignment(0, 0.5) obj.show() obj.field=field self.tblGeneral.attach(obj, 0, 2, x, x+1, gtk.EXPAND|gtk.FILL, 0) elif ptype==int: obj = gtk.SpinButton(climb_rate=10) if len(args)==2: obj.set_range(args[0], args[1]) obj.set_increments(1, 10) obj.set_numeric(True) obj.set_value(value) obj.show() obj.field=field lbl = gtk.Label(name) lbl.set_alignment(0, 0.5) lbl.show() self.tblGeneral.attach(lbl, 0, 1, x, x+1, gtk.FILL, 0) self.tblGeneral.attach(obj, 1, 2, x, x+1, gtk.EXPAND|gtk.FILL, 0) elif ptype==list: obj = gtk.combo_box_new_text() for s in args[0]: obj.append_text(s) obj.set_active(value) obj.show() obj.field=field lbl = gtk.Label(name) lbl.set_alignment(0, 0.5) lbl.show() self.tblGeneral.attach(lbl, 0, 1, x, x+1, gtk.FILL, 0) self.tblGeneral.attach(obj, 1, 2, x, x+1, gtk.EXPAND|gtk.FILL, 0) else: obj = gtk.Entry() obj.set_text(value) obj.show() obj.field=field lbl = gtk.Label(name) lbl.set_alignment(0, 0.5) lbl.show() self.tblGeneral.attach(lbl, 0, 1, x, x+1, gtk.FILL, 0) self.tblGeneral.attach(obj, 1, 2, x, x+1, gtk.EXPAND|gtk.FILL, 0)
def _create_legend(self): icons = ( (gtk.STOCK_FILE, 'Class'), (gtk.STOCK_EXECUTE, 'Method'), (gtk.STOCK_SELECT_FONT, 'Field'), (gtk.STOCK_DELETE, 'Declaration not found'), (gtk.STOCK_INFO, 'Miscellaneous (info)'), (u'?', 'Direct call – e.g. static, private, etc'), (u'?', 'Virtual call (? + ?)'), (u'?', 'Virtual call (indirect) which could be performed because ' 'of polymorphism'), (u'?', 'Virtual call (direct only) which does not actually ' 'performed – e.g. interface method'), (u'?', 'Super call (? + ?)'), (u'?', 'Super call (indirect) because direct super does not ' 'declare the method'), (u'?', 'Super call (direct only) which does not actually ' 'performed – e.g. not declared here'), ) table = gtk.Table(7, 5) table.set_border_width(8) table.set_row_spacings(8) table.set_col_spacings(8) separator = gtk.VSeparator() table.attach(separator, 2, 3, 0, 7, 0) x, y = 0, 0 for icon, desc in icons: if len(icon) == 1: image = gtk.Label(icon) else: image = gtk.Image() image.set_from_stock(icon, gtk.ICON_SIZE_MENU) image.set_alignment(1, 0.5) label = gtk.Label(desc) label.set_alignment(0, 0.5) table.attach(image, x + 0, x + 1, y, y + 1, gtk.FILL) table.attach(label, x + 1, x + 2, y, y + 1, gtk.FILL) y += 1 if y == 5 and x == 0: x, y = 3, 0 frame = gtk.Frame('Legend') frame.add(table) return frame
def _tree_click(self, view, event): if event.button != 1: return index = [0] def pack(widget, pos): self._display.attach(widget, pos, pos + 1, index[0], index[0] + 1, xoptions=gtk.FILL, yoptions=0) def next_row(): index[0] += 1 def abandon(child): self._display.remove(child) pathinfo = view.get_path_at_pos(int(event.x), int(event.y)) path = pathinfo[0] iter = self._store.get_iter(path) name, obj = self._store.get(iter, 0, 1) self._display.foreach(abandon) for name, item in obj.items(): if item.size() % 8 == 0: name = '<b>%s</b> <small>(%s %i bytes)</small>' % ( name, bitwise_type(classname(item)), item.size() / 8) else: name = '<b>%s</b> <small>(%s %i bits)</small>' % ( name, bitwise_type(classname(item)), item.size()) l = gtk.Label(name + " ") l.set_use_markup(True) l.show() pack(l, 0) if (isinstance(item, bitwise.intDataElement) or isinstance(item, bitwise.bcdDataElement)): e = IntegerEditor(item) elif (isinstance(item, bitwise.arrayDataElement) and isinstance(item[0], bitwise.bcdDataElement)): e = BCDArrayEditor(item) elif (isinstance(item, bitwise.arrayDataElement) and isinstance(item[0], bitwise.charDataElement)): e = CharArrayEditor(item) else: e = OtherEditor(item) e.show() pack(e, 1) next_row()