[Python-checkins] r64955 - in sandbox/trunk/ttk-gsoc/src/idlelib: Bindings.py CodeContext.py EditorWindow.py ParenMatch.py config-keys.def configHandler.py help.txt
guilherme.polo
python-checkins at python.org
Mon Jul 14 20:37:25 CEST 2008
Author: guilherme.polo
Date: Mon Jul 14 20:37:24 2008
New Revision: 64955
Log:
Very very early notebook support, all it does right now is creating a notebook
that won't create other pages or even properly close the current page.
Modified:
sandbox/trunk/ttk-gsoc/src/idlelib/Bindings.py
sandbox/trunk/ttk-gsoc/src/idlelib/CodeContext.py
sandbox/trunk/ttk-gsoc/src/idlelib/EditorWindow.py
sandbox/trunk/ttk-gsoc/src/idlelib/ParenMatch.py
sandbox/trunk/ttk-gsoc/src/idlelib/config-keys.def
sandbox/trunk/ttk-gsoc/src/idlelib/configHandler.py
sandbox/trunk/ttk-gsoc/src/idlelib/help.txt
Modified: sandbox/trunk/ttk-gsoc/src/idlelib/Bindings.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/Bindings.py (original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/Bindings.py Mon Jul 14 20:37:24 2008
@@ -6,15 +6,16 @@
makes it possible, for example, to define a Debug menu which is only present in
the PythonShell window, and a Format menu which is only present in the Editor
windows.
-
"""
import sys
+
from configHandler import idleConf
menudefs = [
# underscore prefixes character to underscore
('file', [
('_New Window', '<<open-new-window>>'),
+ ('New _Tab', '<<open-new-tab>>'),
('_Open...', '<<open-window-from-file>>'),
('Open _Module...', '<<open-module>>'),
('Class _Browser', '<<open-class-browser>>'),
@@ -26,6 +27,7 @@
None,
('Prin_t Window', '<<print-window>>'),
None,
+ ('Close Tab', '<<close-tab>>'),
('_Close', '<<close-window>>'),
('E_xit', '<<close-all-windows>>'),
]),
@@ -80,7 +82,6 @@
]),
]
-import sys
if sys.platform == 'darwin' and '.app' in sys.executable:
# Running as a proper MacOS application bundle. This block restructures
# the menus a little to make them conform better to the HIG.
Modified: sandbox/trunk/ttk-gsoc/src/idlelib/CodeContext.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/CodeContext.py (original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/CodeContext.py Mon Jul 14 20:37:24 2008
@@ -59,33 +59,27 @@
#
# All values are passed through int(str(<value>)), since some
# values may be pixel objects, which can't simply be added to ints.
- widgets = self.editwin.text, self.editwin.text_frame
- # Calculate the required vertical padding
- padx = 0
- for widget in widgets:
- padx += int(str( widget.pack_info()['padx'] ))
- padx += int(str( widget.cget('padx') ))
- # Calculate the required border width
- border = 0
- for widget in widgets:
- border += int(str( widget.cget('border') ))
+
+ # Calculate the required horizontal padding
+ padx = int(str(self.editwin.text_notebook.pack_info()['padx']))
+
self.label = Tkinter.Label(self.editwin.top,
text="\n" * (self.context_depth - 1),
anchor=W, justify=LEFT,
font=self.textfont,
bg=self.bgcolor, fg=self.fgcolor,
width=1, #don't request more than we get
- padx=padx, border=border,
+ padx=padx,
relief=SUNKEN)
- # Pack the label widget before and above the text_frame widget,
- # thus ensuring that it will appear directly above text_frame
+ # Pack the label widget before and above the text_notebook widget,
+ # thus ensuring that it will appear directly above text_notebook
self.label.pack(side=TOP, fill=X, expand=False,
- before=self.editwin.text_frame)
+ before=self.editwin.text_notebook)
else:
self.label.destroy()
self.label = None
idleConf.SetOption("extensions", "CodeContext", "visible",
- str(self.label is not None))
+ str(self.label is not None))
idleConf.SaveUserCfgFiles()
def get_line_info(self, linenum):
Modified: sandbox/trunk/ttk-gsoc/src/idlelib/EditorWindow.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/EditorWindow.py (original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/EditorWindow.py Mon Jul 14 20:37:24 2008
@@ -22,6 +22,7 @@
import ClassBrowser
import SearchDialog
import ReplaceDialog
+from tabbedpages import get_tabbedpage
from configHandler import idleConf
from MultiCall import MultiCallCreator
from IOBinding import IOBinding, filesystemencoding, encoding
@@ -29,6 +30,8 @@
from UndoDelegator import UndoDelegator
from MultiStatusBar import MultiStatusBar
+TabbedPageSet = get_tabbedpage()
+
if idleConf.GetOption('main', 'General', 'use-ttk', type='int'):
from ttk import Frame, Scrollbar
@@ -87,7 +90,7 @@
EditorWindow.help_url = 'file://' + EditorWindow.help_url
else:
EditorWindow.help_url = "http://www.python.org/doc/current"
- currentTheme=idleConf.CurrentTheme()
+
self.flist = flist
root = root or flist.root
self.root = root
@@ -107,14 +110,20 @@
# values: Tkinter variable instances
self.top.instance_dict = {}
self.recent_files_path = os.path.join(idleConf.GetUserCfgDir(),
- 'recent-files.lst')
- self.text_frame = text_frame = Frame(top)
- self.vbar = vbar = Scrollbar(text_frame, name='vbar')
- self.width = idleConf.GetOption('main','EditorWindow','width')
+ 'recent-files.lst')
+
+ # create a Notebook where the text pages for this EditorWindow will
+ # reside
+ first_page_title = "#1"
+ self.text_notebook = TabbedPageSet(top, page_names=[first_page_title])
+
+ page_frame = self.text_notebook.pages[first_page_title].frame
+ vbar = Scrollbar(page_frame, name='vbar')
+ # The following "width" attribute is used by PyShell, so keep it here
+ self.width = idleConf.GetOption('main', 'EditorWindow', 'width')
self.text = text = MultiCallCreator(Text)(
- text_frame, name='text', padx=5, wrap='none',
- width=self.width,
- height=idleConf.GetOption('main','EditorWindow','height') )
+ page_frame, name='text', padx=5, wrap='none', width=self.width,
+ height=idleConf.GetOption('main', 'EditorWindow', 'height'))
self.top.focused_widget = self.text
self.createmenubar()
@@ -125,6 +134,8 @@
if macosxSupport.runningAsOSXApp():
# Command-W on editorwindows doesn't work without this.
text.bind('<<close-window>>', self.close_event)
+ text.bind("<<close-tab>>", self.close_tab)
+ text.bind("<<open-new-tab>>", self.new_editor_page)
text.bind("<<cut>>", self.cut)
text.bind("<<copy>>", self.copy)
text.bind("<<paste>>", self.paste)
@@ -178,11 +189,11 @@
if idleConf.GetOption('main', 'EditorWindow', 'font-bold', type='bool'):
fontWeight='bold'
text.config(font=(idleConf.GetOption('main', 'EditorWindow', 'font'),
- idleConf.GetOption('main', 'EditorWindow', 'font-size'),
- fontWeight))
- text_frame.pack(side=LEFT, fill=BOTH, expand=1)
+ idleConf.GetOption('main', 'EditorWindow', 'font-size'),
+ fontWeight))
text.pack(side=TOP, fill=BOTH, expand=1)
text.focus_set()
+ self.text_notebook.pack(fill=BOTH, expand=True)
# usetabs true -> literal tab characters are used by indent and
# dedent cmds, possibly mixed with spaces if
@@ -193,7 +204,8 @@
# Although use-spaces=0 can be configured manually in config-main.def,
# configuration of tabs v. spaces is not supported in the configuration
# dialog. IDLE promotes the preferred Python indentation: use spaces!
- usespaces = idleConf.GetOption('main', 'Indent', 'use-spaces', type='bool')
+ usespaces = idleConf.GetOption('main', 'Indent', 'use-spaces',
+ type='bool')
self.usetabs = not usespaces
# tabwidth is the display width of a literal tab character.
@@ -288,6 +300,11 @@
self.flist.new(dirname)
return "break"
+ def new_editor_page(self, event):
+ """Create a new EditorPage and insert it into the notebook."""
+ print "Not yet"
+ return "break"
+
def home_callback(self, event):
if (event.state & 12) != 0 and event.keysym == "Home":
# state&1==shift, state&4==control, state&8==alt
@@ -852,6 +869,10 @@
def close_event(self, event):
self.close()
+ def close_tab(self, event):
+ """Close current tab, if no more tabs present, close the window."""
+ print "I do nothing right now"
+
def maybesave(self):
if self.io:
if not self.get_saved():
Modified: sandbox/trunk/ttk-gsoc/src/idlelib/ParenMatch.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/ParenMatch.py (original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/ParenMatch.py Mon Jul 14 20:37:24 2008
@@ -159,14 +159,14 @@
if index != self.text.index("insert"):
self.handle_restore_timer(c)
else:
- self.editwin.text_frame.after(CHECK_DELAY, callme, callme)
- self.editwin.text_frame.after(CHECK_DELAY, callme, callme)
+ self.editwin.text_notebook.after(CHECK_DELAY, callme, callme)
+ self.editwin.text_notebook.after(CHECK_DELAY, callme, callme)
def set_timeout_last(self):
"""The last highlight created will be removed after .5 sec"""
# associate a counter with an event; only disable the "paren"
# tag if the event is for the most recent timer.
self.counter += 1
- self.editwin.text_frame.after(self.FLASH_DELAY,
+ self.editwin.text_notebook.after(self.FLASH_DELAY,
lambda self=self, c=self.counter: \
self.handle_restore_timer(c))
Modified: sandbox/trunk/ttk-gsoc/src/idlelib/config-keys.def
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/config-keys.def (original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/config-keys.def Mon Jul 14 20:37:24 2008
@@ -15,6 +15,7 @@
center-insert=<Control-Key-l> <Control-Key-L>
close-all-windows=<Control-Key-q>
close-window=<Alt-Key-F4> <Meta-Key-F4>
+close-tab=<Control-Key-w> <Control-Key-W>
do-nothing=<Control-Key-F12>
end-of-file=<Control-Key-d> <Control-Key-D>
python-docs=<Key-F1>
@@ -27,6 +28,7 @@
open-class-browser=<Alt-Key-c> <Meta-Key-c> <Alt-Key-C>
open-module=<Alt-Key-m> <Meta-Key-m> <Alt-Key-M>
open-new-window=<Control-Key-n> <Control-Key-N>
+open-new-tab=<Control-Key-t> <Control-Key-T>
open-window-from-file=<Control-Key-o> <Control-Key-O>
plain-newline-and-indent=<Control-Key-j> <Control-Key-J>
print-window=<Control-Key-p> <Control-Key-P>
@@ -66,6 +68,7 @@
center-insert=<Control-Key-l>
close-all-windows=<Control-Key-x><Control-Key-c>
close-window=<Control-Key-x><Control-Key-0>
+close-tab=<Alt-Key-w><Control-Key-w>
do-nothing=<Control-Key-x>
end-of-file=<Control-Key-d>
history-next=<Alt-Key-n> <Meta-Key-n>
@@ -76,6 +79,7 @@
open-class-browser=<Control-Key-x><Control-Key-b>
open-module=<Control-Key-x><Control-Key-m>
open-new-window=<Control-Key-x><Control-Key-n>
+open-new-tab=<Alt-Key-t><Control-Key-t>
open-window-from-file=<Control-Key-x><Control-Key-f>
plain-newline-and-indent=<Control-Key-j>
print-window=<Control-x><Control-Key-p>
@@ -117,6 +121,7 @@
center-insert=<Control-Key-l>
close-all-windows=<Command-Key-q>
close-window=<Command-Key-w>
+close-tab=<Control-key-w>
do-nothing=<Control-Key-F12>
end-of-file=<Control-Key-d>
python-docs=<Key-F1>
@@ -129,6 +134,7 @@
open-class-browser=<Command-Key-b>
open-module=<Command-Key-m>
open-new-window=<Command-Key-n>
+open-new-tab=<Control-Key-t>
open-window-from-file=<Command-Key-o>
plain-newline-and-indent=<Control-Key-j>
print-window=<Command-Key-p>
@@ -175,6 +181,7 @@
comment-region = <Control-Key-3>
redo = <Shift-Command-Key-Z>
close-window = <Command-Key-w>
+close-tab=<Control-Key-w>
restart-shell = <Control-Key-F6>
save-window-as-file = <Command-Key-S>
close-all-windows = <Command-Key-q>
@@ -205,6 +212,7 @@
end-of-file = <Control-Key-d>
open-class-browser = <Command-Key-b>
open-new-window = <Command-Key-n>
+open-new-tab = <Control-Key-t>
open-module = <Command-Key-m>
find-selection = <Shift-Command-Key-F3>
python-context-help = <Shift-Key-F1>
Modified: sandbox/trunk/ttk-gsoc/src/idlelib/configHandler.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/configHandler.py (original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/configHandler.py Mon Jul 14 20:37:24 2008
@@ -19,10 +19,10 @@
"""
import os
import sys
-import string
-import macosxSupport
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
+import macosxSupport
+
class InvalidConfigType(Exception): pass
class InvalidConfigSet(Exception): pass
class InvalidFgBg(Exception): pass
@@ -565,6 +565,7 @@
'<<center-insert>>': ['<Control-l>'],
'<<close-all-windows>>': ['<Control-q>'],
'<<close-window>>': ['<Alt-F4>'],
+ '<<close-tab>>': ['<Control-w>'],
'<<do-nothing>>': ['<Control-x>'],
'<<end-of-file>>': ['<Control-d>'],
'<<python-docs>>': ['<F1>'],
@@ -577,6 +578,7 @@
'<<open-class-browser>>': ['<Alt-c>'],
'<<open-module>>': ['<Alt-m>'],
'<<open-new-window>>': ['<Control-n>'],
+ '<<open-new-tab>>': ['<Control-t>'],
'<<open-window-from-file>>': ['<Control-o>'],
'<<plain-newline-and-indent>>': ['<Control-j>'],
'<<print-window>>': ['<Control-p>'],
@@ -649,7 +651,7 @@
menuItem='' #make these empty
helpPath='' #so value won't be added to list
else: #config entry contains ';' as expected
- value=string.split(value,';')
+ value = value.split(';')
menuItem=value[0].strip()
helpPath=value[1].strip()
if menuItem and helpPath: #neither are empty strings
Modified: sandbox/trunk/ttk-gsoc/src/idlelib/help.txt
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/help.txt (original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/help.txt Mon Jul 14 20:37:24 2008
@@ -6,6 +6,7 @@
File Menu:
New Window -- Create a new editing window
+ New Tab -- Create a new editing tab
Open... -- Open an existing file
Recent Files... -- Open a list of recent files
Open Module... -- Open an existing module (searches sys.path)
@@ -23,6 +24,7 @@
---
Print Window -- Print the current window
---
+ Close Tab -- Close current tab (asks to save if unsaved)
Close -- Close current window (asks to save if unsaved)
Exit -- Close all windows, quit (asks to save if unsaved)
More information about the Python-checkins
mailing list