[Python-checkins] python/dist/src/Tools/idle Bindings.py,1.14,1.15 IOBinding.py,1.6,1.7 config-unix.txt,1.2,1.3 config-win.txt,1.1,1.2 keydefs.py,1.4,1.5
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Mon, 10 Jun 2002 11:52:04 -0700
Update of /cvsroot/python/python/dist/src/Tools/idle
In directory usw-pr-cvs1:/tmp/cvs-serv5462
Modified Files:
Bindings.py IOBinding.py config-unix.txt config-win.txt
keydefs.py
Log Message:
Add primitive printing support for Unix and Windows.
Index: Bindings.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/idle/Bindings.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** Bindings.py 26 Aug 1999 23:06:22 -0000 1.14
--- Bindings.py 10 Jun 2002 18:52:02 -0000 1.15
***************
*** 24,27 ****
--- 24,29 ----
('Save Co_py As...', '<<save-copy-of-window-as-file>>'),
None,
+ ('_Print window', '<<print-window>>'),
+ None,
('_Close', '<<close-window>>'),
('E_xit', '<<close-all-windows>>'),
Index: IOBinding.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/idle/IOBinding.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** IOBinding.py 15 Apr 2002 00:19:12 -0000 1.6
--- IOBinding.py 10 Jun 2002 18:52:02 -0000 1.7
***************
*** 1,5 ****
--- 1,7 ----
import os
+ import tempfile
import tkFileDialog
import tkMessageBox
+ from IdleConf import idleconf
#$ event <<open-window-from-file>>
***************
*** 19,22 ****
--- 21,28 ----
#$ unix <Control-x><w>
+ #$ event <<print-window>>
+ #$ win <Control-p>
+ #$ unix <Control-x><Control-p>
+
class IOBinding:
***************
*** 31,34 ****
--- 37,41 ----
self.__id_savecopy = self.text.bind("<<save-copy-of-window-as-file>>",
self.save_a_copy)
+ self.__id_print = self.text.bind("<<print-window>>", self.print_window)
def close(self):
***************
*** 38,41 ****
--- 45,49 ----
self.text.unbind("<<save-window-as-file>>",self.__id_saveas)
self.text.unbind("<<save-copy-of-window-as-file>>", self.__id_savecopy)
+ self.text.unbind("<<print-window>>", self.__id_print)
# Break cycles
self.editwin = None
***************
*** 145,148 ****
--- 153,180 ----
self.writefile(filename)
self.text.focus_set()
+ return "break"
+
+ def print_window(self, event):
+ tempfilename = None
+ if self.get_saved():
+ filename = self.filename
+ else:
+ filename = tempfilename = tempfile.mktemp()
+ if not self.writefile(filename):
+ os.unlink(tempfilename)
+ return "break"
+ edconf = idleconf.getsection('EditorWindow')
+ command = edconf.get('print-command')
+ command = command % filename
+ if os.name == 'posix':
+ command = command + " 2>&1"
+ pipe = os.popen(command, "r")
+ output = pipe.read().strip()
+ status = pipe.close()
+ if status:
+ output = "Printing failed (exit status 0x%x)\n" % status + output
+ if output:
+ output = "Printing command: %s\n" % repr(command) + output
+ tkMessageBox.showerror("Print status", output, master=self.text)
return "break"
Index: config-unix.txt
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/idle/config-unix.txt,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** config-unix.txt 7 Mar 2000 17:56:47 -0000 1.2
--- config-unix.txt 10 Jun 2002 18:52:02 -0000 1.3
***************
*** 2,3 ****
--- 2,4 ----
font-name= courier
font-size= 10
+ print-command=lpr %s
Index: config-win.txt
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/idle/config-win.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** config-win.txt 3 Mar 2000 22:57:42 -0000 1.1
--- config-win.txt 10 Jun 2002 18:52:02 -0000 1.2
***************
*** 2,3 ****
--- 2,4 ----
font-name: courier new
font-size: 10
+ print-command=start /min notepad /p %s
Index: keydefs.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/idle/keydefs.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** keydefs.py 21 May 2002 12:26:59 -0000 1.4
--- keydefs.py 10 Jun 2002 18:52:02 -0000 1.5
***************
*** 18,21 ****
--- 18,22 ----
'<<open-window-from-file>>': ['<Control-o>'],
'<<plain-newline-and-indent>>': ['<Control-j>'],
+ '<<print-window>>': ['<Control-p>'],
'<<redo>>': ['<Control-y>'],
'<<remove-selection>>': ['<Escape>'],
***************
*** 47,50 ****
--- 48,52 ----
'<<open-window-from-file>>': ['<Control-x><Control-f>'],
'<<plain-newline-and-indent>>': ['<Control-j>'],
+ '<<print-window>>': ['<Control-x><Control-p>'],
'<<redo>>': ['<Alt-z>', '<Meta-z>'],
'<<save-copy-of-window-as-file>>': ['<Control-x><w>'],