From: Lucas H. <lu...@di...> - 2006-11-13 12:46:52
|
I've written a small program to let you run commands, using the ComboBoxEntry widget (to allow command history support). [SNIP] class UI: def __init__(self): self.entry = gtk.combo_box_entry_new_text() # HACK: use empty column to clear the entry field self.entry.append_text('') self.set_events(gtk.gdk.KEY_PRESS_MASK) self.connect('key-press-event', self.run_command) self.add(self.entry) def run_command(self, entry, event): if event.keyval == gtk.keysyms.Return: cmd = self.entry.get_active_text() if cmd: self.entry.insert_text(1,cmd) os.popen2(cmd) self.entry.set_active(0) return True class Window(rox.Window, UI): def __init__(self): rox.Window.__init__(self) UI.__init__(self) class Applet(applet.Applet, UI): def __init__(self, res): applet.Applet.__init__(self, res) UI.__init__(self) [SNIP] It works quite well as a windowed application, however, when I run it as an applet. I am unable to get the entry to focus (ie, can not type anything), I have also tried this with the Entry widget, to no avail. Any clues as to why this might happen and or how to get it to work as expected? -- Lucas Hazel <lu...@di...> |