[Twisted-Python] patches to make gtk2manhole work with gtk2

David E. Konerding dekonerding at lbl.gov
Tue Nov 22 13:54:45 MST 2005


Hi, in attempting to use gtk2manhole I had some problems.  It looks like
it was written on a much older version of gtk2,
here are patches I applied (they are not complete, merely sufficient to
start the application):


Index: twisted/manhole/ui/gtk2manhole.py
===================================================================
--- twisted/manhole/ui/gtk2manhole.py   (revision 14819)
+++ twisted/manhole/ui/gtk2manhole.py   (working copy)
@@ -22,6 +22,7 @@
 
 # The pygtk.require for version 2.0 has already been done by the reactor.
 import gtk
+import gobject
 
 import code, types, inspect
 
@@ -159,7 +160,7 @@
         # Silly things, the TextView needs to update itself before it knows
         # where the bottom is.
         if self._willScroll is None:
-            self._willScroll = gtk.idle_add(self._scrollDown)
+            self._willScroll = gobject.idle_add(self._scrollDown)
 
     def _scrollDown(self, *unused):
         self.textView.scroll_to_iter(self.buffer.get_end_iter(), 0,
@@ -256,11 +257,12 @@
         try:
             c = code.compile_command(text)
         except SyntaxError, e:
+            buffer = self.textView.get_buffer()
             # This could conceivably piss you off if the client's python
             # doesn't accept keywords that are known to the manhole's
             # python.
             point = buffer.get_iter_at_line_offset(e.lineno, e.offset)
-            buffer.place(point)
+            buffer.place_cursor(point)
             # TODO: Componentize!
             self.toplevel.output.append(str(e), "exception")
         except (OverflowError, ValueError), e:
Index: twisted/manhole/ui/pywidgets.py
===================================================================
--- twisted/manhole/ui/pywidgets.py     (revision 14819)
+++ twisted/manhole/ui/pywidgets.py     (working copy)
@@ -22,12 +22,12 @@
         return 1
 
 
-class InputText(gtk.GtkText):
+class InputText(gtk.TextView):
     linemode = 0
     blockcount = 0
 
     def __init__(self, toplevel=None):
-        gtk.GtkText.__init__(self)
+        gtk.Text.__init__(self)
         self['name'] = 'Input'
         self.set_editable(gtk.TRUE)
         self.connect("key_press_event", self.processKey)
@@ -155,11 +155,11 @@
         f.close()
 
 
-class Interaction(gtk.GtkWindow):
+class Interaction(gtk.Window):
     titleText = "Abstract Python Console"
 
     def __init__(self):
-        gtk.GtkWindow.__init__(self, gtk.WINDOW_TOPLEVEL)
+        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
         self.set_title(self.titleText)
         self.set_default_size(300, 300)
         self.set_name("Manhole")
@@ -197,11 +197,11 @@
             self.localNS["_"] = val
             self.output.console([("result", repr(val) + "\n")])
 
-class OutputConsole(gtk.GtkText):
+class OutputConsole(gtk.TextView):
     maxBufSz = 10000
 
     def __init__(self, toplevel=None):
-        gtk.GtkText.__init__(self)
+        gtk.TextView.__init__(self)
         self['name'] = "Console"
         gtkutil.defocusify(self)
         #self.set_word_wrap(gtk.TRUE)
Index: twisted/manhole/ui/spelunk_gnome.py
===================================================================
--- twisted/manhole/ui/spelunk_gnome.py (revision 14819)
+++ twisted/manhole/ui/spelunk_gnome.py (working copy)
@@ -32,13 +32,14 @@
 # not with Tk, so this is what I use.
 
 import gnome.ui
+import gnomecanvas
 gnome = SillyModule(gnome.ui, 'Gnome')
 
 import gtk
 (True, False) = (gtk.TRUE, gtk.FALSE)
 gtk = SillyModule(gtk, 'Gtk')
 
-import GDK
+import gtk.gdk as GDK
 
 from twisted.python import reflect, text
 from twisted.spread import pb
@@ -71,7 +72,7 @@
 
 #### Public
 
-class SpelunkDisplay(gnome.Canvas):
+class SpelunkDisplay(gnomecanvas.Canvas):
     """Spelunk widget.
 
     The top-level widget for this module.  This gtk.Widget is where the
@@ -179,11 +180,11 @@
     def __init__(self, box):
         self.box = box
 
-class LooseBox(gnome.CanvasGroup):
+class LooseBox(gnomecanvas.CanvasGroup):
     def __init__(self):
         self.border = _LooseBoxBorder(self)
 
-class Visage(gnome.CanvasGroup):
+class Visage(gnomecanvas.CanvasGroup):
     """A \"face\" of an object under exploration.
 
     A Visage is a representation of an object presented to the user.





More information about the Twisted-Python mailing list