[Python-checkins] r64894 - sandbox/trunk/ttk-gsoc/src/idlelib/EditorWindow.py
guilherme.polo
python-checkins at python.org
Sat Jul 12 17:49:00 CEST 2008
Author: guilherme.polo
Date: Sat Jul 12 17:49:00 2008
New Revision: 64894
Log:
Removed 'from Tkinter import *' usage;
Moved imports to top (except ColorDelegator import);
Reorganized imports;
Replaced itertools.count usage by enumerate;
Modified:
sandbox/trunk/ttk-gsoc/src/idlelib/EditorWindow.py
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 Sat Jul 12 17:49:00 2008
@@ -1,27 +1,36 @@
-import sys
import os
import re
+import sys
import imp
-from itertools import count
-from Tkinter import *
-import tkSimpleDialog
+import traceback
+import webbrowser
import tkMessageBox
-from MultiCall import MultiCallCreator
+import tkSimpleDialog
+from Tkinter import Frame, Text, Menu, Scrollbar, TclError, BooleanVar
+from Tkconstants import INSERT, END, RIGHT, BOTTOM, TOP, X, Y, BOTH, LEFT
-import webbrowser
import idlever
+import textView
+import aboutDialog
+import configDialog
+import macosxSupport
+import PyParse
+import Bindings
+import GrepDialog
import WindowList
+import PathBrowser
+import ClassBrowser
import SearchDialog
-import GrepDialog
import ReplaceDialog
-import PyParse
from configHandler import idleConf
-import aboutDialog, textView, configDialog
-import macosxSupport
+from MultiCall import MultiCallCreator
+from IOBinding import IOBinding, filesystemencoding, encoding
+from Percolator import Percolator
+from UndoDelegator import UndoDelegator
+from MultiStatusBar import MultiStatusBar
if idleConf.GetOption('main', 'General', 'use-ttk', type='int'):
- from ttk import Scrollbar
-
+ from ttk import Frame, Scrollbar
# The default tab setting for a Text widget, in average-width characters.
TK_TABWIDTH_DEFAULT = 8
@@ -44,14 +53,7 @@
return file, filename, descr
class EditorWindow(object):
- from Percolator import Percolator
from ColorDelegator import ColorDelegator
- from UndoDelegator import UndoDelegator
- from IOBinding import IOBinding, filesystemencoding, encoding
- import Bindings
- from Tkinter import Toplevel
- from MultiStatusBar import MultiStatusBar
-
help_url = None
def __init__(self, flist=None, filename=None, key=None, root=None):
@@ -218,16 +220,16 @@
# Making the initial values larger slows things down more often.
self.num_context_lines = 50, 500, 5000000
- self.per = per = self.Percolator(text)
+ self.per = per = Percolator(text)
- self.undo = undo = self.UndoDelegator()
+ self.undo = undo = UndoDelegator()
per.insertfilter(undo)
text.undo_block_start = undo.undo_block_start
text.undo_block_stop = undo.undo_block_stop
undo.set_saved_change_hook(self.saved_change_hook)
# IOBinding implements file I/O and printing functionality
- self.io = io = self.IOBinding(self)
+ self.io = io = IOBinding(self)
io.set_filename_change_hook(self.filename_change_hook)
# Create the recent files submenu
@@ -272,11 +274,11 @@
return filename
else:
try:
- return filename.decode(self.filesystemencoding)
+ return filename.decode(filesystemencoding)
except UnicodeDecodeError:
# XXX
try:
- return filename.decode(self.encoding)
+ return filename.decode(encoding)
except UnicodeDecodeError:
# byte-to-byte conversion
return filename.decode('iso8859-1')
@@ -331,7 +333,7 @@
return "break"
def set_status_bar(self):
- self.status_bar = self.MultiStatusBar(self.top)
+ self.status_bar = MultiStatusBar(self.top)
if macosxSupport.runningAsOSXApp():
# Insert some padding to avoid obscuring some of the statusbar
# by the resize widget.
@@ -567,11 +569,9 @@
return None
head, tail = os.path.split(filename)
base, ext = os.path.splitext(tail)
- import ClassBrowser
ClassBrowser.ClassBrowser(self.flist, base, [head])
def open_path_browser(self, event=None):
- import PathBrowser
PathBrowser.PathBrowser(self.flist)
def gotoline(self, lineno):
@@ -658,7 +658,7 @@
def RemoveKeybindings(self):
"Remove the keybindings before they are changed."
# Called from configDialog.py
- self.Bindings.default_keydefs = keydefs = idleConf.GetCurrentKeySet()
+ Bindings.default_keydefs = keydefs = idleConf.GetCurrentKeySet()
for event, keylist in keydefs.items():
self.text.event_delete(event, *keylist)
for extensionName in self.get_standard_extension_names():
@@ -670,7 +670,7 @@
def ApplyKeybindings(self):
"Update the keybindings after they are changed"
# Called from configDialog.py
- self.Bindings.default_keydefs = keydefs = idleConf.GetCurrentKeySet()
+ Bindings.default_keydefs = keydefs = idleConf.GetCurrentKeySet()
self.apply_bindings()
for extensionName in self.get_standard_extension_names():
xkeydefs = idleConf.GetExtensionBindings(extensionName)
@@ -678,7 +678,7 @@
self.apply_bindings(xkeydefs)
#update menu accelerators
menuEventDict = {}
- for menu in self.Bindings.menudefs:
+ for menu in Bindings.menudefs:
menuEventDict[menu[0]] = {}
for item in menu[1]:
if item:
@@ -765,7 +765,7 @@
for instance in self.top.instance_dict.keys():
menu = instance.recent_files_menu
menu.delete(1, END) # clear, and rebuild:
- for i, file in zip(count(), rf_list):
+ for i, file in enumerate(rf_list):
file_name = file[0:-1] # zap \n
# make unicode string to display non-ASCII chars correctly
ufile_name = self._filename_to_unicode(file_name)
@@ -903,7 +903,6 @@
self.load_extension(name)
except:
print "Failed to load extension", repr(name)
- import traceback
traceback.print_exc()
def get_standard_extension_names(self):
@@ -935,7 +934,7 @@
def apply_bindings(self, keydefs=None):
if keydefs is None:
- keydefs = self.Bindings.default_keydefs
+ keydefs = Bindings.default_keydefs
text = self.text
text.keydefs = keydefs
for event, keylist in keydefs.items():
@@ -948,9 +947,9 @@
Menus that are absent or None in self.menudict are ignored.
"""
if menudefs is None:
- menudefs = self.Bindings.menudefs
+ menudefs = Bindings.menudefs
if keydefs is None:
- keydefs = self.Bindings.default_keydefs
+ keydefs = Bindings.default_keydefs
menudict = self.menudict
text = self.text
for mname, entrylist in menudefs:
More information about the Python-checkins
mailing list