-def makeactiongroup(name, acts):
- """Creates an ActionGroup called NAME. ACTS is a list of tuples
- containing:
- ACT: an action name
- LABEL: the label string for the action
- ACCEL: accelerator string, or None
- FUNC: thunk to call when the action is invoked"""
- actgroup = G.ActionGroup(name)
- for act, label, accel, func in acts:
- a = G.Action(act, label, None, None)
- if func: a.connect('activate', invoker(func))
- actgroup.add_action_with_accel(a, accel)
- return actgroup
-
-class TraceOptions (MyDialog):
- """Tracing options window."""
- def __init__(me, monitor):
- MyDialog.__init__(me, title = 'Tracing options',
- buttons = [(G.STOCK_CLOSE, me.destroy),
- (G.STOCK_OK, me.ok)])
- me.mon = monitor
- me.opts = []
- for o in me.mon.simplecmd('TRACE'):
- char = o[0]
- onp = o[1]
- text = o[3].upper() + o[4:]
- if char.isupper(): continue
- ticky = G.CheckButton(text)
- ticky.set_active(onp != ' ')
- me.vbox.pack_start(ticky)
- me.opts.append((char, ticky))
- me.show_all()
- def ok(me):
- on = []
- off = []
- for char, ticky in me.opts:
- if ticky.get_active():
- on.append(char)
- else:
- off.append(char)
- setting = ''.join(on) + '-' + ''.join(off)
- me.mon.simplecmd('TRACE %s' % setting)
- me.destroy()
-
-def unimplemented(*hunoz):
- """Indicator of laziness."""
- moanbox("I've not written that bit yet.")
-
-class GridPacker (G.Table):
- """Like a Table, but with more state: makes filling in the widgets
- easier."""
- def __init__(me):
- G.Table.__init__(me)
- me.row = 0
- me.col = 0
- me.rows = 1
- me.cols = 1
- me.set_border_width(4)
- me.set_col_spacings(4)
- me.set_row_spacings(4)
- def pack(me, w, width = 1, newlinep = False,
- xopt = G.EXPAND | G.FILL | G.SHRINK, yopt = 0,
- xpad = 0, ypad = 0):
- """Packs a new widget. W is the widget to add. XOPY, YOPT, XPAD and
- YPAD are as for Table. WIDTH is how many cells to take up horizontally.
- NEWLINEP is whether to start a new line for this widget. Returns W."""
- if newlinep:
- me.row += 1
- me.col = 0
- bot = me.row + 1
- right = me.col + width
- if bot > me.rows or right > me.cols:
- if bot > me.rows: me.rows = bot
- if right > me.cols: me.cols = right
- me.resize(me.rows, me.cols)
- me.attach(w, me.col, me.col + width, me.row, me.row + 1,
- xopt, yopt, xpad, ypad)
- me.col += width
- return w
- def labelled(me, lab, w, newlinep = False, **kw):
- """Packs a labelled widget. Other arguments are as for pack. Returns
- W."""
- label = G.Label(lab)
- label.set_alignment(1.0, 0)
- me.pack(label, newlinep = newlinep, xopt = G.FILL)
- me.pack(w, **kw)
- return w
- def info(me, label, text = None, len = 18, **kw):
- e = G.Entry()
- if text is not None: e.set_text(text)
- e.set_width_chars(len)
- e.set_editable(False)
- me.labelled(label, e, **kw)
- return e