[Pythonmac-SIG] readline

Nicholas Riley njriley@uiuc.edu
Sat, 30 Nov 2002 20:53:17 -0600


--NzB8fVQJ5HfG6fxh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Sat, Nov 30, 2002 at 04:19:42PM -0800, Paul Berkowitz wrote:
> Now a more Python-specific question:
> 
> Is there currently a way to get 'readline' to operate in the Python
> Interactive interpreter so I can navigate with arrow keys to make
> corrections, retain values, etc? I gather that we're all waiting for Python
> 2.3 to enable IDLE for Mac OS X, but is there a make-do readline facility in
> the meantime?

You can link with the private readline.framework or (what I did) just
compile readline from Fink and use that.

The idlefork (www.sourceforge.net/projects/idlefork) version of IDLE
works fine under a framework build of Python 2.2.2, barring a couple
of cosmetic issues.  Apply the attached patch to the latest CVS
version of idlefork (fixes it to use pythonw and move the line/column
numbers over to make room for the size box) and you should be all set.
The changes aren't at all cleanly done but they work for me.

After I downloaded WASTE and stuck it in the right place (a directory
named 'waste' at the same level as the Python source directory) before
building, the Python IDE even works from within the framework.  Is
there any documentation on building app wrappers?  It's a bit confusing
to have both IDLE and the Python IDE show up in the dock as
"PythonInterpreter".

-- 
=Nicholas Riley <njriley@uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>
        Pablo Research Group, Department of Computer Science and
  Medical Scholars Program, University of Illinois at Urbana-Champaign

--NzB8fVQJ5HfG6fxh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="idle-python-2.2.2-patch.txt"

Index: EditorWindow.py
===================================================================
RCS file: /cvsroot/idlefork/idle/EditorWindow.py,v
retrieving revision 1.35
diff -c -r1.35 EditorWindow.py
*** EditorWindow.py	23 Oct 2002 04:48:08 -0000	1.35
--- EditorWindow.py	1 Dec 2002 02:44:50 -0000
***************
*** 193,199 ****
          self.status_bar = self.MultiStatusBar(self.top)
          self.status_bar.set_label('column', 'Col: ?', side=RIGHT)
          self.status_bar.set_label('line', 'Ln: ?', side=RIGHT)
!         self.status_bar.pack(side=BOTTOM, fill=X)
          self.text.bind('<KeyRelease>', self.set_line_and_column)
          self.text.bind('<ButtonRelease>', self.set_line_and_column)
          self.text.after_idle(self.set_line_and_column)
--- 193,199 ----
          self.status_bar = self.MultiStatusBar(self.top)
          self.status_bar.set_label('column', 'Col: ?', side=RIGHT)
          self.status_bar.set_label('line', 'Ln: ?', side=RIGHT)
!         self.status_bar.pack(side=BOTTOM, fill=X, padx=14)
          self.text.bind('<KeyRelease>', self.set_line_and_column)
          self.text.bind('<ButtonRelease>', self.set_line_and_column)
          self.text.after_idle(self.set_line_and_column)
Index: MultiStatusBar.py
===================================================================
RCS file: /cvsroot/idlefork/idle/MultiStatusBar.py,v
retrieving revision 1.3
diff -c -r1.3 MultiStatusBar.py
*** MultiStatusBar.py	13 Jul 2001 17:52:08 -0000	1.3
--- MultiStatusBar.py	1 Dec 2002 02:44:50 -0000
***************
*** 10,16 ****
  
      def set_label(self, name, text='', side=LEFT):
          if not self.labels.has_key(name):
!             label = Label(self, bd=1, relief=SUNKEN, anchor=W)
              label.pack(side=side)
              self.labels[name] = label
          else:
--- 10,16 ----
  
      def set_label(self, name, text='', side=LEFT):
          if not self.labels.has_key(name):
!             label = Label(self, bd=1, relief=SUNKEN, anchor=W, font=('Geneva', 9, ''))
              label.pack(side=side)
              self.labels[name] = label
          else:
Index: PyShell.py
===================================================================
RCS file: /cvsroot/idlefork/idle/PyShell.py,v
retrieving revision 1.35
diff -c -r1.35 PyShell.py
*** PyShell.py	30 Nov 2002 18:49:10 -0000	1.35
--- PyShell.py	1 Dec 2002 02:44:53 -0000
***************
*** 285,293 ****
              #
              # Instead, find the executable by looking relative to
              # sys.prefix.
!             executable = os.path.join(sys.prefix, 'Resources', 
!                                       'Python.app', 'Contents',
!                                       'MacOS', 'python')
              return executable
          else:
              return sys.executable 
--- 285,294 ----
              #
              # Instead, find the executable by looking relative to
              # sys.prefix.
!             #executable = os.path.join(sys.prefix, 'Resources', 
!             #                          'Python.app', 'Contents',
!             #                          'MacOS', 'python')
!             executable = os.path.join(sys.prefix, 'bin', 'python')
              return executable
          else:
              return sys.executable 
Index: TreeWidget.py
===================================================================
RCS file: /cvsroot/idlefork/idle/TreeWidget.py,v
retrieving revision 1.5
diff -c -r1.5 TreeWidget.py
*** TreeWidget.py	30 Nov 2002 19:04:06 -0000	1.5
--- TreeWidget.py	1 Dec 2002 02:44:53 -0000
***************
*** 248,254 ****
              label = self.label
          except AttributeError:
              # padding carefully selected (on Windows) to match Entry widget:
!             self.label = Label(self.canvas, text=text, bd=0, padx=2, pady=2)
          if self.selected:
              self.label.configure(fg="white", bg="darkblue")
          else:
--- 248,254 ----
              label = self.label
          except AttributeError:
              # padding carefully selected (on Windows) to match Entry widget:
!             self.label = Label(self.canvas, text=text, bd=0, padx=2, pady=2, font=('', 11, ''))
          if self.selected:
              self.label.configure(fg="white", bg="darkblue")
          else:
Index: idle
===================================================================
RCS file: /cvsroot/idlefork/idle/idle,v
retrieving revision 1.3
diff -c -r1.3 idle
*** idle	17 Jul 2001 04:59:01 -0000	1.3
--- idle	1 Dec 2002 02:44:53 -0000
***************
*** 1,4 ****
! #! /usr/bin/env python
  
  import PyShell
  PyShell.main()
--- 1,4 ----
! #! /usr/bin/env pythonw
  
  import PyShell
  PyShell.main()

--NzB8fVQJ5HfG6fxh--