mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Whitespace Normalization
This commit is contained in:
parent
9532298c82
commit
6655e4bc27
23 changed files with 306 additions and 322 deletions
|
@ -37,7 +37,7 @@ class CallTip:
|
||||||
# This command is only needed and available on Tk >= 8.4.0 for OSX
|
# This command is only needed and available on Tk >= 8.4.0 for OSX
|
||||||
# Without it, call tips intrude on the typing process by grabbing
|
# Without it, call tips intrude on the typing process by grabbing
|
||||||
# the focus.
|
# the focus.
|
||||||
tw.tk.call("::tk::unsupported::MacWindowStyle", "style", tw._w,
|
tw.tk.call("::tk::unsupported::MacWindowStyle", "style", tw._w,
|
||||||
"help", "noActivates")
|
"help", "noActivates")
|
||||||
except TclError:
|
except TclError:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -81,10 +81,10 @@ class CallTips:
|
||||||
while i and str[i-1] in idchars:
|
while i and str[i-1] in idchars:
|
||||||
i -= 1
|
i -= 1
|
||||||
return str[i:]
|
return str[i:]
|
||||||
|
|
||||||
def fetch_tip(self, name):
|
def fetch_tip(self, name):
|
||||||
"""Return the argument list and docstring of a function or class
|
"""Return the argument list and docstring of a function or class
|
||||||
|
|
||||||
If there is a Python subprocess, get the calltip there. Otherwise,
|
If there is a Python subprocess, get the calltip there. Otherwise,
|
||||||
either fetch_tip() is running in the subprocess itself or it was called
|
either fetch_tip() is running in the subprocess itself or it was called
|
||||||
in an IDLE EditorWindow before any script had been run.
|
in an IDLE EditorWindow before any script had been run.
|
||||||
|
@ -93,7 +93,7 @@ class CallTips:
|
||||||
two unrelated modules are being edited some calltips in the current
|
two unrelated modules are being edited some calltips in the current
|
||||||
module may be inoperative if the module was not the last to run.
|
module may be inoperative if the module was not the last to run.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
rpcclt = self.editwin.flist.pyshell.interp.rpcclt
|
rpcclt = self.editwin.flist.pyshell.interp.rpcclt
|
||||||
except:
|
except:
|
||||||
|
@ -211,7 +211,7 @@ if __name__=='__main__':
|
||||||
print "%d of %d tests failed" % (len(failed), len(tests))
|
print "%d of %d tests failed" % (len(failed), len(tests))
|
||||||
|
|
||||||
tc = TC()
|
tc = TC()
|
||||||
tests = (t1, t2, t3, t4, t5, t6,
|
tests = (t1, t2, t3, t4, t5, t6,
|
||||||
TC, tc.t1, tc.t2, tc.t3, tc.t4, tc.t5, tc.t6)
|
TC, tc.t1, tc.t2, tc.t3, tc.t4, tc.t5, tc.t6)
|
||||||
|
|
||||||
test(tests)
|
test(tests)
|
||||||
|
|
|
@ -52,7 +52,7 @@ class ColorDelegator(Delegator):
|
||||||
if cnf:
|
if cnf:
|
||||||
apply(self.tag_configure, (tag,), cnf)
|
apply(self.tag_configure, (tag,), cnf)
|
||||||
self.tag_raise('sel')
|
self.tag_raise('sel')
|
||||||
|
|
||||||
def LoadTagDefs(self):
|
def LoadTagDefs(self):
|
||||||
theme = idleConf.GetOption('main','Theme','name')
|
theme = idleConf.GetOption('main','Theme','name')
|
||||||
self.tagdefs = {
|
self.tagdefs = {
|
||||||
|
@ -67,7 +67,7 @@ class ColorDelegator(Delegator):
|
||||||
# The following is used by ReplaceDialog:
|
# The following is used by ReplaceDialog:
|
||||||
"hit": idleConf.GetHighlight(theme, "hit"),
|
"hit": idleConf.GetHighlight(theme, "hit"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if DEBUG: print 'tagdefs',tagdefs
|
if DEBUG: print 'tagdefs',tagdefs
|
||||||
|
|
||||||
def insert(self, index, chars, tags=None):
|
def insert(self, index, chars, tags=None):
|
||||||
|
|
|
@ -15,17 +15,17 @@ class Idb(bdb.Bdb):
|
||||||
def user_line(self, frame):
|
def user_line(self, frame):
|
||||||
|
|
||||||
co_filename = frame.f_code.co_filename
|
co_filename = frame.f_code.co_filename
|
||||||
co_name = frame.f_code.co_name
|
co_name = frame.f_code.co_name
|
||||||
|
|
||||||
## print>>sys.__stderr__, "*function: ", frame.f_code.co_name
|
## print>>sys.__stderr__, "*function: ", frame.f_code.co_name
|
||||||
## print>>sys.__stderr__, "*file: ", frame.f_code.co_filename
|
## print>>sys.__stderr__, "*file: ", frame.f_code.co_filename
|
||||||
## print>>sys.__stderr__, "*line number: ", frame.f_code.co_firstlineno
|
## print>>sys.__stderr__, "*line number: ", frame.f_code.co_firstlineno
|
||||||
## print>>sys.__stderr__, "*name: ", co_name
|
## print>>sys.__stderr__, "*name: ", co_name
|
||||||
## print>>sys.__stderr__, "*function: ", frame.f_locals.get(co_name,None)
|
## print>>sys.__stderr__, "*function: ", frame.f_locals.get(co_name,None)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# XXX 12 Dec 2002 CGT TO DO: Find way to get a reference to the
|
# XXX 12 Dec 2002 CGT TO DO: Find way to get a reference to the
|
||||||
# XXX currently running function. If the function has an
|
# XXX currently running function. If the function has an
|
||||||
# attribute called "DebuggerStepThrough", prevent the debugger
|
# attribute called "DebuggerStepThrough", prevent the debugger
|
||||||
# from stepping through Idle code. The following doesn't work
|
# from stepping through Idle code. The following doesn't work
|
||||||
# in instance methods. Hard coded some workarounds.
|
# in instance methods. Hard coded some workarounds.
|
||||||
|
@ -75,7 +75,7 @@ class Debugger:
|
||||||
self.frame = None
|
self.frame = None
|
||||||
self.make_gui()
|
self.make_gui()
|
||||||
self.interacting = 0
|
self.interacting = 0
|
||||||
|
|
||||||
def run(self, *args):
|
def run(self, *args):
|
||||||
try:
|
try:
|
||||||
self.interacting = 1
|
self.interacting = 1
|
||||||
|
|
|
@ -111,7 +111,7 @@ class EditorWindow:
|
||||||
text.bind("<<untabify-region>>",self.untabify_region_event)
|
text.bind("<<untabify-region>>",self.untabify_region_event)
|
||||||
text.bind("<<toggle-tabs>>",self.toggle_tabs_event)
|
text.bind("<<toggle-tabs>>",self.toggle_tabs_event)
|
||||||
text.bind("<<change-indentwidth>>",self.change_indentwidth_event)
|
text.bind("<<change-indentwidth>>",self.change_indentwidth_event)
|
||||||
|
|
||||||
if flist:
|
if flist:
|
||||||
flist.inversedict[self] = key
|
flist.inversedict[self] = key
|
||||||
if key:
|
if key:
|
||||||
|
@ -186,7 +186,7 @@ class EditorWindow:
|
||||||
if self.extensions.has_key('AutoIndent'):
|
if self.extensions.has_key('AutoIndent'):
|
||||||
self.extensions['AutoIndent'].set_indentation_params(
|
self.extensions['AutoIndent'].set_indentation_params(
|
||||||
self.ispythonsource(filename))
|
self.ispythonsource(filename))
|
||||||
|
|
||||||
def set_status_bar(self):
|
def set_status_bar(self):
|
||||||
self.status_bar = self.MultiStatusBar(self.top)
|
self.status_bar = self.MultiStatusBar(self.top)
|
||||||
self.status_bar.set_label('column', 'Col: ?', side=RIGHT)
|
self.status_bar.set_label('column', 'Col: ?', side=RIGHT)
|
||||||
|
@ -273,21 +273,21 @@ class EditorWindow:
|
||||||
|
|
||||||
def about_dialog(self, event=None):
|
def about_dialog(self, event=None):
|
||||||
aboutDialog.AboutDialog(self.top,'About IDLEfork')
|
aboutDialog.AboutDialog(self.top,'About IDLEfork')
|
||||||
|
|
||||||
def config_dialog(self, event=None):
|
def config_dialog(self, event=None):
|
||||||
configDialog.ConfigDialog(self.top,'Settings')
|
configDialog.ConfigDialog(self.top,'Settings')
|
||||||
|
|
||||||
def good_advice(self, event=None):
|
def good_advice(self, event=None):
|
||||||
tkMessageBox.showinfo('Advice', "Don't Panic!", master=self.text)
|
tkMessageBox.showinfo('Advice', "Don't Panic!", master=self.text)
|
||||||
|
|
||||||
def view_readme(self, event=None):
|
def view_readme(self, event=None):
|
||||||
fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'README.txt')
|
fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'README.txt')
|
||||||
textView.TextViewer(self.top,'IDLEfork - README',fn)
|
textView.TextViewer(self.top,'IDLEfork - README',fn)
|
||||||
|
|
||||||
def help_dialog(self, event=None):
|
def help_dialog(self, event=None):
|
||||||
fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt')
|
fn=os.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt')
|
||||||
textView.TextViewer(self.top,'Help',fn)
|
textView.TextViewer(self.top,'Help',fn)
|
||||||
|
|
||||||
help_url = "http://www.python.org/doc/current/"
|
help_url = "http://www.python.org/doc/current/"
|
||||||
if sys.platform[:3] == "win":
|
if sys.platform[:3] == "win":
|
||||||
fn = os.path.dirname(__file__)
|
fn = os.path.dirname(__file__)
|
||||||
|
@ -469,7 +469,7 @@ class EditorWindow:
|
||||||
self.per.removefilter(self.color)
|
self.per.removefilter(self.color)
|
||||||
self.color = None
|
self.color = None
|
||||||
self.per.insertfilter(self.undo)
|
self.per.insertfilter(self.undo)
|
||||||
|
|
||||||
def ResetColorizer(self):
|
def ResetColorizer(self):
|
||||||
"Update the colour theme if it is changed"
|
"Update the colour theme if it is changed"
|
||||||
# Called from configDialog.py
|
# Called from configDialog.py
|
||||||
|
@ -478,7 +478,7 @@ class EditorWindow:
|
||||||
self.per.insertfilter(self.color)
|
self.per.insertfilter(self.color)
|
||||||
|
|
||||||
def ResetFont(self):
|
def ResetFont(self):
|
||||||
"Update the text widgets' font if it is changed"
|
"Update the text widgets' font if it is changed"
|
||||||
# Called from configDialog.py
|
# Called from configDialog.py
|
||||||
fontWeight='normal'
|
fontWeight='normal'
|
||||||
if idleConf.GetOption('main','EditorWindow','font-bold',type='bool'):
|
if idleConf.GetOption('main','EditorWindow','font-bold',type='bool'):
|
||||||
|
@ -535,15 +535,15 @@ class EditorWindow:
|
||||||
self.menuExtraHelp.add_command(label=menuItem[0],
|
self.menuExtraHelp.add_command(label=menuItem[0],
|
||||||
command=self.__DisplayExtraHelpCallback(menuItem[1]))
|
command=self.__DisplayExtraHelpCallback(menuItem[1]))
|
||||||
else: #no extra help items
|
else: #no extra help items
|
||||||
if hasattr(self,'menuExtraHelp'):
|
if hasattr(self,'menuExtraHelp'):
|
||||||
helpMenu.delete(cascadeIndex-1)
|
helpMenu.delete(cascadeIndex-1)
|
||||||
del(self.menuExtraHelp)
|
del(self.menuExtraHelp)
|
||||||
|
|
||||||
def __DisplayExtraHelpCallback(self,helpFile):
|
def __DisplayExtraHelpCallback(self,helpFile):
|
||||||
def DisplayExtraHelp(helpFile=helpFile):
|
def DisplayExtraHelp(helpFile=helpFile):
|
||||||
self.display_docs(helpFile)
|
self.display_docs(helpFile)
|
||||||
return DisplayExtraHelp
|
return DisplayExtraHelp
|
||||||
|
|
||||||
def UpdateRecentFilesList(self,newFile=None):
|
def UpdateRecentFilesList(self,newFile=None):
|
||||||
"Load or update the recent files list, and menu if required"
|
"Load or update the recent files list, and menu if required"
|
||||||
rfList=[]
|
rfList=[]
|
||||||
|
@ -553,7 +553,7 @@ class EditorWindow:
|
||||||
rfList=RFfile.readlines()
|
rfList=RFfile.readlines()
|
||||||
finally:
|
finally:
|
||||||
RFfile.close()
|
RFfile.close()
|
||||||
if newFile:
|
if newFile:
|
||||||
newFile=os.path.abspath(newFile)+'\n'
|
newFile=os.path.abspath(newFile)+'\n'
|
||||||
if newFile in rfList:
|
if newFile in rfList:
|
||||||
rfList.remove(newFile)
|
rfList.remove(newFile)
|
||||||
|
@ -567,7 +567,7 @@ class EditorWindow:
|
||||||
for instance in self.top.instanceDict.keys():
|
for instance in self.top.instanceDict.keys():
|
||||||
menu = instance.menuRecentFiles
|
menu = instance.menuRecentFiles
|
||||||
menu.delete(1,END)
|
menu.delete(1,END)
|
||||||
i = 0 ; ul = 0; ullen = len(ullist)
|
i = 0 ; ul = 0; ullen = len(ullist)
|
||||||
for file in rfList:
|
for file in rfList:
|
||||||
fileName=file[0:-1]
|
fileName=file[0:-1]
|
||||||
callback = instance.__RecentFileCallback(fileName)
|
callback = instance.__RecentFileCallback(fileName)
|
||||||
|
@ -577,13 +577,13 @@ class EditorWindow:
|
||||||
command=callback,
|
command=callback,
|
||||||
underline=ul)
|
underline=ul)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
def __CleanRecentFiles(self,rfList):
|
def __CleanRecentFiles(self,rfList):
|
||||||
origRfList=rfList[:]
|
origRfList=rfList[:]
|
||||||
count=0
|
count=0
|
||||||
nonFiles=[]
|
nonFiles=[]
|
||||||
for path in rfList:
|
for path in rfList:
|
||||||
if not os.path.exists(path[0:-1]):
|
if not os.path.exists(path[0:-1]):
|
||||||
nonFiles.append(count)
|
nonFiles.append(count)
|
||||||
count=count+1
|
count=count+1
|
||||||
if nonFiles:
|
if nonFiles:
|
||||||
|
@ -599,12 +599,12 @@ class EditorWindow:
|
||||||
finally:
|
finally:
|
||||||
RFfile.close()
|
RFfile.close()
|
||||||
return rfList
|
return rfList
|
||||||
|
|
||||||
def __RecentFileCallback(self,fileName):
|
def __RecentFileCallback(self,fileName):
|
||||||
def OpenRecentFile(fileName=fileName):
|
def OpenRecentFile(fileName=fileName):
|
||||||
self.io.open(editFile=fileName)
|
self.io.open(editFile=fileName)
|
||||||
return OpenRecentFile
|
return OpenRecentFile
|
||||||
|
|
||||||
def saved_change_hook(self):
|
def saved_change_hook(self):
|
||||||
short = self.short_title()
|
short = self.short_title()
|
||||||
long = self.long_title()
|
long = self.long_title()
|
||||||
|
@ -672,7 +672,7 @@ class EditorWindow:
|
||||||
def maybesave(self):
|
def maybesave(self):
|
||||||
if self.io:
|
if self.io:
|
||||||
if not self.get_saved():
|
if not self.get_saved():
|
||||||
if self.top.state()!='normal':
|
if self.top.state()!='normal':
|
||||||
self.top.deiconify()
|
self.top.deiconify()
|
||||||
self.top.lower()
|
self.top.lower()
|
||||||
self.top.lift()
|
self.top.lift()
|
||||||
|
|
|
@ -103,7 +103,7 @@ class IOBinding:
|
||||||
self.save_a_copy)
|
self.save_a_copy)
|
||||||
self.fileencoding = None
|
self.fileencoding = None
|
||||||
self.__id_print = self.text.bind("<<print-window>>", self.print_window)
|
self.__id_print = self.text.bind("<<print-window>>", self.print_window)
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
# Undo command bindings
|
# Undo command bindings
|
||||||
self.text.unbind("<<open-window-from-file>>", self.__id_open)
|
self.text.unbind("<<open-window-from-file>>", self.__id_open)
|
||||||
|
@ -366,7 +366,7 @@ class IOBinding:
|
||||||
"# -*- coding: %s -*- \nto your file" % enc,
|
"# -*- coding: %s -*- \nto your file" % enc,
|
||||||
master = self.text)
|
master = self.text)
|
||||||
return chars
|
return chars
|
||||||
|
|
||||||
def fixlastline(self):
|
def fixlastline(self):
|
||||||
c = self.text.get("end-2c")
|
c = self.text.get("end-2c")
|
||||||
if c != '\n':
|
if c != '\n':
|
||||||
|
@ -403,10 +403,10 @@ class IOBinding:
|
||||||
output = "Printing command: %s\n" % repr(command) + output
|
output = "Printing command: %s\n" % repr(command) + output
|
||||||
tkMessageBox.showerror("Print status", output, master=self.text)
|
tkMessageBox.showerror("Print status", output, master=self.text)
|
||||||
else: #no printing for this platform
|
else: #no printing for this platform
|
||||||
message="Printing is not enabled for this platform: %s" % platform
|
message="Printing is not enabled for this platform: %s" % platform
|
||||||
tkMessageBox.showinfo("Print status", message, master=self.text)
|
tkMessageBox.showinfo("Print status", message, master=self.text)
|
||||||
return "break"
|
return "break"
|
||||||
|
|
||||||
opendialog = None
|
opendialog = None
|
||||||
savedialog = None
|
savedialog = None
|
||||||
|
|
||||||
|
|
|
@ -146,10 +146,3 @@ class OnDemandOutputWindow:
|
||||||
|
|
||||||
# def flush(self):
|
# def flush(self):
|
||||||
# pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ def extended_linecache_checkcache(orig_checkcache=linecache.checkcache):
|
||||||
save[filename] = cache[filename]
|
save[filename] = cache[filename]
|
||||||
orig_checkcache()
|
orig_checkcache()
|
||||||
cache.update(save)
|
cache.update(save)
|
||||||
|
|
||||||
# Patch linecache.checkcache():
|
# Patch linecache.checkcache():
|
||||||
linecache.checkcache = extended_linecache_checkcache
|
linecache.checkcache = extended_linecache_checkcache
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ class PyShellEditorWindow(EditorWindow):
|
||||||
lines = open(self.breakpointPath,"r").readlines()
|
lines = open(self.breakpointPath,"r").readlines()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line.startswith(filename + '='):
|
if line.startswith(filename + '='):
|
||||||
breakpoint_linenumbers = eval(line[len(filename)+1:])
|
breakpoint_linenumbers = eval(line[len(filename)+1:])
|
||||||
for breakpoint_linenumber in breakpoint_linenumbers:
|
for breakpoint_linenumber in breakpoint_linenumbers:
|
||||||
self.set_breakpoint(breakpoint_linenumber)
|
self.set_breakpoint(breakpoint_linenumber)
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ class PyShellEditorWindow(EditorWindow):
|
||||||
"Extend base method - clear breaks when module is closed"
|
"Extend base method - clear breaks when module is closed"
|
||||||
self.clear_file_breaks()
|
self.clear_file_breaks()
|
||||||
EditorWindow._close(self)
|
EditorWindow._close(self)
|
||||||
|
|
||||||
|
|
||||||
class PyShellFileList(FileList):
|
class PyShellFileList(FileList):
|
||||||
"Extend base class: file list when a shell is present"
|
"Extend base class: file list when a shell is present"
|
||||||
|
@ -246,7 +246,7 @@ class PyShellFileList(FileList):
|
||||||
|
|
||||||
class ModifiedColorDelegator(ColorDelegator):
|
class ModifiedColorDelegator(ColorDelegator):
|
||||||
"Extend base class: colorizer for the shell window itself"
|
"Extend base class: colorizer for the shell window itself"
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
ColorDelegator.__init__(self)
|
ColorDelegator.__init__(self)
|
||||||
self.LoadTagDefs()
|
self.LoadTagDefs()
|
||||||
|
@ -255,7 +255,7 @@ class ModifiedColorDelegator(ColorDelegator):
|
||||||
self.tag_remove("TODO", "1.0", "iomark")
|
self.tag_remove("TODO", "1.0", "iomark")
|
||||||
self.tag_add("SYNC", "1.0", "iomark")
|
self.tag_add("SYNC", "1.0", "iomark")
|
||||||
ColorDelegator.recolorize_main(self)
|
ColorDelegator.recolorize_main(self)
|
||||||
|
|
||||||
def LoadTagDefs(self):
|
def LoadTagDefs(self):
|
||||||
ColorDelegator.LoadTagDefs(self)
|
ColorDelegator.LoadTagDefs(self)
|
||||||
theme = idleConf.GetOption('main','Theme','name')
|
theme = idleConf.GetOption('main','Theme','name')
|
||||||
|
@ -300,7 +300,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
||||||
rpcclt = None
|
rpcclt = None
|
||||||
rpcpid = None
|
rpcpid = None
|
||||||
|
|
||||||
def spawn_subprocess(self):
|
def spawn_subprocess(self):
|
||||||
args = self.build_subprocess_arglist()
|
args = self.build_subprocess_arglist()
|
||||||
self.rpcpid = os.spawnv(os.P_NOWAIT, args[0], args)
|
self.rpcpid = os.spawnv(os.P_NOWAIT, args[0], args)
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
||||||
# here are the applet architectures tried:
|
# here are the applet architectures tried:
|
||||||
#
|
#
|
||||||
# framework applet: sys.executable + -p is correct
|
# framework applet: sys.executable + -p is correct
|
||||||
# python 2.2 + pure python main applet:
|
# python 2.2 + pure python main applet:
|
||||||
# sys.executable + -p is correct
|
# sys.executable + -p is correct
|
||||||
# pythonw idle.py: sys.executable + -c is correct
|
# pythonw idle.py: sys.executable + -c is correct
|
||||||
#
|
#
|
||||||
|
@ -360,7 +360,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
||||||
# close only the subprocess debugger
|
# close only the subprocess debugger
|
||||||
debug = self.getdebugger()
|
debug = self.getdebugger()
|
||||||
if debug:
|
if debug:
|
||||||
RemoteDebugger.close_subprocess_debugger(self.rpcclt)
|
RemoteDebugger.close_subprocess_debugger(self.rpcclt)
|
||||||
# kill subprocess, spawn a new one, accept connection
|
# kill subprocess, spawn a new one, accept connection
|
||||||
self.rpcclt.close()
|
self.rpcclt.close()
|
||||||
self.spawn_subprocess()
|
self.spawn_subprocess()
|
||||||
|
@ -434,7 +434,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
||||||
while tb:
|
while tb:
|
||||||
for rpcfile in exclude:
|
for rpcfile in exclude:
|
||||||
if tb[-1][0].count(rpcfile):
|
if tb[-1][0].count(rpcfile):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
break
|
break
|
||||||
del tb[-1]
|
del tb[-1]
|
||||||
|
@ -525,7 +525,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
||||||
lines = source.split("\n")
|
lines = source.split("\n")
|
||||||
linecache.cache[filename] = len(source)+1, 0, lines, filename
|
linecache.cache[filename] = len(source)+1, 0, lines, filename
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
def showsyntaxerror(self, filename=None):
|
def showsyntaxerror(self, filename=None):
|
||||||
"""Extend base class method: Add Colorizing
|
"""Extend base class method: Add Colorizing
|
||||||
|
|
||||||
|
@ -587,7 +587,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
|
||||||
"The Python Shell window is already executing a command; "
|
"The Python Shell window is already executing a command; "
|
||||||
"please wait until it is finished.",
|
"please wait until it is finished.",
|
||||||
master=self.tkconsole.text)
|
master=self.tkconsole.text)
|
||||||
|
|
||||||
def runcommand(self, code):
|
def runcommand(self, code):
|
||||||
"Run the code without invoking the debugger"
|
"Run the code without invoking the debugger"
|
||||||
# The code better not raise an exception!
|
# The code better not raise an exception!
|
||||||
|
@ -1075,10 +1075,10 @@ class PseudoFile:
|
||||||
|
|
||||||
usage_msg = """\
|
usage_msg = """\
|
||||||
|
|
||||||
USAGE: idle [-deis] [-t title] [file]*
|
USAGE: idle [-deis] [-t title] [file]*
|
||||||
idle [-ds] [-t title] (-c cmd | -r file) [arg]*
|
idle [-ds] [-t title] (-c cmd | -r file) [arg]*
|
||||||
idle [-ds] [-t title] - [arg]*
|
idle [-ds] [-t title] - [arg]*
|
||||||
|
|
||||||
-h print this help message and exit
|
-h print this help message and exit
|
||||||
|
|
||||||
The following options will override the IDLE 'settings' configuration:
|
The following options will override the IDLE 'settings' configuration:
|
||||||
|
@ -1175,7 +1175,7 @@ def main():
|
||||||
if args and args[0] == '-':
|
if args and args[0] == '-':
|
||||||
cmd = sys.stdin.read()
|
cmd = sys.stdin.read()
|
||||||
enable_shell = True
|
enable_shell = True
|
||||||
|
|
||||||
use_subprocess = True
|
use_subprocess = True
|
||||||
|
|
||||||
# process sys.argv and sys.path:
|
# process sys.argv and sys.path:
|
||||||
|
@ -1202,9 +1202,9 @@ def main():
|
||||||
sys.path.insert(0, dir)
|
sys.path.insert(0, dir)
|
||||||
# check the IDLE settings configuration (but command line overrides)
|
# check the IDLE settings configuration (but command line overrides)
|
||||||
edit_start = idleConf.GetOption('main', 'General',
|
edit_start = idleConf.GetOption('main', 'General',
|
||||||
'editor-on-startup', type='bool')
|
'editor-on-startup', type='bool')
|
||||||
enable_edit = enable_edit or edit_start
|
enable_edit = enable_edit or edit_start
|
||||||
enable_shell = enable_shell or not edit_start
|
enable_shell = enable_shell or not edit_start
|
||||||
# start editor and/or shell windows:
|
# start editor and/or shell windows:
|
||||||
root = Tk(className="Idle")
|
root = Tk(className="Idle")
|
||||||
fixwordbreaks(root)
|
fixwordbreaks(root)
|
||||||
|
@ -1258,7 +1258,7 @@ start. Here are some possible causes of this problem:
|
||||||
3. Personal firewall software is preventing IDLE from using this port
|
3. Personal firewall software is preventing IDLE from using this port
|
||||||
|
|
||||||
IDLE makes and accepts connections only with this computer, and does not
|
IDLE makes and accepts connections only with this computer, and does not
|
||||||
communicate over the internet in any way. Its use of port 8833 should not
|
communicate over the internet in any way. Its use of port 8833 should not
|
||||||
be a security risk on a single-user machine.
|
be a security risk on a single-user machine.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
|
@ -121,7 +121,7 @@ class IdbAdapter:
|
||||||
def clear_all_file_breaks(self, filename):
|
def clear_all_file_breaks(self, filename):
|
||||||
msg = self.idb.clear_all_file_breaks(filename)
|
msg = self.idb.clear_all_file_breaks(filename)
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
#----------called by a FrameProxy----------
|
#----------called by a FrameProxy----------
|
||||||
|
|
||||||
def frame_attr(self, fid, name):
|
def frame_attr(self, fid, name):
|
||||||
|
@ -366,7 +366,7 @@ def close_remote_debugger(rpcclt):
|
||||||
debugger and RPC link objects. (The second reference to the debugger GUI
|
debugger and RPC link objects. (The second reference to the debugger GUI
|
||||||
is deleted in PyShell.close_remote_debugger().)
|
is deleted in PyShell.close_remote_debugger().)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
close_subprocess_debugger(rpcclt)
|
close_subprocess_debugger(rpcclt)
|
||||||
rpcclt.unregister(gui_adap_oid)
|
rpcclt.unregister(gui_adap_oid)
|
||||||
|
|
||||||
|
@ -377,4 +377,3 @@ def restart_subprocess_debugger(rpcclt):
|
||||||
idb_adap_oid_ret = rpcclt.remotecall("exec", "start_the_debugger",\
|
idb_adap_oid_ret = rpcclt.remotecall("exec", "start_the_debugger",\
|
||||||
(gui_adap_oid,), {})
|
(gui_adap_oid,), {})
|
||||||
assert idb_adap_oid_ret == idb_adap_oid, 'Idb restarted with different oid'
|
assert idb_adap_oid_ret == idb_adap_oid, 'Idb restarted with different oid'
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ class ScriptBinding:
|
||||||
self.errorbox("Syntax error",
|
self.errorbox("Syntax error",
|
||||||
"There's an error in your program:\n" + msg)
|
"There's an error in your program:\n" + msg)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def colorize_syntax_error(self, msg, lineno, offset):
|
def colorize_syntax_error(self, msg, lineno, offset):
|
||||||
text = self.editwin.text
|
text = self.editwin.text
|
||||||
pos = "0.0 + %d lines + %d chars" % (lineno-1, offset-1)
|
pos = "0.0 + %d lines + %d chars" % (lineno-1, offset-1)
|
||||||
|
@ -112,7 +112,7 @@ class ScriptBinding:
|
||||||
else:
|
else:
|
||||||
text.mark_set("insert", pos + "+1c")
|
text.mark_set("insert", pos + "+1c")
|
||||||
text.see(pos)
|
text.see(pos)
|
||||||
|
|
||||||
def run_script_event(self, event):
|
def run_script_event(self, event):
|
||||||
"Check syntax, if ok run the script in the shell top level"
|
"Check syntax, if ok run the script in the shell top level"
|
||||||
filename = self.getfilename()
|
filename = self.getfilename()
|
||||||
|
|
|
@ -10,7 +10,7 @@ class ZoomHeight:
|
||||||
('_Zoom Height', '<<zoom-height>>'),
|
('_Zoom Height', '<<zoom-height>>'),
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, editwin):
|
def __init__(self, editwin):
|
||||||
self.editwin = editwin
|
self.editwin = editwin
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ def zoom_height(top):
|
||||||
#newy = 24
|
#newy = 24
|
||||||
newy = 0
|
newy = 0
|
||||||
#newheight = newheight - 96
|
#newheight = newheight - 96
|
||||||
newheight = newheight - 88
|
newheight = newheight - 88
|
||||||
if height >= newheight:
|
if height >= newheight:
|
||||||
newgeom = ""
|
newgeom = ""
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -10,7 +10,7 @@ import idlever
|
||||||
class AboutDialog(Toplevel):
|
class AboutDialog(Toplevel):
|
||||||
"""
|
"""
|
||||||
modal about dialog for idle
|
modal about dialog for idle
|
||||||
"""
|
"""
|
||||||
def __init__(self,parent,title):
|
def __init__(self,parent,title):
|
||||||
Toplevel.__init__(self, parent)
|
Toplevel.__init__(self, parent)
|
||||||
self.configure(borderwidth=5)
|
self.configure(borderwidth=5)
|
||||||
|
@ -18,7 +18,7 @@ class AboutDialog(Toplevel):
|
||||||
parent.winfo_rooty()+30))
|
parent.winfo_rooty()+30))
|
||||||
self.bg="#707070"
|
self.bg="#707070"
|
||||||
self.fg="#ffffff"
|
self.fg="#ffffff"
|
||||||
|
|
||||||
self.CreateWidgets()
|
self.CreateWidgets()
|
||||||
self.resizable(height=FALSE,width=FALSE)
|
self.resizable(height=FALSE,width=FALSE)
|
||||||
self.title(title)
|
self.title(title)
|
||||||
|
@ -33,7 +33,7 @@ class AboutDialog(Toplevel):
|
||||||
self.bind('<Return>',self.Ok) #dismiss dialog
|
self.bind('<Return>',self.Ok) #dismiss dialog
|
||||||
self.bind('<Escape>',self.Ok) #dismiss dialog
|
self.bind('<Escape>',self.Ok) #dismiss dialog
|
||||||
self.wait_window()
|
self.wait_window()
|
||||||
|
|
||||||
def CreateWidgets(self):
|
def CreateWidgets(self):
|
||||||
frameMain = Frame(self,borderwidth=2,relief=SUNKEN)
|
frameMain = Frame(self,borderwidth=2,relief=SUNKEN)
|
||||||
frameButtons = Frame(self)
|
frameButtons = Frame(self)
|
||||||
|
@ -83,7 +83,7 @@ class AboutDialog(Toplevel):
|
||||||
#handle weird tk version num in windoze python >= 1.6 (?!?)
|
#handle weird tk version num in windoze python >= 1.6 (?!?)
|
||||||
tkVer = `TkVersion`.split('.')
|
tkVer = `TkVersion`.split('.')
|
||||||
tkVer[len(tkVer)-1] = str('%.3g' % (float('.'+tkVer[len(tkVer)-1])))[2:]
|
tkVer[len(tkVer)-1] = str('%.3g' % (float('.'+tkVer[len(tkVer)-1])))[2:]
|
||||||
if tkVer[len(tkVer)-1] == '':
|
if tkVer[len(tkVer)-1] == '':
|
||||||
tkVer[len(tkVer)-1] = '0'
|
tkVer[len(tkVer)-1] = '0'
|
||||||
tkVer = string.join(tkVer,'.')
|
tkVer = string.join(tkVer,'.')
|
||||||
labelTkVer = Label(frameBg,text='Tk version: '+
|
labelTkVer = Label(frameBg,text='Tk version: '+
|
||||||
|
@ -105,7 +105,7 @@ class AboutDialog(Toplevel):
|
||||||
|
|
||||||
def ShowLicense(self):
|
def ShowLicense(self):
|
||||||
self.ViewFile('About - License','LICENSE.txt')
|
self.ViewFile('About - License','LICENSE.txt')
|
||||||
|
|
||||||
def ShowCredits(self):
|
def ShowCredits(self):
|
||||||
self.ViewFile('About - Credits','CREDITS.txt')
|
self.ViewFile('About - Credits','CREDITS.txt')
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ class AboutDialog(Toplevel):
|
||||||
|
|
||||||
def Ok(self, event=None):
|
def Ok(self, event=None):
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#test the dialog
|
#test the dialog
|
||||||
root=Tk()
|
root=Tk()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"boolcheck - import this module to ensure True, False, bool() builtins exist."
|
"boolcheck - import this module to ensure True, False, bool() builtins exist."
|
||||||
try:
|
try:
|
||||||
True
|
True
|
||||||
except NameError:
|
except NameError:
|
||||||
import __builtin__
|
import __builtin__
|
||||||
|
@ -7,4 +7,3 @@ except NameError:
|
||||||
__builtin__.False = 0
|
__builtin__.False = 0
|
||||||
from operator import truth
|
from operator import truth
|
||||||
__builtin__.bool = truth
|
__builtin__.bool = truth
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ from configHelpSourceEdit import GetHelpSourceDialog
|
||||||
class ConfigDialog(Toplevel):
|
class ConfigDialog(Toplevel):
|
||||||
"""
|
"""
|
||||||
configuration dialog for idle
|
configuration dialog for idle
|
||||||
"""
|
"""
|
||||||
def __init__(self,parent,title):
|
def __init__(self,parent,title):
|
||||||
Toplevel.__init__(self, parent)
|
Toplevel.__init__(self, parent)
|
||||||
self.configure(borderwidth=5)
|
self.configure(borderwidth=5)
|
||||||
|
@ -22,7 +22,7 @@ class ConfigDialog(Toplevel):
|
||||||
parent.winfo_rooty()+30))
|
parent.winfo_rooty()+30))
|
||||||
#Theme Elements. Each theme element key is it's display name.
|
#Theme Elements. Each theme element key is it's display name.
|
||||||
#The first value of the tuple is the sample area tag name.
|
#The first value of the tuple is the sample area tag name.
|
||||||
#The second value is the display name list sort index.
|
#The second value is the display name list sort index.
|
||||||
self.themeElements={'Normal Text':('normal','00'),
|
self.themeElements={'Normal Text':('normal','00'),
|
||||||
'Python Keywords':('keyword','01'),
|
'Python Keywords':('keyword','01'),
|
||||||
'Python Definitions':('definition','02'),
|
'Python Definitions':('definition','02'),
|
||||||
|
@ -48,9 +48,9 @@ class ConfigDialog(Toplevel):
|
||||||
#self.bind('<Alt-a>',self.Apply) #apply changes, save
|
#self.bind('<Alt-a>',self.Apply) #apply changes, save
|
||||||
#self.bind('<F1>',self.Help) #context help
|
#self.bind('<F1>',self.Help) #context help
|
||||||
self.LoadConfigs()
|
self.LoadConfigs()
|
||||||
self.AttachVarCallbacks() #avoid callbacks during LoadConfigs
|
self.AttachVarCallbacks() #avoid callbacks during LoadConfigs
|
||||||
self.wait_window()
|
self.wait_window()
|
||||||
|
|
||||||
def CreateWidgets(self):
|
def CreateWidgets(self):
|
||||||
self.tabPages = TabPageSet(self,
|
self.tabPages = TabPageSet(self,
|
||||||
pageNames=['Fonts/Tabs','Highlighting','Keys','General'])
|
pageNames=['Fonts/Tabs','Highlighting','Keys','General'])
|
||||||
|
@ -75,7 +75,7 @@ class ConfigDialog(Toplevel):
|
||||||
self.buttonCancel.pack(side=LEFT,padx=5,pady=5)
|
self.buttonCancel.pack(side=LEFT,padx=5,pady=5)
|
||||||
frameActionButtons.pack(side=BOTTOM)
|
frameActionButtons.pack(side=BOTTOM)
|
||||||
self.tabPages.pack(side=TOP,expand=TRUE,fill=BOTH)
|
self.tabPages.pack(side=TOP,expand=TRUE,fill=BOTH)
|
||||||
|
|
||||||
def CreatePageFontTab(self):
|
def CreatePageFontTab(self):
|
||||||
#tkVars
|
#tkVars
|
||||||
self.fontSize=StringVar(self)
|
self.fontSize=StringVar(self)
|
||||||
|
@ -83,7 +83,7 @@ class ConfigDialog(Toplevel):
|
||||||
self.fontName=StringVar(self)
|
self.fontName=StringVar(self)
|
||||||
self.spaceNum=IntVar(self)
|
self.spaceNum=IntVar(self)
|
||||||
#self.tabCols=IntVar(self)
|
#self.tabCols=IntVar(self)
|
||||||
self.indentBySpaces=BooleanVar(self)
|
self.indentBySpaces=BooleanVar(self)
|
||||||
self.editFont=tkFont.Font(self,('courier',12,'normal'))
|
self.editFont=tkFont.Font(self,('courier',12,'normal'))
|
||||||
##widget creation
|
##widget creation
|
||||||
#body frame
|
#body frame
|
||||||
|
@ -168,7 +168,7 @@ class ConfigDialog(Toplevel):
|
||||||
self.fgHilite=BooleanVar(self)
|
self.fgHilite=BooleanVar(self)
|
||||||
self.colour=StringVar(self)
|
self.colour=StringVar(self)
|
||||||
self.fontName=StringVar(self)
|
self.fontName=StringVar(self)
|
||||||
self.themeIsBuiltin=BooleanVar(self)
|
self.themeIsBuiltin=BooleanVar(self)
|
||||||
self.highlightTarget=StringVar(self)
|
self.highlightTarget=StringVar(self)
|
||||||
##widget creation
|
##widget creation
|
||||||
#body frame
|
#body frame
|
||||||
|
@ -194,7 +194,7 @@ class ConfigDialog(Toplevel):
|
||||||
(' ','normal'),('stderr','stderr'),('\n','normal'))
|
(' ','normal'),('stderr','stderr'),('\n','normal'))
|
||||||
for txTa in textAndTags:
|
for txTa in textAndTags:
|
||||||
text.insert(END,txTa[0],txTa[1])
|
text.insert(END,txTa[0],txTa[1])
|
||||||
for element in self.themeElements.keys():
|
for element in self.themeElements.keys():
|
||||||
text.tag_bind(self.themeElements[element][0],'<ButtonPress-1>',
|
text.tag_bind(self.themeElements[element][0],'<ButtonPress-1>',
|
||||||
lambda event,elem=element: event.widget.winfo_toplevel()
|
lambda event,elem=element: event.widget.winfo_toplevel()
|
||||||
.highlightTarget.set(elem))
|
.highlightTarget.set(elem))
|
||||||
|
@ -211,7 +211,7 @@ class ConfigDialog(Toplevel):
|
||||||
self.radioBg=Radiobutton(frameFgBg,variable=self.fgHilite,
|
self.radioBg=Radiobutton(frameFgBg,variable=self.fgHilite,
|
||||||
value=0,text='Background',command=self.SetColourSampleBinding)
|
value=0,text='Background',command=self.SetColourSampleBinding)
|
||||||
self.fgHilite.set(1)
|
self.fgHilite.set(1)
|
||||||
buttonSaveCustomTheme=Button(frameCustom,
|
buttonSaveCustomTheme=Button(frameCustom,
|
||||||
text='Save as New Custom Theme',command=self.SaveAsNewTheme)
|
text='Save as New Custom Theme',command=self.SaveAsNewTheme)
|
||||||
#frameTheme
|
#frameTheme
|
||||||
labelThemeTitle=Label(frameTheme,text='Select a Highlighting Theme')
|
labelThemeTitle=Label(frameTheme,text='Select a Highlighting Theme')
|
||||||
|
@ -240,7 +240,7 @@ class ConfigDialog(Toplevel):
|
||||||
self.optMenuHighlightTarget.pack(side=TOP,expand=TRUE,fill=X,padx=8,pady=3)
|
self.optMenuHighlightTarget.pack(side=TOP,expand=TRUE,fill=X,padx=8,pady=3)
|
||||||
self.radioFg.pack(side=LEFT,anchor=E)
|
self.radioFg.pack(side=LEFT,anchor=E)
|
||||||
self.radioBg.pack(side=RIGHT,anchor=W)
|
self.radioBg.pack(side=RIGHT,anchor=W)
|
||||||
buttonSaveCustomTheme.pack(side=BOTTOM,fill=X,padx=5,pady=5)
|
buttonSaveCustomTheme.pack(side=BOTTOM,fill=X,padx=5,pady=5)
|
||||||
#frameTheme
|
#frameTheme
|
||||||
labelThemeTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
labelThemeTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
||||||
labelTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
labelTypeTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
||||||
|
@ -256,7 +256,7 @@ class ConfigDialog(Toplevel):
|
||||||
self.bindingTarget=StringVar(self)
|
self.bindingTarget=StringVar(self)
|
||||||
self.builtinKeys=StringVar(self)
|
self.builtinKeys=StringVar(self)
|
||||||
self.customKeys=StringVar(self)
|
self.customKeys=StringVar(self)
|
||||||
self.keysAreBuiltin=BooleanVar(self)
|
self.keysAreBuiltin=BooleanVar(self)
|
||||||
self.keyBinding=StringVar(self)
|
self.keyBinding=StringVar(self)
|
||||||
##widget creation
|
##widget creation
|
||||||
#body frame
|
#body frame
|
||||||
|
@ -300,8 +300,8 @@ class ConfigDialog(Toplevel):
|
||||||
frameKeySets.pack(side=LEFT,padx=5,pady=5,fill=Y)
|
frameKeySets.pack(side=LEFT,padx=5,pady=5,fill=Y)
|
||||||
#frameCustom
|
#frameCustom
|
||||||
labelCustomTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
labelCustomTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
||||||
buttonSaveCustomKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5)
|
buttonSaveCustomKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5)
|
||||||
self.buttonNewKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5)
|
self.buttonNewKeys.pack(side=BOTTOM,fill=X,padx=5,pady=5)
|
||||||
frameTarget.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH)
|
frameTarget.pack(side=LEFT,padx=5,pady=5,expand=TRUE,fill=BOTH)
|
||||||
#frame target
|
#frame target
|
||||||
frameTarget.columnconfigure(0,weight=1)
|
frameTarget.columnconfigure(0,weight=1)
|
||||||
|
@ -321,16 +321,16 @@ class ConfigDialog(Toplevel):
|
||||||
return frame
|
return frame
|
||||||
|
|
||||||
def CreatePageGeneral(self):
|
def CreatePageGeneral(self):
|
||||||
#tkVars
|
#tkVars
|
||||||
self.winWidth=StringVar(self)
|
self.winWidth=StringVar(self)
|
||||||
self.winHeight=StringVar(self)
|
self.winHeight=StringVar(self)
|
||||||
self.startupEdit=IntVar(self)
|
self.startupEdit=IntVar(self)
|
||||||
self.userHelpBrowser=BooleanVar(self)
|
self.userHelpBrowser=BooleanVar(self)
|
||||||
self.helpBrowser=StringVar(self)
|
self.helpBrowser=StringVar(self)
|
||||||
#widget creation
|
#widget creation
|
||||||
#body
|
#body
|
||||||
frame=self.tabPages.pages['General']['page']
|
frame=self.tabPages.pages['General']['page']
|
||||||
#body section frames
|
#body section frames
|
||||||
frameRun=Frame(frame,borderwidth=2,relief=GROOVE)
|
frameRun=Frame(frame,borderwidth=2,relief=GROOVE)
|
||||||
frameWinSize=Frame(frame,borderwidth=2,relief=GROOVE)
|
frameWinSize=Frame(frame,borderwidth=2,relief=GROOVE)
|
||||||
frameHelp=Frame(frame,borderwidth=2,relief=GROOVE)
|
frameHelp=Frame(frame,borderwidth=2,relief=GROOVE)
|
||||||
|
@ -383,7 +383,7 @@ class ConfigDialog(Toplevel):
|
||||||
labelRunTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
labelRunTitle.pack(side=TOP,anchor=W,padx=5,pady=5)
|
||||||
labelRunChoiceTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
|
labelRunChoiceTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
|
||||||
radioStartupEdit.pack(side=LEFT,anchor=W,padx=5,pady=5)
|
radioStartupEdit.pack(side=LEFT,anchor=W,padx=5,pady=5)
|
||||||
radioStartupShell.pack(side=LEFT,anchor=W,padx=5,pady=5)
|
radioStartupShell.pack(side=LEFT,anchor=W,padx=5,pady=5)
|
||||||
#frameWinSize
|
#frameWinSize
|
||||||
labelWinSizeTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
|
labelWinSizeTitle.pack(side=LEFT,anchor=W,padx=5,pady=5)
|
||||||
entryWinHeight.pack(side=RIGHT,anchor=E,padx=10,pady=5)
|
entryWinHeight.pack(side=RIGHT,anchor=E,padx=10,pady=5)
|
||||||
|
@ -414,12 +414,12 @@ class ConfigDialog(Toplevel):
|
||||||
self.colour.trace_variable('w',self.VarChanged_colour)
|
self.colour.trace_variable('w',self.VarChanged_colour)
|
||||||
self.builtinTheme.trace_variable('w',self.VarChanged_builtinTheme)
|
self.builtinTheme.trace_variable('w',self.VarChanged_builtinTheme)
|
||||||
self.customTheme.trace_variable('w',self.VarChanged_customTheme)
|
self.customTheme.trace_variable('w',self.VarChanged_customTheme)
|
||||||
self.themeIsBuiltin.trace_variable('w',self.VarChanged_themeIsBuiltin)
|
self.themeIsBuiltin.trace_variable('w',self.VarChanged_themeIsBuiltin)
|
||||||
self.highlightTarget.trace_variable('w',self.VarChanged_highlightTarget)
|
self.highlightTarget.trace_variable('w',self.VarChanged_highlightTarget)
|
||||||
self.keyBinding.trace_variable('w',self.VarChanged_keyBinding)
|
self.keyBinding.trace_variable('w',self.VarChanged_keyBinding)
|
||||||
self.builtinKeys.trace_variable('w',self.VarChanged_builtinKeys)
|
self.builtinKeys.trace_variable('w',self.VarChanged_builtinKeys)
|
||||||
self.customKeys.trace_variable('w',self.VarChanged_customKeys)
|
self.customKeys.trace_variable('w',self.VarChanged_customKeys)
|
||||||
self.keysAreBuiltin.trace_variable('w',self.VarChanged_keysAreBuiltin)
|
self.keysAreBuiltin.trace_variable('w',self.VarChanged_keysAreBuiltin)
|
||||||
self.winWidth.trace_variable('w',self.VarChanged_winWidth)
|
self.winWidth.trace_variable('w',self.VarChanged_winWidth)
|
||||||
self.winHeight.trace_variable('w',self.VarChanged_winHeight)
|
self.winHeight.trace_variable('w',self.VarChanged_winHeight)
|
||||||
self.startupEdit.trace_variable('w',self.VarChanged_startupEdit)
|
self.startupEdit.trace_variable('w',self.VarChanged_startupEdit)
|
||||||
|
@ -427,7 +427,7 @@ class ConfigDialog(Toplevel):
|
||||||
def VarChanged_fontSize(self,*params):
|
def VarChanged_fontSize(self,*params):
|
||||||
value=self.fontSize.get()
|
value=self.fontSize.get()
|
||||||
self.AddChangedItem('main','EditorWindow','font-size',value)
|
self.AddChangedItem('main','EditorWindow','font-size',value)
|
||||||
|
|
||||||
def VarChanged_fontName(self,*params):
|
def VarChanged_fontName(self,*params):
|
||||||
value=self.fontName.get()
|
value=self.fontName.get()
|
||||||
self.AddChangedItem('main','EditorWindow','font',value)
|
self.AddChangedItem('main','EditorWindow','font',value)
|
||||||
|
@ -472,7 +472,7 @@ class ConfigDialog(Toplevel):
|
||||||
|
|
||||||
def VarChanged_highlightTarget(self,*params):
|
def VarChanged_highlightTarget(self,*params):
|
||||||
self.SetHighlightTarget()
|
self.SetHighlightTarget()
|
||||||
|
|
||||||
def VarChanged_keyBinding(self,*params):
|
def VarChanged_keyBinding(self,*params):
|
||||||
value=self.keyBinding.get()
|
value=self.keyBinding.get()
|
||||||
keySet=self.customKeys.get()
|
keySet=self.customKeys.get()
|
||||||
|
@ -484,7 +484,7 @@ class ConfigDialog(Toplevel):
|
||||||
extName=idleConf.GetExtnNameForEvent(event)
|
extName=idleConf.GetExtnNameForEvent(event)
|
||||||
extKeybindSection=extName+'_cfgBindings'
|
extKeybindSection=extName+'_cfgBindings'
|
||||||
self.AddChangedItem('extensions',extKeybindSection,event,value)
|
self.AddChangedItem('extensions',extKeybindSection,event,value)
|
||||||
|
|
||||||
def VarChanged_builtinKeys(self,*params):
|
def VarChanged_builtinKeys(self,*params):
|
||||||
value=self.builtinKeys.get()
|
value=self.builtinKeys.get()
|
||||||
self.AddChangedItem('main','Keys','name',value)
|
self.AddChangedItem('main','Keys','name',value)
|
||||||
|
@ -497,9 +497,9 @@ class ConfigDialog(Toplevel):
|
||||||
self.LoadKeysList(value)
|
self.LoadKeysList(value)
|
||||||
|
|
||||||
def VarChanged_keysAreBuiltin(self,*params):
|
def VarChanged_keysAreBuiltin(self,*params):
|
||||||
value=self.keysAreBuiltin.get()
|
value=self.keysAreBuiltin.get()
|
||||||
self.AddChangedItem('main','Keys','default',value)
|
self.AddChangedItem('main','Keys','default',value)
|
||||||
if value:
|
if value:
|
||||||
self.VarChanged_builtinKeys()
|
self.VarChanged_builtinKeys()
|
||||||
else:
|
else:
|
||||||
self.VarChanged_customKeys()
|
self.VarChanged_customKeys()
|
||||||
|
@ -518,8 +518,8 @@ class ConfigDialog(Toplevel):
|
||||||
|
|
||||||
def ResetChangedItems(self):
|
def ResetChangedItems(self):
|
||||||
#When any config item is changed in this dialog, an entry
|
#When any config item is changed in this dialog, an entry
|
||||||
#should be made in the relevant section (config type) of this
|
#should be made in the relevant section (config type) of this
|
||||||
#dictionary. The key should be the config file section name and the
|
#dictionary. The key should be the config file section name and the
|
||||||
#value a dictionary, whose key:value pairs are item=value pairs for
|
#value a dictionary, whose key:value pairs are item=value pairs for
|
||||||
#that config file section.
|
#that config file section.
|
||||||
self.changedItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
|
self.changedItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
|
||||||
|
@ -527,9 +527,9 @@ class ConfigDialog(Toplevel):
|
||||||
def AddChangedItem(self,type,section,item,value):
|
def AddChangedItem(self,type,section,item,value):
|
||||||
value=str(value) #make sure we use a string
|
value=str(value) #make sure we use a string
|
||||||
if not self.changedItems[type].has_key(section):
|
if not self.changedItems[type].has_key(section):
|
||||||
self.changedItems[type][section]={}
|
self.changedItems[type][section]={}
|
||||||
self.changedItems[type][section][item]=value
|
self.changedItems[type][section][item]=value
|
||||||
|
|
||||||
def GetDefaultItems(self):
|
def GetDefaultItems(self):
|
||||||
dItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
|
dItems={'main':{},'highlight':{},'keys':{},'extensions':{}}
|
||||||
for configType in dItems.keys():
|
for configType in dItems.keys():
|
||||||
|
@ -537,11 +537,11 @@ class ConfigDialog(Toplevel):
|
||||||
for section in sections:
|
for section in sections:
|
||||||
dItems[configType][section]={}
|
dItems[configType][section]={}
|
||||||
options=idleConf.defaultCfg[configType].GetOptionList(section)
|
options=idleConf.defaultCfg[configType].GetOptionList(section)
|
||||||
for option in options:
|
for option in options:
|
||||||
dItems[configType][section][option]=(
|
dItems[configType][section][option]=(
|
||||||
idleConf.defaultCfg[configType].Get(section,option))
|
idleConf.defaultCfg[configType].Get(section,option))
|
||||||
return dItems
|
return dItems
|
||||||
|
|
||||||
def SetThemeType(self):
|
def SetThemeType(self):
|
||||||
if self.themeIsBuiltin.get():
|
if self.themeIsBuiltin.get():
|
||||||
self.optMenuThemeBuiltin.config(state=NORMAL)
|
self.optMenuThemeBuiltin.config(state=NORMAL)
|
||||||
|
@ -563,14 +563,14 @@ class ConfigDialog(Toplevel):
|
||||||
self.radioKeysCustom.config(state=NORMAL)
|
self.radioKeysCustom.config(state=NORMAL)
|
||||||
self.optMenuKeysCustom.config(state=NORMAL)
|
self.optMenuKeysCustom.config(state=NORMAL)
|
||||||
self.buttonDeleteCustomKeys.config(state=NORMAL)
|
self.buttonDeleteCustomKeys.config(state=NORMAL)
|
||||||
|
|
||||||
def GetNewKeys(self):
|
def GetNewKeys(self):
|
||||||
listIndex=self.listBindings.index(ANCHOR)
|
listIndex=self.listBindings.index(ANCHOR)
|
||||||
binding=self.listBindings.get(listIndex)
|
binding=self.listBindings.get(listIndex)
|
||||||
bindName=binding.split()[0] #first part, up to first space
|
bindName=binding.split()[0] #first part, up to first space
|
||||||
if self.keysAreBuiltin.get():
|
if self.keysAreBuiltin.get():
|
||||||
currentKeySetName=self.builtinKeys.get()
|
currentKeySetName=self.builtinKeys.get()
|
||||||
else:
|
else:
|
||||||
currentKeySetName=self.customKeys.get()
|
currentKeySetName=self.customKeys.get()
|
||||||
currentBindings=idleConf.GetCurrentKeySet()
|
currentBindings=idleConf.GetCurrentKeySet()
|
||||||
if currentKeySetName in self.changedItems['keys'].keys(): #unsaved changes
|
if currentKeySetName in self.changedItems['keys'].keys(): #unsaved changes
|
||||||
|
@ -589,8 +589,8 @@ class ConfigDialog(Toplevel):
|
||||||
self.listBindings.select_set(listIndex)
|
self.listBindings.select_set(listIndex)
|
||||||
self.listBindings.select_anchor(listIndex)
|
self.listBindings.select_anchor(listIndex)
|
||||||
return
|
return
|
||||||
else: #create new custom key set based on previously active key set
|
else: #create new custom key set based on previously active key set
|
||||||
self.CreateNewKeySet(newKeySet)
|
self.CreateNewKeySet(newKeySet)
|
||||||
self.listBindings.delete(listIndex)
|
self.listBindings.delete(listIndex)
|
||||||
self.listBindings.insert(listIndex,bindName+' - '+newKeys)
|
self.listBindings.insert(listIndex,bindName+' - '+newKeys)
|
||||||
self.listBindings.select_set(listIndex)
|
self.listBindings.select_set(listIndex)
|
||||||
|
@ -606,7 +606,7 @@ class ConfigDialog(Toplevel):
|
||||||
newKeySet=GetCfgSectionNameDialog(self,'New Custom Key Set',
|
newKeySet=GetCfgSectionNameDialog(self,'New Custom Key Set',
|
||||||
message,usedNames).result
|
message,usedNames).result
|
||||||
return newKeySet
|
return newKeySet
|
||||||
|
|
||||||
def SaveAsNewKeySet(self):
|
def SaveAsNewKeySet(self):
|
||||||
newKeysName=self.GetNewKeysName('New Key Set Name:')
|
newKeysName=self.GetNewKeysName('New Key Set Name:')
|
||||||
if newKeysName:
|
if newKeysName:
|
||||||
|
@ -618,9 +618,9 @@ class ConfigDialog(Toplevel):
|
||||||
def CreateNewKeySet(self,newKeySetName):
|
def CreateNewKeySet(self,newKeySetName):
|
||||||
#creates new custom key set based on the previously active key set,
|
#creates new custom key set based on the previously active key set,
|
||||||
#and makes the new key set active
|
#and makes the new key set active
|
||||||
if self.keysAreBuiltin.get():
|
if self.keysAreBuiltin.get():
|
||||||
prevKeySetName=self.builtinKeys.get()
|
prevKeySetName=self.builtinKeys.get()
|
||||||
else:
|
else:
|
||||||
prevKeySetName=self.customKeys.get()
|
prevKeySetName=self.customKeys.get()
|
||||||
prevKeys=idleConf.GetCoreKeys(prevKeySetName)
|
prevKeys=idleConf.GetCoreKeys(prevKeySetName)
|
||||||
newKeys={}
|
newKeys={}
|
||||||
|
@ -641,7 +641,7 @@ class ConfigDialog(Toplevel):
|
||||||
self.optMenuKeysCustom.SetMenu(customKeyList,newKeySetName)
|
self.optMenuKeysCustom.SetMenu(customKeyList,newKeySetName)
|
||||||
self.keysAreBuiltin.set(0)
|
self.keysAreBuiltin.set(0)
|
||||||
self.SetKeysType()
|
self.SetKeysType()
|
||||||
|
|
||||||
def LoadKeysList(self,keySetName):
|
def LoadKeysList(self,keySetName):
|
||||||
reselect=0
|
reselect=0
|
||||||
newKeySet=0
|
newKeySet=0
|
||||||
|
@ -652,7 +652,7 @@ class ConfigDialog(Toplevel):
|
||||||
bindNames=keySet.keys()
|
bindNames=keySet.keys()
|
||||||
bindNames.sort()
|
bindNames.sort()
|
||||||
self.listBindings.delete(0,END)
|
self.listBindings.delete(0,END)
|
||||||
for bindName in bindNames:
|
for bindName in bindNames:
|
||||||
key=string.join(keySet[bindName]) #make key(s) into a string
|
key=string.join(keySet[bindName]) #make key(s) into a string
|
||||||
bindName=bindName[2:-2] #trim off the angle brackets
|
bindName=bindName[2:-2] #trim off the angle brackets
|
||||||
if keySetName in self.changedItems['keys'].keys():
|
if keySetName in self.changedItems['keys'].keys():
|
||||||
|
@ -690,7 +690,7 @@ class ConfigDialog(Toplevel):
|
||||||
#user can't back out of these changes, they must be applied now
|
#user can't back out of these changes, they must be applied now
|
||||||
self.Apply()
|
self.Apply()
|
||||||
self.SetKeysType()
|
self.SetKeysType()
|
||||||
|
|
||||||
def DeleteCustomTheme(self):
|
def DeleteCustomTheme(self):
|
||||||
themeName=self.customTheme.get()
|
themeName=self.customTheme.get()
|
||||||
if not tkMessageBox.askyesno('Delete Theme','Are you sure you wish '+
|
if not tkMessageBox.askyesno('Delete Theme','Are you sure you wish '+
|
||||||
|
@ -722,7 +722,7 @@ class ConfigDialog(Toplevel):
|
||||||
prevColour=self.frameColourSet.cget('bg')
|
prevColour=self.frameColourSet.cget('bg')
|
||||||
rgbTuplet, colourString = tkColorChooser.askcolor(parent=self,
|
rgbTuplet, colourString = tkColorChooser.askcolor(parent=self,
|
||||||
title='Pick new colour for : '+target,initialcolor=prevColour)
|
title='Pick new colour for : '+target,initialcolor=prevColour)
|
||||||
if colourString and (colourString!=prevColour):
|
if colourString and (colourString!=prevColour):
|
||||||
#user didn't cancel, and they chose a new colour
|
#user didn't cancel, and they chose a new colour
|
||||||
if self.themeIsBuiltin.get(): #current theme is a built-in
|
if self.themeIsBuiltin.get(): #current theme is a built-in
|
||||||
message=('Your changes will be saved as a new Custom Theme. '+
|
message=('Your changes will be saved as a new Custom Theme. '+
|
||||||
|
@ -730,12 +730,12 @@ class ConfigDialog(Toplevel):
|
||||||
newTheme=self.GetNewThemeName(message)
|
newTheme=self.GetNewThemeName(message)
|
||||||
if not newTheme: #user cancelled custom theme creation
|
if not newTheme: #user cancelled custom theme creation
|
||||||
return
|
return
|
||||||
else: #create new custom theme based on previously active theme
|
else: #create new custom theme based on previously active theme
|
||||||
self.CreateNewTheme(newTheme)
|
self.CreateNewTheme(newTheme)
|
||||||
self.colour.set(colourString)
|
self.colour.set(colourString)
|
||||||
else: #current theme is user defined
|
else: #current theme is user defined
|
||||||
self.colour.set(colourString)
|
self.colour.set(colourString)
|
||||||
|
|
||||||
def OnNewColourSet(self):
|
def OnNewColourSet(self):
|
||||||
newColour=self.colour.get()
|
newColour=self.colour.get()
|
||||||
self.frameColourSet.config(bg=newColour)#set sample
|
self.frameColourSet.config(bg=newColour)#set sample
|
||||||
|
@ -754,7 +754,7 @@ class ConfigDialog(Toplevel):
|
||||||
newTheme=GetCfgSectionNameDialog(self,'New Custom Theme',
|
newTheme=GetCfgSectionNameDialog(self,'New Custom Theme',
|
||||||
message,usedNames).result
|
message,usedNames).result
|
||||||
return newTheme
|
return newTheme
|
||||||
|
|
||||||
def SaveAsNewTheme(self):
|
def SaveAsNewTheme(self):
|
||||||
newThemeName=self.GetNewThemeName('New Theme Name:')
|
newThemeName=self.GetNewThemeName('New Theme Name:')
|
||||||
if newThemeName:
|
if newThemeName:
|
||||||
|
@ -763,10 +763,10 @@ class ConfigDialog(Toplevel):
|
||||||
def CreateNewTheme(self,newThemeName):
|
def CreateNewTheme(self,newThemeName):
|
||||||
#creates new custom theme based on the previously active theme,
|
#creates new custom theme based on the previously active theme,
|
||||||
#and makes the new theme active
|
#and makes the new theme active
|
||||||
if self.themeIsBuiltin.get():
|
if self.themeIsBuiltin.get():
|
||||||
themeType='default'
|
themeType='default'
|
||||||
themeName=self.builtinTheme.get()
|
themeName=self.builtinTheme.get()
|
||||||
else:
|
else:
|
||||||
themeType='user'
|
themeType='user'
|
||||||
themeName=self.customTheme.get()
|
themeName=self.customTheme.get()
|
||||||
newTheme=idleConf.GetThemeDict(themeType,themeName)
|
newTheme=idleConf.GetThemeDict(themeType,themeName)
|
||||||
|
@ -783,16 +783,16 @@ class ConfigDialog(Toplevel):
|
||||||
self.optMenuThemeCustom.SetMenu(customThemeList,newThemeName)
|
self.optMenuThemeCustom.SetMenu(customThemeList,newThemeName)
|
||||||
self.themeIsBuiltin.set(0)
|
self.themeIsBuiltin.set(0)
|
||||||
self.SetThemeType()
|
self.SetThemeType()
|
||||||
|
|
||||||
def OnListFontButtonRelease(self,event):
|
def OnListFontButtonRelease(self,event):
|
||||||
self.fontName.set(self.listFontName.get(ANCHOR))
|
self.fontName.set(self.listFontName.get(ANCHOR))
|
||||||
self.SetFontSample()
|
self.SetFontSample()
|
||||||
|
|
||||||
def SetFontSample(self,event=None):
|
def SetFontSample(self,event=None):
|
||||||
fontName=self.fontName.get()
|
fontName=self.fontName.get()
|
||||||
if self.fontBold.get():
|
if self.fontBold.get():
|
||||||
fontWeight=tkFont.BOLD
|
fontWeight=tkFont.BOLD
|
||||||
else:
|
else:
|
||||||
fontWeight=tkFont.NORMAL
|
fontWeight=tkFont.NORMAL
|
||||||
self.editFont.config(size=self.fontSize.get(),
|
self.editFont.config(size=self.fontSize.get(),
|
||||||
weight=fontWeight,family=fontName)
|
weight=fontWeight,family=fontName)
|
||||||
|
@ -807,10 +807,10 @@ class ConfigDialog(Toplevel):
|
||||||
self.radioBg.config(state=NORMAL)
|
self.radioBg.config(state=NORMAL)
|
||||||
self.fgHilite.set(1)
|
self.fgHilite.set(1)
|
||||||
self.SetColourSample()
|
self.SetColourSample()
|
||||||
|
|
||||||
def SetColourSampleBinding(self,*args):
|
def SetColourSampleBinding(self,*args):
|
||||||
self.SetColourSample()
|
self.SetColourSample()
|
||||||
|
|
||||||
def SetColourSample(self):
|
def SetColourSample(self):
|
||||||
#set the colour smaple area
|
#set the colour smaple area
|
||||||
tag=self.themeElements[self.highlightTarget.get()][0]
|
tag=self.themeElements[self.highlightTarget.get()][0]
|
||||||
|
@ -818,7 +818,7 @@ class ConfigDialog(Toplevel):
|
||||||
else: plane='background'
|
else: plane='background'
|
||||||
colour=self.textHighlightSample.tag_cget(tag,plane)
|
colour=self.textHighlightSample.tag_cget(tag,plane)
|
||||||
self.frameColourSet.config(bg=colour)
|
self.frameColourSet.config(bg=colour)
|
||||||
|
|
||||||
def PaintThemeSample(self):
|
def PaintThemeSample(self):
|
||||||
if self.themeIsBuiltin.get(): #a default theme
|
if self.themeIsBuiltin.get(): #a default theme
|
||||||
theme=self.builtinTheme.get()
|
theme=self.builtinTheme.get()
|
||||||
|
@ -828,7 +828,7 @@ class ConfigDialog(Toplevel):
|
||||||
element=self.themeElements[elementTitle][0]
|
element=self.themeElements[elementTitle][0]
|
||||||
colours=idleConf.GetHighlight(theme,element)
|
colours=idleConf.GetHighlight(theme,element)
|
||||||
if element=='cursor': #cursor sample needs special painting
|
if element=='cursor': #cursor sample needs special painting
|
||||||
colours['background']=idleConf.GetHighlight(theme,
|
colours['background']=idleConf.GetHighlight(theme,
|
||||||
'normal', fgBg='bg')
|
'normal', fgBg='bg')
|
||||||
#handle any unsaved changes to this theme
|
#handle any unsaved changes to this theme
|
||||||
if theme in self.changedItems['highlight'].keys():
|
if theme in self.changedItems['highlight'].keys():
|
||||||
|
@ -839,16 +839,16 @@ class ConfigDialog(Toplevel):
|
||||||
colours['background']=themeDict[element+'-background']
|
colours['background']=themeDict[element+'-background']
|
||||||
apply(self.textHighlightSample.tag_config,(element,),colours)
|
apply(self.textHighlightSample.tag_config,(element,),colours)
|
||||||
self.SetColourSample()
|
self.SetColourSample()
|
||||||
|
|
||||||
def OnCheckUserHelpBrowser(self):
|
def OnCheckUserHelpBrowser(self):
|
||||||
if self.userHelpBrowser.get():
|
if self.userHelpBrowser.get():
|
||||||
self.entryHelpBrowser.config(state=NORMAL)
|
self.entryHelpBrowser.config(state=NORMAL)
|
||||||
else:
|
else:
|
||||||
self.entryHelpBrowser.config(state=DISABLED)
|
self.entryHelpBrowser.config(state=DISABLED)
|
||||||
|
|
||||||
def HelpSourceSelected(self,event):
|
def HelpSourceSelected(self,event):
|
||||||
self.SetHelpListButtonStates()
|
self.SetHelpListButtonStates()
|
||||||
|
|
||||||
def SetHelpListButtonStates(self):
|
def SetHelpListButtonStates(self):
|
||||||
if self.listHelp.size()<1: #no entries in list
|
if self.listHelp.size()<1: #no entries in list
|
||||||
self.buttonHelpListEdit.config(state=DISABLED)
|
self.buttonHelpListEdit.config(state=DISABLED)
|
||||||
|
@ -868,7 +868,7 @@ class ConfigDialog(Toplevel):
|
||||||
self.listHelp.insert(END,helpSource[0]+' '+helpSource[1])
|
self.listHelp.insert(END,helpSource[0]+' '+helpSource[1])
|
||||||
self.UpdateUserHelpChangedItems()
|
self.UpdateUserHelpChangedItems()
|
||||||
self.SetHelpListButtonStates()
|
self.SetHelpListButtonStates()
|
||||||
|
|
||||||
def HelpListItemEdit(self):
|
def HelpListItemEdit(self):
|
||||||
itemIndex=self.listHelp.index(ANCHOR)
|
itemIndex=self.listHelp.index(ANCHOR)
|
||||||
helpSource=self.userHelpList[itemIndex]
|
helpSource=self.userHelpList[itemIndex]
|
||||||
|
@ -881,14 +881,14 @@ class ConfigDialog(Toplevel):
|
||||||
self.listHelp.insert(itemIndex,newHelpSource[0]+' '+newHelpSource[1])
|
self.listHelp.insert(itemIndex,newHelpSource[0]+' '+newHelpSource[1])
|
||||||
self.UpdateUserHelpChangedItems()
|
self.UpdateUserHelpChangedItems()
|
||||||
self.SetHelpListButtonStates()
|
self.SetHelpListButtonStates()
|
||||||
|
|
||||||
def HelpListItemRemove(self):
|
def HelpListItemRemove(self):
|
||||||
itemIndex=self.listHelp.index(ANCHOR)
|
itemIndex=self.listHelp.index(ANCHOR)
|
||||||
del(self.userHelpList[itemIndex])
|
del(self.userHelpList[itemIndex])
|
||||||
self.listHelp.delete(itemIndex)
|
self.listHelp.delete(itemIndex)
|
||||||
self.UpdateUserHelpChangedItems()
|
self.UpdateUserHelpChangedItems()
|
||||||
self.SetHelpListButtonStates()
|
self.SetHelpListButtonStates()
|
||||||
|
|
||||||
def UpdateUserHelpChangedItems(self):
|
def UpdateUserHelpChangedItems(self):
|
||||||
#clear and rebuild the HelpFiles secion in self.changedItems
|
#clear and rebuild the HelpFiles secion in self.changedItems
|
||||||
if self.changedItems['main'].has_key('HelpFiles'):
|
if self.changedItems['main'].has_key('HelpFiles'):
|
||||||
|
@ -896,7 +896,7 @@ class ConfigDialog(Toplevel):
|
||||||
for num in range(1,len(self.userHelpList)+1):
|
for num in range(1,len(self.userHelpList)+1):
|
||||||
self.AddChangedItem('main','HelpFiles',str(num),
|
self.AddChangedItem('main','HelpFiles',str(num),
|
||||||
string.join(self.userHelpList[num-1],';'))
|
string.join(self.userHelpList[num-1],';'))
|
||||||
|
|
||||||
def LoadFontCfg(self):
|
def LoadFontCfg(self):
|
||||||
##base editor font selection list
|
##base editor font selection list
|
||||||
fonts=list(tkFont.families(self))
|
fonts=list(tkFont.families(self))
|
||||||
|
@ -919,9 +919,9 @@ class ConfigDialog(Toplevel):
|
||||||
##fontWeight
|
##fontWeight
|
||||||
self.fontBold.set(idleConf.GetOption('main','EditorWindow',
|
self.fontBold.set(idleConf.GetOption('main','EditorWindow',
|
||||||
'font-bold',default=0,type='bool'))
|
'font-bold',default=0,type='bool'))
|
||||||
##font sample
|
##font sample
|
||||||
self.SetFontSample()
|
self.SetFontSample()
|
||||||
|
|
||||||
def LoadTabCfg(self):
|
def LoadTabCfg(self):
|
||||||
##indent type radiobuttons
|
##indent type radiobuttons
|
||||||
spaceIndent=idleConf.GetOption('main','Indent','use-spaces',
|
spaceIndent=idleConf.GetOption('main','Indent','use-spaces',
|
||||||
|
@ -934,7 +934,7 @@ class ConfigDialog(Toplevel):
|
||||||
# default=4,type='int')
|
# default=4,type='int')
|
||||||
self.spaceNum.set(spaceNum)
|
self.spaceNum.set(spaceNum)
|
||||||
#self.tabCols.set(tabCols)
|
#self.tabCols.set(tabCols)
|
||||||
|
|
||||||
def LoadThemeCfg(self):
|
def LoadThemeCfg(self):
|
||||||
##current theme type radiobutton
|
##current theme type radiobutton
|
||||||
self.themeIsBuiltin.set(idleConf.GetOption('main','Theme','default',
|
self.themeIsBuiltin.set(idleConf.GetOption('main','Theme','default',
|
||||||
|
@ -950,7 +950,7 @@ class ConfigDialog(Toplevel):
|
||||||
itemList.sort()
|
itemList.sort()
|
||||||
if not itemList:
|
if not itemList:
|
||||||
self.radioThemeCustom.config(state=DISABLED)
|
self.radioThemeCustom.config(state=DISABLED)
|
||||||
self.customTheme.set('- no custom themes -')
|
self.customTheme.set('- no custom themes -')
|
||||||
else:
|
else:
|
||||||
self.optMenuThemeCustom.SetMenu(itemList,itemList[0])
|
self.optMenuThemeCustom.SetMenu(itemList,itemList[0])
|
||||||
else: #user theme selected
|
else: #user theme selected
|
||||||
|
@ -964,15 +964,15 @@ class ConfigDialog(Toplevel):
|
||||||
##load theme element option menu
|
##load theme element option menu
|
||||||
themeNames=self.themeElements.keys()
|
themeNames=self.themeElements.keys()
|
||||||
themeNames.sort(self.__ThemeNameIndexCompare)
|
themeNames.sort(self.__ThemeNameIndexCompare)
|
||||||
self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0])
|
self.optMenuHighlightTarget.SetMenu(themeNames,themeNames[0])
|
||||||
self.PaintThemeSample()
|
self.PaintThemeSample()
|
||||||
self.SetHighlightTarget()
|
self.SetHighlightTarget()
|
||||||
|
|
||||||
def __ThemeNameIndexCompare(self,a,b):
|
def __ThemeNameIndexCompare(self,a,b):
|
||||||
if self.themeElements[a][1]<self.themeElements[b][1]: return -1
|
if self.themeElements[a][1]<self.themeElements[b][1]: return -1
|
||||||
elif self.themeElements[a][1]==self.themeElements[b][1]: return 0
|
elif self.themeElements[a][1]==self.themeElements[b][1]: return 0
|
||||||
else: return 1
|
else: return 1
|
||||||
|
|
||||||
def LoadKeyCfg(self):
|
def LoadKeyCfg(self):
|
||||||
##current keys type radiobutton
|
##current keys type radiobutton
|
||||||
self.keysAreBuiltin.set(idleConf.GetOption('main','Keys','default',
|
self.keysAreBuiltin.set(idleConf.GetOption('main','Keys','default',
|
||||||
|
@ -987,8 +987,8 @@ class ConfigDialog(Toplevel):
|
||||||
itemList=idleConf.GetSectionList('user','keys')
|
itemList=idleConf.GetSectionList('user','keys')
|
||||||
itemList.sort()
|
itemList.sort()
|
||||||
if not itemList:
|
if not itemList:
|
||||||
self.radioKeysCustom.config(state=DISABLED)
|
self.radioKeysCustom.config(state=DISABLED)
|
||||||
self.customKeys.set('- no custom keys -')
|
self.customKeys.set('- no custom keys -')
|
||||||
else:
|
else:
|
||||||
self.optMenuKeysCustom.SetMenu(itemList,itemList[0])
|
self.optMenuKeysCustom.SetMenu(itemList,itemList[0])
|
||||||
else: #user key set selected
|
else: #user key set selected
|
||||||
|
@ -998,17 +998,17 @@ class ConfigDialog(Toplevel):
|
||||||
itemList=idleConf.GetSectionList('default','keys')
|
itemList=idleConf.GetSectionList('default','keys')
|
||||||
itemList.sort()
|
itemList.sort()
|
||||||
self.optMenuKeysBuiltin.SetMenu(itemList,itemList[0])
|
self.optMenuKeysBuiltin.SetMenu(itemList,itemList[0])
|
||||||
self.SetKeysType()
|
self.SetKeysType()
|
||||||
##load keyset element list
|
##load keyset element list
|
||||||
keySetName=idleConf.CurrentKeys()
|
keySetName=idleConf.CurrentKeys()
|
||||||
self.LoadKeysList(keySetName)
|
self.LoadKeysList(keySetName)
|
||||||
|
|
||||||
def LoadGeneralCfg(self):
|
def LoadGeneralCfg(self):
|
||||||
#startup state
|
#startup state
|
||||||
self.startupEdit.set(idleConf.GetOption('main','General',
|
self.startupEdit.set(idleConf.GetOption('main','General',
|
||||||
'editor-on-startup',default=1,type='bool'))
|
'editor-on-startup',default=1,type='bool'))
|
||||||
#initial window size
|
#initial window size
|
||||||
self.winWidth.set(idleConf.GetOption('main','EditorWindow','width'))
|
self.winWidth.set(idleConf.GetOption('main','EditorWindow','width'))
|
||||||
self.winHeight.set(idleConf.GetOption('main','EditorWindow','height'))
|
self.winHeight.set(idleConf.GetOption('main','EditorWindow','height'))
|
||||||
#help browsing
|
#help browsing
|
||||||
self.userHelpList=idleConf.GetExtraHelpSourceList('user')
|
self.userHelpList=idleConf.GetExtraHelpSourceList('user')
|
||||||
|
@ -1020,22 +1020,22 @@ class ConfigDialog(Toplevel):
|
||||||
#self.helpBrowser.set(idleConf.GetOption('main','General',
|
#self.helpBrowser.set(idleConf.GetOption('main','General',
|
||||||
# 'user-help-browser-command',default=''))
|
# 'user-help-browser-command',default=''))
|
||||||
#self.OnCheckUserHelpBrowser()
|
#self.OnCheckUserHelpBrowser()
|
||||||
|
|
||||||
def LoadConfigs(self):
|
def LoadConfigs(self):
|
||||||
"""
|
"""
|
||||||
load configuration from default and user config files and populate
|
load configuration from default and user config files and populate
|
||||||
the widgets on the config dialog pages.
|
the widgets on the config dialog pages.
|
||||||
"""
|
"""
|
||||||
### fonts / tabs page
|
### fonts / tabs page
|
||||||
self.LoadFontCfg()
|
self.LoadFontCfg()
|
||||||
self.LoadTabCfg()
|
self.LoadTabCfg()
|
||||||
### highlighting page
|
### highlighting page
|
||||||
self.LoadThemeCfg()
|
self.LoadThemeCfg()
|
||||||
### keys page
|
### keys page
|
||||||
self.LoadKeyCfg()
|
self.LoadKeyCfg()
|
||||||
### general page
|
### general page
|
||||||
self.LoadGeneralCfg()
|
self.LoadGeneralCfg()
|
||||||
|
|
||||||
def SaveNewKeySet(self,keySetName,keySet):
|
def SaveNewKeySet(self,keySetName,keySet):
|
||||||
"""
|
"""
|
||||||
save a newly created core key set.
|
save a newly created core key set.
|
||||||
|
@ -1047,7 +1047,7 @@ class ConfigDialog(Toplevel):
|
||||||
for event in keySet.keys():
|
for event in keySet.keys():
|
||||||
value=keySet[event]
|
value=keySet[event]
|
||||||
idleConf.userCfg['keys'].SetOption(keySetName,event,value)
|
idleConf.userCfg['keys'].SetOption(keySetName,event,value)
|
||||||
|
|
||||||
def SaveNewTheme(self,themeName,theme):
|
def SaveNewTheme(self,themeName,theme):
|
||||||
"""
|
"""
|
||||||
save a newly created theme.
|
save a newly created theme.
|
||||||
|
@ -1059,7 +1059,7 @@ class ConfigDialog(Toplevel):
|
||||||
for element in theme.keys():
|
for element in theme.keys():
|
||||||
value=theme[element]
|
value=theme[element]
|
||||||
idleConf.userCfg['highlight'].SetOption(themeName,element,value)
|
idleConf.userCfg['highlight'].SetOption(themeName,element,value)
|
||||||
|
|
||||||
def SetUserValue(self,configType,section,item,value):
|
def SetUserValue(self,configType,section,item,value):
|
||||||
if idleConf.defaultCfg[configType].has_option(section,item):
|
if idleConf.defaultCfg[configType].has_option(section,item):
|
||||||
if idleConf.defaultCfg[configType].Get(section,item)==value:
|
if idleConf.defaultCfg[configType].Get(section,item)==value:
|
||||||
|
@ -1067,7 +1067,7 @@ class ConfigDialog(Toplevel):
|
||||||
return idleConf.userCfg[configType].RemoveOption(section,item)
|
return idleConf.userCfg[configType].RemoveOption(section,item)
|
||||||
#if we got here set the option
|
#if we got here set the option
|
||||||
return idleConf.userCfg[configType].SetOption(section,item,value)
|
return idleConf.userCfg[configType].SetOption(section,item,value)
|
||||||
|
|
||||||
def SaveAllChangedConfigs(self):
|
def SaveAllChangedConfigs(self):
|
||||||
"""
|
"""
|
||||||
save all configuration changes to user config files.
|
save all configuration changes to user config files.
|
||||||
|
@ -1082,12 +1082,12 @@ class ConfigDialog(Toplevel):
|
||||||
value=self.changedItems[configType][section][item]
|
value=self.changedItems[configType][section][item]
|
||||||
if self.SetUserValue(configType,section,item,value):
|
if self.SetUserValue(configType,section,item,value):
|
||||||
cfgTypeHasChanges=1
|
cfgTypeHasChanges=1
|
||||||
if cfgTypeHasChanges:
|
if cfgTypeHasChanges:
|
||||||
idleConf.userCfg[configType].Save()
|
idleConf.userCfg[configType].Save()
|
||||||
self.ResetChangedItems() #clear the changed items dict
|
self.ResetChangedItems() #clear the changed items dict
|
||||||
|
|
||||||
def ActivateConfigChanges(self):
|
def ActivateConfigChanges(self):
|
||||||
#things that need to be done to make
|
#things that need to be done to make
|
||||||
#applied config changes dynamic:
|
#applied config changes dynamic:
|
||||||
#update editor/shell font and repaint
|
#update editor/shell font and repaint
|
||||||
#dynamically update indentation setttings
|
#dynamically update indentation setttings
|
||||||
|
@ -1100,7 +1100,7 @@ class ConfigDialog(Toplevel):
|
||||||
instance.ResetFont()
|
instance.ResetFont()
|
||||||
instance.ResetKeybindings()
|
instance.ResetKeybindings()
|
||||||
instance.ResetExtraHelpMenu()
|
instance.ResetExtraHelpMenu()
|
||||||
|
|
||||||
def Cancel(self):
|
def Cancel(self):
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
|
|
@ -5,8 +5,8 @@ Provides access to stored idle configuration information.
|
||||||
# when a problem occurs in returning a requested configuration value back to
|
# when a problem occurs in returning a requested configuration value back to
|
||||||
# idle. This is to allow idle to continue to function in spite of errors in
|
# idle. This is to allow idle to continue to function in spite of errors in
|
||||||
# the retrieval of config information. When a default is returned instead of
|
# the retrieval of config information. When a default is returned instead of
|
||||||
# a requested config value, a message is printed to stderr to aid in
|
# a requested config value, a message is printed to stderr to aid in
|
||||||
# configuration problem notification and resolution.
|
# configuration problem notification and resolution.
|
||||||
|
|
||||||
import os, sys, string
|
import os, sys, string
|
||||||
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
|
from ConfigParser import ConfigParser, NoOptionError, NoSectionError
|
||||||
|
@ -26,17 +26,17 @@ class IdleConfParser(ConfigParser):
|
||||||
"""
|
"""
|
||||||
self.file=cfgFile
|
self.file=cfgFile
|
||||||
ConfigParser.__init__(self,defaults=cfgDefaults)
|
ConfigParser.__init__(self,defaults=cfgDefaults)
|
||||||
|
|
||||||
def Get(self, section, option, type=None, default=None):
|
def Get(self, section, option, type=None, default=None):
|
||||||
"""
|
"""
|
||||||
Get an option value for given section/option or return default.
|
Get an option value for given section/option or return default.
|
||||||
If type is specified, return as type.
|
If type is specified, return as type.
|
||||||
"""
|
"""
|
||||||
if type=='bool':
|
if type=='bool':
|
||||||
getVal=self.getboolean
|
getVal=self.getboolean
|
||||||
elif type=='int':
|
elif type=='int':
|
||||||
getVal=self.getint
|
getVal=self.getint
|
||||||
else:
|
else:
|
||||||
getVal=self.get
|
getVal=self.get
|
||||||
if self.has_option(section,option):
|
if self.has_option(section,option):
|
||||||
#return getVal(section, option, raw, vars, default)
|
#return getVal(section, option, raw, vars, default)
|
||||||
|
@ -54,11 +54,11 @@ class IdleConfParser(ConfigParser):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def Load(self):
|
def Load(self):
|
||||||
"""
|
"""
|
||||||
Load the configuration file from disk
|
Load the configuration file from disk
|
||||||
"""
|
"""
|
||||||
self.read(self.file)
|
self.read(self.file)
|
||||||
|
|
||||||
class IdleUserConfParser(IdleConfParser):
|
class IdleUserConfParser(IdleConfParser):
|
||||||
"""
|
"""
|
||||||
IdleConfigParser specialised for user configuration handling.
|
IdleConfigParser specialised for user configuration handling.
|
||||||
|
@ -70,15 +70,15 @@ class IdleUserConfParser(IdleConfParser):
|
||||||
"""
|
"""
|
||||||
if not self.has_section(section):
|
if not self.has_section(section):
|
||||||
self.add_section(section)
|
self.add_section(section)
|
||||||
|
|
||||||
def RemoveEmptySections(self):
|
def RemoveEmptySections(self):
|
||||||
"""
|
"""
|
||||||
remove any sections that have no options
|
remove any sections that have no options
|
||||||
"""
|
"""
|
||||||
for section in self.sections():
|
for section in self.sections():
|
||||||
if not self.GetOptionList(section):
|
if not self.GetOptionList(section):
|
||||||
self.remove_section(section)
|
self.remove_section(section)
|
||||||
|
|
||||||
def IsEmpty(self):
|
def IsEmpty(self):
|
||||||
"""
|
"""
|
||||||
Remove empty sections and then return 1 if parser has no sections
|
Remove empty sections and then return 1 if parser has no sections
|
||||||
|
@ -89,7 +89,7 @@ class IdleUserConfParser(IdleConfParser):
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def RemoveOption(self,section,option):
|
def RemoveOption(self,section,option):
|
||||||
"""
|
"""
|
||||||
If section/option exists, remove it.
|
If section/option exists, remove it.
|
||||||
|
@ -97,7 +97,7 @@ class IdleUserConfParser(IdleConfParser):
|
||||||
"""
|
"""
|
||||||
if self.has_section(section):
|
if self.has_section(section):
|
||||||
return self.remove_option(section,option)
|
return self.remove_option(section,option)
|
||||||
|
|
||||||
def SetOption(self,section,option,value):
|
def SetOption(self,section,option,value):
|
||||||
"""
|
"""
|
||||||
Sets option to value, adding section if required.
|
Sets option to value, adding section if required.
|
||||||
|
@ -114,14 +114,14 @@ class IdleUserConfParser(IdleConfParser):
|
||||||
self.add_section(section)
|
self.add_section(section)
|
||||||
self.set(section,option,value)
|
self.set(section,option,value)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def RemoveFile(self):
|
def RemoveFile(self):
|
||||||
"""
|
"""
|
||||||
Removes the user config file from disk if it exists.
|
Removes the user config file from disk if it exists.
|
||||||
"""
|
"""
|
||||||
if os.path.exists(self.file):
|
if os.path.exists(self.file):
|
||||||
os.remove(self.file)
|
os.remove(self.file)
|
||||||
|
|
||||||
def Save(self):
|
def Save(self):
|
||||||
"""
|
"""
|
||||||
If config isn't empty, write file to disk. If config is empty,
|
If config isn't empty, write file to disk. If config is empty,
|
||||||
|
@ -154,10 +154,10 @@ class IdleConf:
|
||||||
self.CreateConfigHandlers()
|
self.CreateConfigHandlers()
|
||||||
self.LoadCfgFiles()
|
self.LoadCfgFiles()
|
||||||
#self.LoadCfg()
|
#self.LoadCfg()
|
||||||
|
|
||||||
def CreateConfigHandlers(self):
|
def CreateConfigHandlers(self):
|
||||||
"""
|
"""
|
||||||
set up a dictionary of config parsers for default and user
|
set up a dictionary of config parsers for default and user
|
||||||
configurations respectively
|
configurations respectively
|
||||||
"""
|
"""
|
||||||
#build idle install path
|
#build idle install path
|
||||||
|
@ -170,15 +170,15 @@ class IdleConf:
|
||||||
defCfgFiles={}
|
defCfgFiles={}
|
||||||
usrCfgFiles={}
|
usrCfgFiles={}
|
||||||
for cfgType in configTypes: #build config file names
|
for cfgType in configTypes: #build config file names
|
||||||
defCfgFiles[cfgType]=os.path.join(idleDir,'config-'+cfgType+'.def')
|
defCfgFiles[cfgType]=os.path.join(idleDir,'config-'+cfgType+'.def')
|
||||||
usrCfgFiles[cfgType]=os.path.join(userDir,'config-'+cfgType+'.cfg')
|
usrCfgFiles[cfgType]=os.path.join(userDir,'config-'+cfgType+'.cfg')
|
||||||
for cfgType in configTypes: #create config parsers
|
for cfgType in configTypes: #create config parsers
|
||||||
self.defaultCfg[cfgType]=IdleConfParser(defCfgFiles[cfgType])
|
self.defaultCfg[cfgType]=IdleConfParser(defCfgFiles[cfgType])
|
||||||
self.userCfg[cfgType]=IdleUserConfParser(usrCfgFiles[cfgType])
|
self.userCfg[cfgType]=IdleUserConfParser(usrCfgFiles[cfgType])
|
||||||
|
|
||||||
def GetUserCfgDir(self):
|
def GetUserCfgDir(self):
|
||||||
"""
|
"""
|
||||||
Creates (if required) and returns a filesystem directory for storing
|
Creates (if required) and returns a filesystem directory for storing
|
||||||
user config files.
|
user config files.
|
||||||
"""
|
"""
|
||||||
cfgDir='.idlerc'
|
cfgDir='.idlerc'
|
||||||
|
@ -192,23 +192,23 @@ class IdleConf:
|
||||||
if userDir=='~': #we still don't have a home directory
|
if userDir=='~': #we still don't have a home directory
|
||||||
#traditionally idle has defaulted to os.getcwd(), is this adeqate?
|
#traditionally idle has defaulted to os.getcwd(), is this adeqate?
|
||||||
userDir = os.getcwd() #hack for no real homedir
|
userDir = os.getcwd() #hack for no real homedir
|
||||||
userDir=os.path.join(userDir,cfgDir)
|
userDir=os.path.join(userDir,cfgDir)
|
||||||
if not os.path.exists(userDir):
|
if not os.path.exists(userDir):
|
||||||
try: #make the config dir if it doesn't exist yet
|
try: #make the config dir if it doesn't exist yet
|
||||||
os.mkdir(userDir)
|
os.mkdir(userDir)
|
||||||
except IOError:
|
except IOError:
|
||||||
warn=('\n Warning: unable to create user config directory\n '+
|
warn=('\n Warning: unable to create user config directory\n '+
|
||||||
userDir+'\n')
|
userDir+'\n')
|
||||||
sys.stderr.write(warn)
|
sys.stderr.write(warn)
|
||||||
return userDir
|
return userDir
|
||||||
|
|
||||||
def GetOption(self, configType, section, option, default=None, type=None):
|
def GetOption(self, configType, section, option, default=None, type=None):
|
||||||
"""
|
"""
|
||||||
Get an option value for given config type and given general
|
Get an option value for given config type and given general
|
||||||
configuration section/option or return a default. If type is specified,
|
configuration section/option or return a default. If type is specified,
|
||||||
return as type. Firstly the user configuration is checked, with a
|
return as type. Firstly the user configuration is checked, with a
|
||||||
fallback to the default configuration, and a final 'catch all'
|
fallback to the default configuration, and a final 'catch all'
|
||||||
fallback to a useable passed-in default if the option isn't present in
|
fallback to a useable passed-in default if the option isn't present in
|
||||||
either the user or the default configuration.
|
either the user or the default configuration.
|
||||||
configType must be one of ('main','extensions','highlight','keys')
|
configType must be one of ('main','extensions','highlight','keys')
|
||||||
If a default is returned a warning is printed to stderr.
|
If a default is returned a warning is printed to stderr.
|
||||||
|
@ -224,12 +224,12 @@ class IdleConf:
|
||||||
' returning default value: '+`default`+'\n')
|
' returning default value: '+`default`+'\n')
|
||||||
sys.stderr.write(warning)
|
sys.stderr.write(warning)
|
||||||
return default
|
return default
|
||||||
|
|
||||||
def GetSectionList(self, configSet, configType):
|
def GetSectionList(self, configSet, configType):
|
||||||
"""
|
"""
|
||||||
Get a list of sections from either the user or default config for
|
Get a list of sections from either the user or default config for
|
||||||
the given config type.
|
the given config type.
|
||||||
configSet must be either 'user' or 'default'
|
configSet must be either 'user' or 'default'
|
||||||
configType must be one of ('main','extensions','highlight','keys')
|
configType must be one of ('main','extensions','highlight','keys')
|
||||||
"""
|
"""
|
||||||
if not (configType in ('main','extensions','highlight','keys')):
|
if not (configType in ('main','extensions','highlight','keys')):
|
||||||
|
@ -241,13 +241,13 @@ class IdleConf:
|
||||||
else:
|
else:
|
||||||
raise InvalidConfigSet, 'Invalid configSet specified'
|
raise InvalidConfigSet, 'Invalid configSet specified'
|
||||||
return cfgParser.sections()
|
return cfgParser.sections()
|
||||||
|
|
||||||
def GetHighlight(self, theme, element, fgBg=None):
|
def GetHighlight(self, theme, element, fgBg=None):
|
||||||
"""
|
"""
|
||||||
return individual highlighting theme elements.
|
return individual highlighting theme elements.
|
||||||
fgBg - string ('fg'or'bg') or None, if None return a dictionary
|
fgBg - string ('fg'or'bg') or None, if None return a dictionary
|
||||||
containing fg and bg colours (appropriate for passing to Tkinter in,
|
containing fg and bg colours (appropriate for passing to Tkinter in,
|
||||||
e.g., a tag_config call), otherwise fg or bg colour only as specified.
|
e.g., a tag_config call), otherwise fg or bg colour only as specified.
|
||||||
"""
|
"""
|
||||||
if self.defaultCfg['highlight'].has_section(theme):
|
if self.defaultCfg['highlight'].has_section(theme):
|
||||||
themeDict=self.GetThemeDict('default',theme)
|
themeDict=self.GetThemeDict('default',theme)
|
||||||
|
@ -256,7 +256,7 @@ class IdleConf:
|
||||||
fore=themeDict[element+'-foreground']
|
fore=themeDict[element+'-foreground']
|
||||||
if element=='cursor': #there is no config value for cursor bg
|
if element=='cursor': #there is no config value for cursor bg
|
||||||
back=themeDict['normal-background']
|
back=themeDict['normal-background']
|
||||||
else:
|
else:
|
||||||
back=themeDict[element+'-background']
|
back=themeDict[element+'-background']
|
||||||
highlight={"foreground": fore,"background": back}
|
highlight={"foreground": fore,"background": back}
|
||||||
if not fgBg: #return dict of both colours
|
if not fgBg: #return dict of both colours
|
||||||
|
@ -266,7 +266,7 @@ class IdleConf:
|
||||||
return highlight["foreground"]
|
return highlight["foreground"]
|
||||||
if fgBg == 'bg':
|
if fgBg == 'bg':
|
||||||
return highlight["background"]
|
return highlight["background"]
|
||||||
else:
|
else:
|
||||||
raise InvalidFgBg, 'Invalid fgBg specified'
|
raise InvalidFgBg, 'Invalid fgBg specified'
|
||||||
|
|
||||||
def GetThemeDict(self,type,themeName):
|
def GetThemeDict(self,type,themeName):
|
||||||
|
@ -275,7 +275,7 @@ class IdleConf:
|
||||||
themeName - string, theme name
|
themeName - string, theme name
|
||||||
Returns a dictionary which holds {option:value} for each element
|
Returns a dictionary which holds {option:value} for each element
|
||||||
in the specified theme. Values are loaded over a set of ultimate last
|
in the specified theme. Values are loaded over a set of ultimate last
|
||||||
fallback defaults to guarantee that all theme elements are present in
|
fallback defaults to guarantee that all theme elements are present in
|
||||||
a newly created theme.
|
a newly created theme.
|
||||||
"""
|
"""
|
||||||
if type == 'user':
|
if type == 'user':
|
||||||
|
@ -288,15 +288,15 @@ class IdleConf:
|
||||||
#(apart from cursor) even though all these values are not yet used
|
#(apart from cursor) even though all these values are not yet used
|
||||||
#by idle, to allow for their use in the future. Default values are
|
#by idle, to allow for their use in the future. Default values are
|
||||||
#generally black and white.
|
#generally black and white.
|
||||||
theme={ 'normal-foreground':'#000000',
|
theme={ 'normal-foreground':'#000000',
|
||||||
'normal-background':'#ffffff',
|
'normal-background':'#ffffff',
|
||||||
'keyword-foreground':'#000000',
|
'keyword-foreground':'#000000',
|
||||||
'keyword-background':'#ffffff',
|
'keyword-background':'#ffffff',
|
||||||
'comment-foreground':'#000000',
|
'comment-foreground':'#000000',
|
||||||
'comment-background':'#ffffff',
|
'comment-background':'#ffffff',
|
||||||
'string-foreground':'#000000',
|
'string-foreground':'#000000',
|
||||||
'string-background':'#ffffff',
|
'string-background':'#ffffff',
|
||||||
'definition-foreground':'#000000',
|
'definition-foreground':'#000000',
|
||||||
'definition-background':'#ffffff',
|
'definition-background':'#ffffff',
|
||||||
'hilite-foreground':'#000000',
|
'hilite-foreground':'#000000',
|
||||||
'hilite-background':'gray',
|
'hilite-background':'gray',
|
||||||
|
@ -305,9 +305,9 @@ class IdleConf:
|
||||||
'hit-foreground':'#ffffff',
|
'hit-foreground':'#ffffff',
|
||||||
'hit-background':'#000000',
|
'hit-background':'#000000',
|
||||||
'error-foreground':'#ffffff',
|
'error-foreground':'#ffffff',
|
||||||
'error-background':'#000000',
|
'error-background':'#000000',
|
||||||
#cursor (only foreground can be set)
|
#cursor (only foreground can be set)
|
||||||
'cursor-foreground':'#000000',
|
'cursor-foreground':'#000000',
|
||||||
#shell window
|
#shell window
|
||||||
'stdout-foreground':'#000000',
|
'stdout-foreground':'#000000',
|
||||||
'stdout-background':'#ffffff',
|
'stdout-background':'#ffffff',
|
||||||
|
@ -323,22 +323,22 @@ class IdleConf:
|
||||||
'\n from theme '+`themeName`+'.\n'+
|
'\n from theme '+`themeName`+'.\n'+
|
||||||
' returning default value: '+`theme[element]`+'\n')
|
' returning default value: '+`theme[element]`+'\n')
|
||||||
sys.stderr.write(warning)
|
sys.stderr.write(warning)
|
||||||
colour=cfgParser.Get(themeName,element,default=theme[element])
|
colour=cfgParser.Get(themeName,element,default=theme[element])
|
||||||
theme[element]=colour
|
theme[element]=colour
|
||||||
return theme
|
return theme
|
||||||
|
|
||||||
def CurrentTheme(self):
|
def CurrentTheme(self):
|
||||||
"""
|
"""
|
||||||
Returns the name of the currently active theme
|
Returns the name of the currently active theme
|
||||||
"""
|
"""
|
||||||
return self.GetOption('main','Theme','name',default='')
|
return self.GetOption('main','Theme','name',default='')
|
||||||
|
|
||||||
def CurrentKeys(self):
|
def CurrentKeys(self):
|
||||||
"""
|
"""
|
||||||
Returns the name of the currently active key set
|
Returns the name of the currently active key set
|
||||||
"""
|
"""
|
||||||
return self.GetOption('main','Keys','name',default='')
|
return self.GetOption('main','Keys','name',default='')
|
||||||
|
|
||||||
def GetExtensions(self, activeOnly=1):
|
def GetExtensions(self, activeOnly=1):
|
||||||
"""
|
"""
|
||||||
Gets a list of all idle extensions declared in the config files.
|
Gets a list of all idle extensions declared in the config files.
|
||||||
|
@ -350,7 +350,7 @@ class IdleConf:
|
||||||
self.GetSectionList('user','extensions'))
|
self.GetSectionList('user','extensions'))
|
||||||
for extn in userExtns:
|
for extn in userExtns:
|
||||||
if extn not in extns: #user has added own extension
|
if extn not in extns: #user has added own extension
|
||||||
extns.append(extn)
|
extns.append(extn)
|
||||||
if activeOnly:
|
if activeOnly:
|
||||||
activeExtns=[]
|
activeExtns=[]
|
||||||
for extn in extns:
|
for extn in extns:
|
||||||
|
@ -360,21 +360,21 @@ class IdleConf:
|
||||||
activeExtns.append(extn)
|
activeExtns.append(extn)
|
||||||
return activeExtns
|
return activeExtns
|
||||||
else:
|
else:
|
||||||
return extns
|
return extns
|
||||||
|
|
||||||
def RemoveKeyBindNames(self,extnNameList):
|
def RemoveKeyBindNames(self,extnNameList):
|
||||||
#get rid of keybinding section names
|
#get rid of keybinding section names
|
||||||
names=extnNameList
|
names=extnNameList
|
||||||
kbNameIndicies=[]
|
kbNameIndicies=[]
|
||||||
for name in names:
|
for name in names:
|
||||||
if name.endswith('_bindings') or name.endswith('_cfgBindings'):
|
if name.endswith('_bindings') or name.endswith('_cfgBindings'):
|
||||||
kbNameIndicies.append(names.index(name))
|
kbNameIndicies.append(names.index(name))
|
||||||
kbNameIndicies.sort()
|
kbNameIndicies.sort()
|
||||||
kbNameIndicies.reverse()
|
kbNameIndicies.reverse()
|
||||||
for index in kbNameIndicies: #delete each keybinding section name
|
for index in kbNameIndicies: #delete each keybinding section name
|
||||||
del(names[index])
|
del(names[index])
|
||||||
return names
|
return names
|
||||||
|
|
||||||
def GetExtnNameForEvent(self,virtualEvent):
|
def GetExtnNameForEvent(self,virtualEvent):
|
||||||
"""
|
"""
|
||||||
Returns the name of the extension that virtualEvent is bound in, or
|
Returns the name of the extension that virtualEvent is bound in, or
|
||||||
|
@ -389,7 +389,7 @@ class IdleConf:
|
||||||
if event == vEvent:
|
if event == vEvent:
|
||||||
extName=extn
|
extName=extn
|
||||||
return extName
|
return extName
|
||||||
|
|
||||||
def GetExtensionKeys(self,extensionName):
|
def GetExtensionKeys(self,extensionName):
|
||||||
"""
|
"""
|
||||||
returns a dictionary of the configurable keybindings for a particular
|
returns a dictionary of the configurable keybindings for a particular
|
||||||
|
@ -405,8 +405,8 @@ class IdleConf:
|
||||||
event='<<'+eventName+'>>'
|
event='<<'+eventName+'>>'
|
||||||
binding=activeKeys[event]
|
binding=activeKeys[event]
|
||||||
extKeys[event]=binding
|
extKeys[event]=binding
|
||||||
return extKeys
|
return extKeys
|
||||||
|
|
||||||
def __GetRawExtensionKeys(self,extensionName):
|
def __GetRawExtensionKeys(self,extensionName):
|
||||||
"""
|
"""
|
||||||
returns a dictionary of the configurable keybindings for a particular
|
returns a dictionary of the configurable keybindings for a particular
|
||||||
|
@ -422,13 +422,13 @@ class IdleConf:
|
||||||
eventName,default='').split()
|
eventName,default='').split()
|
||||||
event='<<'+eventName+'>>'
|
event='<<'+eventName+'>>'
|
||||||
extKeys[event]=binding
|
extKeys[event]=binding
|
||||||
return extKeys
|
return extKeys
|
||||||
|
|
||||||
def GetExtensionBindings(self,extensionName):
|
def GetExtensionBindings(self,extensionName):
|
||||||
"""
|
"""
|
||||||
Returns a dictionary of all the event bindings for a particular
|
Returns a dictionary of all the event bindings for a particular
|
||||||
extension. The configurable keybindings are returned as they exist in
|
extension. The configurable keybindings are returned as they exist in
|
||||||
the dictionary returned by GetCurrentKeySet; that is, where re-used
|
the dictionary returned by GetCurrentKeySet; that is, where re-used
|
||||||
keybindings are disabled.
|
keybindings are disabled.
|
||||||
"""
|
"""
|
||||||
bindsName=extensionName+'_bindings'
|
bindsName=extensionName+'_bindings'
|
||||||
|
@ -441,14 +441,14 @@ class IdleConf:
|
||||||
eventName,default='').split()
|
eventName,default='').split()
|
||||||
event='<<'+eventName+'>>'
|
event='<<'+eventName+'>>'
|
||||||
extBinds[event]=binding
|
extBinds[event]=binding
|
||||||
|
|
||||||
return extBinds
|
return extBinds
|
||||||
|
|
||||||
def GetKeyBinding(self, keySetName, eventStr):
|
def GetKeyBinding(self, keySetName, eventStr):
|
||||||
"""
|
"""
|
||||||
returns the keybinding for a specific event.
|
returns the keybinding for a specific event.
|
||||||
keySetName - string, name of key binding set
|
keySetName - string, name of key binding set
|
||||||
eventStr - string, the virtual event we want the binding for,
|
eventStr - string, the virtual event we want the binding for,
|
||||||
represented as a string, eg. '<<event>>'
|
represented as a string, eg. '<<event>>'
|
||||||
"""
|
"""
|
||||||
eventName=eventStr[2:-2] #trim off the angle brackets
|
eventName=eventStr[2:-2] #trim off the angle brackets
|
||||||
|
@ -457,10 +457,10 @@ class IdleConf:
|
||||||
|
|
||||||
def GetCurrentKeySet(self):
|
def GetCurrentKeySet(self):
|
||||||
return self.GetKeySet(self.CurrentKeys())
|
return self.GetKeySet(self.CurrentKeys())
|
||||||
|
|
||||||
def GetKeySet(self,keySetName):
|
def GetKeySet(self,keySetName):
|
||||||
"""
|
"""
|
||||||
Returns a dictionary of: all requested core keybindings, plus the
|
Returns a dictionary of: all requested core keybindings, plus the
|
||||||
keybindings for all currently active extensions. If a binding defined
|
keybindings for all currently active extensions. If a binding defined
|
||||||
in an extension is already in use, that binding is disabled.
|
in an extension is already in use, that binding is disabled.
|
||||||
"""
|
"""
|
||||||
|
@ -483,7 +483,7 @@ class IdleConf:
|
||||||
the enclosing '<< >>'
|
the enclosing '<< >>'
|
||||||
"""
|
"""
|
||||||
return ('<<'+virtualEvent+'>>') in self.GetCoreKeys().keys()
|
return ('<<'+virtualEvent+'>>') in self.GetCoreKeys().keys()
|
||||||
|
|
||||||
def GetCoreKeys(self, keySetName=None):
|
def GetCoreKeys(self, keySetName=None):
|
||||||
"""
|
"""
|
||||||
returns the requested set of core keybindings, with fallbacks if
|
returns the requested set of core keybindings, with fallbacks if
|
||||||
|
@ -504,7 +504,7 @@ class IdleConf:
|
||||||
'<<do-nothing>>': ['<Control-x>'],
|
'<<do-nothing>>': ['<Control-x>'],
|
||||||
'<<end-of-file>>': ['<Control-d>'],
|
'<<end-of-file>>': ['<Control-d>'],
|
||||||
'<<python-docs>>': ['<F1>'],
|
'<<python-docs>>': ['<F1>'],
|
||||||
'<<python-context-help>>': ['<Shift-F1>'],
|
'<<python-context-help>>': ['<Shift-F1>'],
|
||||||
'<<history-next>>': ['<Alt-n>'],
|
'<<history-next>>': ['<Alt-n>'],
|
||||||
'<<history-previous>>': ['<Alt-p>'],
|
'<<history-previous>>': ['<Alt-p>'],
|
||||||
'<<interrupt-execution>>': ['<Control-c>'],
|
'<<interrupt-execution>>': ['<Control-c>'],
|
||||||
|
@ -527,7 +527,7 @@ class IdleConf:
|
||||||
'<<find-selection>>': ['<Control-F3>'],
|
'<<find-selection>>': ['<Control-F3>'],
|
||||||
'<<find>>': ['<Control-f>'],
|
'<<find>>': ['<Control-f>'],
|
||||||
'<<replace>>': ['<Control-h>'],
|
'<<replace>>': ['<Control-h>'],
|
||||||
'<<goto-line>>': ['<Alt-g>'],
|
'<<goto-line>>': ['<Alt-g>'],
|
||||||
'<<smart-backspace>>': ['<Key-BackSpace>'],
|
'<<smart-backspace>>': ['<Key-BackSpace>'],
|
||||||
'<<newline-and-indent>>': ['<Key-Return> <Key-KP_Enter>'],
|
'<<newline-and-indent>>': ['<Key-Return> <Key-KP_Enter>'],
|
||||||
'<<smart-indent>>': ['<Key-Tab>'],
|
'<<smart-indent>>': ['<Key-Tab>'],
|
||||||
|
@ -552,18 +552,18 @@ class IdleConf:
|
||||||
' returning default value: '+`keyBindings[event]`+'\n')
|
' returning default value: '+`keyBindings[event]`+'\n')
|
||||||
sys.stderr.write(warning)
|
sys.stderr.write(warning)
|
||||||
return keyBindings
|
return keyBindings
|
||||||
|
|
||||||
def GetExtraHelpSourceList(self,configSet):
|
def GetExtraHelpSourceList(self,configSet):
|
||||||
"""
|
"""
|
||||||
Returns a list of tuples containing the details of any additional
|
Returns a list of tuples containing the details of any additional
|
||||||
help sources configured in the requested configSet ('user' or 'default')
|
help sources configured in the requested configSet ('user' or 'default')
|
||||||
, or an empty list if there are none. Returned tuples are of the form
|
, or an empty list if there are none. Returned tuples are of the form
|
||||||
form (menu_item , path_to_help_file , option).
|
form (menu_item , path_to_help_file , option).
|
||||||
"""
|
"""
|
||||||
helpSources=[]
|
helpSources=[]
|
||||||
if configSet=='user':
|
if configSet=='user':
|
||||||
cfgParser=self.userCfg['main']
|
cfgParser=self.userCfg['main']
|
||||||
elif configSet=='default':
|
elif configSet=='default':
|
||||||
cfgParser=self.defaultCfg['main']
|
cfgParser=self.defaultCfg['main']
|
||||||
else:
|
else:
|
||||||
raise InvalidConfigSet, 'Invalid configSet specified'
|
raise InvalidConfigSet, 'Invalid configSet specified'
|
||||||
|
@ -583,28 +583,28 @@ class IdleConf:
|
||||||
|
|
||||||
def GetAllExtraHelpSourcesList(self):
|
def GetAllExtraHelpSourcesList(self):
|
||||||
"""
|
"""
|
||||||
Returns a list of tuples containing the details of all additional help
|
Returns a list of tuples containing the details of all additional help
|
||||||
sources configured, or an empty list if there are none. Tuples are of
|
sources configured, or an empty list if there are none. Tuples are of
|
||||||
the format returned by GetExtraHelpSourceList.
|
the format returned by GetExtraHelpSourceList.
|
||||||
"""
|
"""
|
||||||
allHelpSources=( self.GetExtraHelpSourceList('default')+
|
allHelpSources=( self.GetExtraHelpSourceList('default')+
|
||||||
self.GetExtraHelpSourceList('user') )
|
self.GetExtraHelpSourceList('user') )
|
||||||
return allHelpSources
|
return allHelpSources
|
||||||
|
|
||||||
def LoadCfgFiles(self):
|
def LoadCfgFiles(self):
|
||||||
"""
|
"""
|
||||||
load all configuration files.
|
load all configuration files.
|
||||||
"""
|
"""
|
||||||
for key in self.defaultCfg.keys():
|
for key in self.defaultCfg.keys():
|
||||||
self.defaultCfg[key].Load()
|
self.defaultCfg[key].Load()
|
||||||
self.userCfg[key].Load() #same keys
|
self.userCfg[key].Load() #same keys
|
||||||
|
|
||||||
def SaveUserCfgFiles(self):
|
def SaveUserCfgFiles(self):
|
||||||
"""
|
"""
|
||||||
write all loaded user configuration files back to disk
|
write all loaded user configuration files back to disk
|
||||||
"""
|
"""
|
||||||
for key in self.userCfg.keys():
|
for key in self.userCfg.keys():
|
||||||
self.userCfg[key].Save()
|
self.userCfg[key].Save()
|
||||||
|
|
||||||
idleConf=IdleConf()
|
idleConf=IdleConf()
|
||||||
|
|
||||||
|
@ -618,7 +618,7 @@ if __name__ == '__main__':
|
||||||
print sections
|
print sections
|
||||||
for section in sections:
|
for section in sections:
|
||||||
options=cfg[key].options(section)
|
options=cfg[key].options(section)
|
||||||
print section
|
print section
|
||||||
print options
|
print options
|
||||||
for option in options:
|
for option in options:
|
||||||
print option, '=', cfg[key].Get(section,option)
|
print option, '=', cfg[key].Get(section,option)
|
||||||
|
|
|
@ -27,7 +27,7 @@ class GetHelpSourceDialog(Toplevel):
|
||||||
self.withdraw() #hide while setting geometry
|
self.withdraw() #hide while setting geometry
|
||||||
self.update_idletasks()
|
self.update_idletasks()
|
||||||
#needs to be done here so that the winfo_reqwidth is valid
|
#needs to be done here so that the winfo_reqwidth is valid
|
||||||
self.geometry("+%d+%d" %
|
self.geometry("+%d+%d" %
|
||||||
((parent.winfo_rootx()+((parent.winfo_width()/2)
|
((parent.winfo_rootx()+((parent.winfo_width()/2)
|
||||||
-(self.winfo_reqwidth()/2)),
|
-(self.winfo_reqwidth()/2)),
|
||||||
parent.winfo_rooty()+((parent.winfo_height()/2)
|
parent.winfo_rooty()+((parent.winfo_height()/2)
|
||||||
|
@ -63,7 +63,7 @@ class GetHelpSourceDialog(Toplevel):
|
||||||
self.buttonCancel.grid(row=0,column=1,padx=5,pady=5)
|
self.buttonCancel.grid(row=0,column=1,padx=5,pady=5)
|
||||||
|
|
||||||
def MenuOk(self):
|
def MenuOk(self):
|
||||||
#simple validity check for a sensible
|
#simple validity check for a sensible
|
||||||
#menu item name
|
#menu item name
|
||||||
menuOk=1
|
menuOk=1
|
||||||
menu=self.menu.get()
|
menu=self.menu.get()
|
||||||
|
@ -80,9 +80,9 @@ class GetHelpSourceDialog(Toplevel):
|
||||||
self.entryMenu.focus_set()
|
self.entryMenu.focus_set()
|
||||||
menuOk=0
|
menuOk=0
|
||||||
return menuOk
|
return menuOk
|
||||||
|
|
||||||
def PathOk(self):
|
def PathOk(self):
|
||||||
#simple validity check for menu file path
|
#simple validity check for menu file path
|
||||||
pathOk=1
|
pathOk=1
|
||||||
path=self.path.get()
|
path=self.path.get()
|
||||||
path.strip()
|
path.strip()
|
||||||
|
@ -97,13 +97,13 @@ class GetHelpSourceDialog(Toplevel):
|
||||||
self.entryPath.focus_set()
|
self.entryPath.focus_set()
|
||||||
pathOk=0
|
pathOk=0
|
||||||
return pathOk
|
return pathOk
|
||||||
|
|
||||||
def Ok(self, event=None):
|
def Ok(self, event=None):
|
||||||
if self.MenuOk():
|
if self.MenuOk():
|
||||||
if self.PathOk():
|
if self.PathOk():
|
||||||
self.result=( self.menu.get().strip(),self.path.get().strip() )
|
self.result=( self.menu.get().strip(),self.path.get().strip() )
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
def Cancel(self, event=None):
|
def Cancel(self, event=None):
|
||||||
self.result=None
|
self.result=None
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
@ -117,5 +117,3 @@ if __name__ == '__main__':
|
||||||
print dlg.result
|
print dlg.result
|
||||||
Button(root,text='Dialog',command=run).pack()
|
Button(root,text='Dialog',command=run).pack()
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ class GetCfgSectionNameDialog(Toplevel):
|
||||||
self.update_idletasks()
|
self.update_idletasks()
|
||||||
#needs to be done here so that the winfo_reqwidth is valid
|
#needs to be done here so that the winfo_reqwidth is valid
|
||||||
self.messageInfo.config(width=self.frameMain.winfo_reqwidth())
|
self.messageInfo.config(width=self.frameMain.winfo_reqwidth())
|
||||||
self.geometry("+%d+%d" %
|
self.geometry("+%d+%d" %
|
||||||
((parent.winfo_rootx()+((parent.winfo_width()/2)
|
((parent.winfo_rootx()+((parent.winfo_width()/2)
|
||||||
-(self.winfo_reqwidth()/2)),
|
-(self.winfo_reqwidth()/2)),
|
||||||
parent.winfo_rooty()+((parent.winfo_height()/2)
|
parent.winfo_rooty()+((parent.winfo_height()/2)
|
||||||
|
@ -56,7 +56,7 @@ class GetCfgSectionNameDialog(Toplevel):
|
||||||
self.buttonCancel.grid(row=0,column=1,padx=5,pady=5)
|
self.buttonCancel.grid(row=0,column=1,padx=5,pady=5)
|
||||||
|
|
||||||
def NameOk(self):
|
def NameOk(self):
|
||||||
#simple validity check for a sensible
|
#simple validity check for a sensible
|
||||||
#ConfigParser file section name
|
#ConfigParser file section name
|
||||||
nameOk=1
|
nameOk=1
|
||||||
name=self.name.get()
|
name=self.name.get()
|
||||||
|
@ -75,12 +75,12 @@ class GetCfgSectionNameDialog(Toplevel):
|
||||||
message='This name is already in use.')
|
message='This name is already in use.')
|
||||||
nameOk=0
|
nameOk=0
|
||||||
return nameOk
|
return nameOk
|
||||||
|
|
||||||
def Ok(self, event=None):
|
def Ok(self, event=None):
|
||||||
if self.NameOk():
|
if self.NameOk():
|
||||||
self.result=self.name.get().strip()
|
self.result=self.name.get().strip()
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
def Cancel(self, event=None):
|
def Cancel(self, event=None):
|
||||||
self.result=''
|
self.result=''
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
@ -95,5 +95,3 @@ if __name__ == '__main__':
|
||||||
print dlg.result
|
print dlg.result
|
||||||
Button(root,text='Dialog',command=run).pack()
|
Button(root,text='Dialog',command=run).pack()
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,12 +20,12 @@ class DynOptionMenu(OptionMenu):
|
||||||
#self.menu=self['menu']
|
#self.menu=self['menu']
|
||||||
self.variable=variable
|
self.variable=variable
|
||||||
self.command=kwargs.get('command')
|
self.command=kwargs.get('command')
|
||||||
|
|
||||||
def SetMenu(self,valueList,value=None):
|
def SetMenu(self,valueList,value=None):
|
||||||
"""
|
"""
|
||||||
clear and reload the menu with a new set of options.
|
clear and reload the menu with a new set of options.
|
||||||
valueList - list of new options
|
valueList - list of new options
|
||||||
value - initial value to set the optionmenu's menubutton to
|
value - initial value to set the optionmenu's menubutton to
|
||||||
"""
|
"""
|
||||||
self['menu'].delete(0,'end')
|
self['menu'].delete(0,'end')
|
||||||
for item in valueList:
|
for item in valueList:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"""
|
"""
|
||||||
dialog for building tkinter accelerator key bindings
|
dialog for building tkinter accelerator key bindings
|
||||||
"""
|
"""
|
||||||
from Tkinter import *
|
from Tkinter import *
|
||||||
import tkMessageBox
|
import tkMessageBox
|
||||||
|
@ -11,7 +11,7 @@ class GetKeysDialog(Toplevel):
|
||||||
action - string, the name of the virtual event these keys will be
|
action - string, the name of the virtual event these keys will be
|
||||||
mapped to
|
mapped to
|
||||||
currentKeys - list, a list of all key sequence lists currently mapped
|
currentKeys - list, a list of all key sequence lists currently mapped
|
||||||
to virtual events, for overlap checking
|
to virtual events, for overlap checking
|
||||||
"""
|
"""
|
||||||
Toplevel.__init__(self, parent)
|
Toplevel.__init__(self, parent)
|
||||||
self.configure(borderwidth=5)
|
self.configure(borderwidth=5)
|
||||||
|
@ -36,14 +36,14 @@ class GetKeysDialog(Toplevel):
|
||||||
self.LoadFinalKeyList()
|
self.LoadFinalKeyList()
|
||||||
self.withdraw() #hide while setting geometry
|
self.withdraw() #hide while setting geometry
|
||||||
self.update_idletasks()
|
self.update_idletasks()
|
||||||
self.geometry("+%d+%d" %
|
self.geometry("+%d+%d" %
|
||||||
((parent.winfo_rootx()+((parent.winfo_width()/2)
|
((parent.winfo_rootx()+((parent.winfo_width()/2)
|
||||||
-(self.winfo_reqwidth()/2)),
|
-(self.winfo_reqwidth()/2)),
|
||||||
parent.winfo_rooty()+((parent.winfo_height()/2)
|
parent.winfo_rooty()+((parent.winfo_height()/2)
|
||||||
-(self.winfo_reqheight()/2)) )) ) #centre dialog over parent
|
-(self.winfo_reqheight()/2)) )) ) #centre dialog over parent
|
||||||
self.deiconify() #geometry set, unhide
|
self.deiconify() #geometry set, unhide
|
||||||
self.wait_window()
|
self.wait_window()
|
||||||
|
|
||||||
def CreateWidgets(self):
|
def CreateWidgets(self):
|
||||||
frameMain = Frame(self,borderwidth=2,relief=SUNKEN)
|
frameMain = Frame(self,borderwidth=2,relief=SUNKEN)
|
||||||
frameMain.pack(side=TOP,expand=TRUE,fill=BOTH)
|
frameMain.pack(side=TOP,expand=TRUE,fill=BOTH)
|
||||||
|
@ -143,19 +143,19 @@ class GetKeysDialog(Toplevel):
|
||||||
self.ClearKeySeq()
|
self.ClearKeySeq()
|
||||||
self.buttonLevel.config(text='Advanced Key Binding Entry >>')
|
self.buttonLevel.config(text='Advanced Key Binding Entry >>')
|
||||||
self.frameKeySeqBasic.lift()
|
self.frameKeySeqBasic.lift()
|
||||||
self.frameControlsBasic.lift()
|
self.frameControlsBasic.lift()
|
||||||
|
|
||||||
def FinalKeySelected(self,event):
|
def FinalKeySelected(self,event):
|
||||||
self.BuildKeyString()
|
self.BuildKeyString()
|
||||||
|
|
||||||
def BuildKeyString(self):
|
def BuildKeyString(self):
|
||||||
keyList=[]
|
keyList=[]
|
||||||
modifiers=self.GetModifiers()
|
modifiers=self.GetModifiers()
|
||||||
finalKey=self.listKeysFinal.get(ANCHOR)
|
finalKey=self.listKeysFinal.get(ANCHOR)
|
||||||
if modifiers: modifiers[0]='<'+modifiers[0]
|
if modifiers: modifiers[0]='<'+modifiers[0]
|
||||||
keyList=keyList+modifiers
|
keyList=keyList+modifiers
|
||||||
if finalKey:
|
if finalKey:
|
||||||
if (not modifiers) and (finalKey not
|
if (not modifiers) and (finalKey not
|
||||||
in self.alphanumKeys+self.punctuationKeys):
|
in self.alphanumKeys+self.punctuationKeys):
|
||||||
finalKey='<'+self.TranslateKey(finalKey)
|
finalKey='<'+self.TranslateKey(finalKey)
|
||||||
else:
|
else:
|
||||||
|
@ -163,7 +163,7 @@ class GetKeysDialog(Toplevel):
|
||||||
keyList.append(finalKey+'>')
|
keyList.append(finalKey+'>')
|
||||||
keyStr=string.join(keyList,'-')
|
keyStr=string.join(keyList,'-')
|
||||||
self.keyString.set(keyStr)
|
self.keyString.set(keyStr)
|
||||||
|
|
||||||
def GetModifiers(self):
|
def GetModifiers(self):
|
||||||
modList = [variable.get() for variable in self.modifier_vars]
|
modList = [variable.get() for variable in self.modifier_vars]
|
||||||
return filter(None, modList)
|
return filter(None, modList)
|
||||||
|
@ -174,7 +174,7 @@ class GetKeysDialog(Toplevel):
|
||||||
for variable in self.modifier_vars:
|
for variable in self.modifier_vars:
|
||||||
variable.set('')
|
variable.set('')
|
||||||
self.keyString.set('')
|
self.keyString.set('')
|
||||||
|
|
||||||
def LoadFinalKeyList(self):
|
def LoadFinalKeyList(self):
|
||||||
#these tuples are also available for use in validity checks
|
#these tuples are also available for use in validity checks
|
||||||
self.functionKeys=('F1','F2','F2','F4','F5','F6','F7','F8','F9',
|
self.functionKeys=('F1','F2','F2','F4','F5','F6','F7','F8','F9',
|
||||||
|
@ -190,7 +190,7 @@ class GetKeysDialog(Toplevel):
|
||||||
self.whitespaceKeys+self.editKeys+self.moveKeys)
|
self.whitespaceKeys+self.editKeys+self.moveKeys)
|
||||||
apply(self.listKeysFinal.insert,
|
apply(self.listKeysFinal.insert,
|
||||||
(END,)+keys)
|
(END,)+keys)
|
||||||
|
|
||||||
def TranslateKey(self,key):
|
def TranslateKey(self,key):
|
||||||
#translate from key list value to tkinter key-id
|
#translate from key list value to tkinter key-id
|
||||||
translateDict={'~':'asciitilde','!':'exclam','@':'at','#':'numbersign',
|
translateDict={'~':'asciitilde','!':'exclam','@':'at','#':'numbersign',
|
||||||
|
@ -206,16 +206,16 @@ class GetKeysDialog(Toplevel):
|
||||||
key=translateDict[key]
|
key=translateDict[key]
|
||||||
key='Key-'+key
|
key='Key-'+key
|
||||||
return key
|
return key
|
||||||
|
|
||||||
def Ok(self, event=None):
|
def Ok(self, event=None):
|
||||||
if self.KeysOk():
|
if self.KeysOk():
|
||||||
self.result=self.keyString.get()
|
self.result=self.keyString.get()
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
def Cancel(self, event=None):
|
def Cancel(self, event=None):
|
||||||
self.result=''
|
self.result=''
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
def KeysOk(self):
|
def KeysOk(self):
|
||||||
#simple validity check
|
#simple validity check
|
||||||
keysOk=1
|
keysOk=1
|
||||||
|
@ -232,13 +232,13 @@ class GetKeysDialog(Toplevel):
|
||||||
tkMessageBox.showerror(title='Key Sequence Error',
|
tkMessageBox.showerror(title='Key Sequence Error',
|
||||||
message='No final key specified.')
|
message='No final key specified.')
|
||||||
keysOk=0
|
keysOk=0
|
||||||
elif (not modifiers) and (finalKey in
|
elif (not modifiers) and (finalKey in
|
||||||
self.alphanumKeys+self.punctuationKeys):
|
self.alphanumKeys+self.punctuationKeys):
|
||||||
#modifier required
|
#modifier required
|
||||||
tkMessageBox.showerror(title='Key Sequence Error',
|
tkMessageBox.showerror(title='Key Sequence Error',
|
||||||
message='No modifier key(s) specified.')
|
message='No modifier key(s) specified.')
|
||||||
keysOk=0
|
keysOk=0
|
||||||
elif (modifiers==['Shift']) and (finalKey not
|
elif (modifiers==['Shift']) and (finalKey not
|
||||||
in self.functionKeys+('Tab',)):
|
in self.functionKeys+('Tab',)):
|
||||||
#shift alone is only a useful modifier with a function key
|
#shift alone is only a useful modifier with a function key
|
||||||
tkMessageBox.showerror(title='Key Sequence Error',
|
tkMessageBox.showerror(title='Key Sequence Error',
|
||||||
|
@ -250,7 +250,7 @@ class GetKeysDialog(Toplevel):
|
||||||
message='This key combination is already in use.')
|
message='This key combination is already in use.')
|
||||||
keysOk=0
|
keysOk=0
|
||||||
return keysOk
|
return keysOk
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
#test the dialog
|
#test the dialog
|
||||||
root=Tk()
|
root=Tk()
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
|
|
||||||
Installation:
|
Installation:
|
||||||
see the install_IDLE target in python/dist/src/Mac/OSX/Makefile
|
see the install_IDLE target in python/dist/src/Mac/OSX/Makefile
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
1. Double clicking IDLE icon will open IDLE.
|
1. Double clicking IDLE icon will open IDLE.
|
||||||
2. Dropping file on IDLE icon will open that file in IDLE.
|
2. Dropping file on IDLE icon will open that file in IDLE.
|
||||||
|
@ -26,7 +26,7 @@ except NameError:
|
||||||
__file__ = sys.argv[0]
|
__file__ = sys.argv[0]
|
||||||
idlelib = join(split(__file__)[0], 'idlelib')
|
idlelib = join(split(__file__)[0], 'idlelib')
|
||||||
if isdir(idlelib):
|
if isdir(idlelib):
|
||||||
sys.path.append(idlelib)
|
sys.path.append(idlelib)
|
||||||
|
|
||||||
# see if we are being asked to execute the subprocess code
|
# see if we are being asked to execute the subprocess code
|
||||||
if '-p' in sys.argv:
|
if '-p' in sys.argv:
|
||||||
|
|
|
@ -56,7 +56,7 @@ def pickle_code(co):
|
||||||
# def pickle_function(fn):
|
# def pickle_function(fn):
|
||||||
# assert isinstance(fn, type.FunctionType)
|
# assert isinstance(fn, type.FunctionType)
|
||||||
# return `fn`
|
# return `fn`
|
||||||
|
|
||||||
copy_reg.pickle(types.CodeType, pickle_code, unpickle_code)
|
copy_reg.pickle(types.CodeType, pickle_code, unpickle_code)
|
||||||
# copy_reg.pickle(types.FunctionType, pickle_function, unpickle_function)
|
# copy_reg.pickle(types.FunctionType, pickle_function, unpickle_function)
|
||||||
|
|
||||||
|
@ -75,13 +75,13 @@ class RPCServer(SocketServer.TCPServer):
|
||||||
|
|
||||||
def server_activate(self):
|
def server_activate(self):
|
||||||
"""Override TCPServer method, connect() instead of listen()
|
"""Override TCPServer method, connect() instead of listen()
|
||||||
|
|
||||||
Due to the reversed connection, self.server_address is actually the
|
Due to the reversed connection, self.server_address is actually the
|
||||||
address of the Idle Client to which we are connecting.
|
address of the Idle Client to which we are connecting.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.socket.connect(self.server_address)
|
self.socket.connect(self.server_address)
|
||||||
|
|
||||||
def get_request(self):
|
def get_request(self):
|
||||||
"Override TCPServer method, return already connected socket"
|
"Override TCPServer method, return already connected socket"
|
||||||
return self.socket, self.server_address
|
return self.socket, self.server_address
|
||||||
|
@ -126,7 +126,7 @@ class SocketIO:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def localcall(self, request):
|
def localcall(self, request):
|
||||||
self.debug("localcall:", request)
|
self.debug("localcall:", request)
|
||||||
try:
|
try:
|
||||||
how, (oid, methodname, args, kwargs) = request
|
how, (oid, methodname, args, kwargs) = request
|
||||||
except TypeError:
|
except TypeError:
|
||||||
|
@ -174,7 +174,7 @@ class SocketIO:
|
||||||
return ("EXCEPTION", (mod, name, args, tb))
|
return ("EXCEPTION", (mod, name, args, tb))
|
||||||
|
|
||||||
def remotecall(self, oid, methodname, args, kwargs):
|
def remotecall(self, oid, methodname, args, kwargs):
|
||||||
self.debug("remotecall:")
|
self.debug("remotecall:")
|
||||||
seq = self.asynccall(oid, methodname, args, kwargs)
|
seq = self.asynccall(oid, methodname, args, kwargs)
|
||||||
return self.asyncreturn(seq)
|
return self.asyncreturn(seq)
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ class SocketIO:
|
||||||
# do the best we can:
|
# do the best we can:
|
||||||
raise name, args
|
raise name, args
|
||||||
if how == "ERROR":
|
if how == "ERROR":
|
||||||
self.debug("decoderesponse: Internal ERROR:", what)
|
self.debug("decoderesponse: Internal ERROR:", what)
|
||||||
raise RuntimeError, what
|
raise RuntimeError, what
|
||||||
raise SystemError, (how, what)
|
raise SystemError, (how, what)
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ class SocketIO:
|
||||||
cv.notify()
|
cv.notify()
|
||||||
self.statelock.release()
|
self.statelock.release()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#----------------- end class SocketIO --------------------
|
#----------------- end class SocketIO --------------------
|
||||||
|
|
||||||
class RemoteObject:
|
class RemoteObject:
|
||||||
|
@ -465,7 +465,7 @@ def _getattributes(obj, attributes):
|
||||||
for name in dir(obj):
|
for name in dir(obj):
|
||||||
attr = getattr(obj, name)
|
attr = getattr(obj, name)
|
||||||
if not callable(attr):
|
if not callable(attr):
|
||||||
attributes[name] = 1
|
attributes[name] = 1
|
||||||
|
|
||||||
class MethodProxy:
|
class MethodProxy:
|
||||||
|
|
||||||
|
@ -486,14 +486,14 @@ def testServer(addr):
|
||||||
# XXX 25 Jul 02 KBK needs update to use rpc.py register/unregister methods
|
# XXX 25 Jul 02 KBK needs update to use rpc.py register/unregister methods
|
||||||
class RemotePerson:
|
class RemotePerson:
|
||||||
def __init__(self,name):
|
def __init__(self,name):
|
||||||
self.name = name
|
self.name = name
|
||||||
def greet(self, name):
|
def greet(self, name):
|
||||||
print "(someone called greet)"
|
print "(someone called greet)"
|
||||||
print "Hello %s, I am %s." % (name, self.name)
|
print "Hello %s, I am %s." % (name, self.name)
|
||||||
print
|
print
|
||||||
def getName(self):
|
def getName(self):
|
||||||
print "(someone called getName)"
|
print "(someone called getName)"
|
||||||
print
|
print
|
||||||
return self.name
|
return self.name
|
||||||
def greet_this_guy(self, name):
|
def greet_this_guy(self, name):
|
||||||
print "(someone called greet_this_guy)"
|
print "(someone called greet_this_guy)"
|
||||||
|
@ -502,7 +502,7 @@ def testServer(addr):
|
||||||
remote_guy.greet("Thomas Edison")
|
remote_guy.greet("Thomas Edison")
|
||||||
print "Done."
|
print "Done."
|
||||||
print
|
print
|
||||||
|
|
||||||
person = RemotePerson("Thomas Edison")
|
person = RemotePerson("Thomas Edison")
|
||||||
svr = RPCServer(addr)
|
svr = RPCServer(addr)
|
||||||
svr.register('thomas', person)
|
svr.register('thomas', person)
|
||||||
|
@ -526,12 +526,12 @@ def testClient(addr):
|
||||||
thomas.greet("Alexander Bell")
|
thomas.greet("Alexander Bell")
|
||||||
#clt.remotecall("thomas","greet",("Alexander Bell",), {})
|
#clt.remotecall("thomas","greet",("Alexander Bell",), {})
|
||||||
print "Done."
|
print "Done."
|
||||||
print
|
print
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
# demonstrates remote server calling local instance
|
# demonstrates remote server calling local instance
|
||||||
class LocalPerson:
|
class LocalPerson:
|
||||||
def __init__(self,name):
|
def __init__(self,name):
|
||||||
self.name = name
|
self.name = name
|
||||||
def greet(self, name):
|
def greet(self, name):
|
||||||
print "You've greeted me!"
|
print "You've greeted me!"
|
||||||
def getName(self):
|
def getName(self):
|
||||||
|
@ -551,5 +551,3 @@ def test():
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
test()
|
test()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,23 +10,23 @@ class AlreadyExists(Exception): pass
|
||||||
class PageTab(Frame):
|
class PageTab(Frame):
|
||||||
"""
|
"""
|
||||||
a 'page tab' like framed button
|
a 'page tab' like framed button
|
||||||
"""
|
"""
|
||||||
def __init__(self,parent):
|
def __init__(self,parent):
|
||||||
Frame.__init__(self, parent,borderwidth=2,relief=RIDGE)
|
Frame.__init__(self, parent,borderwidth=2,relief=RIDGE)
|
||||||
self.button=Radiobutton(self,padx=5,pady=5,takefocus=FALSE,
|
self.button=Radiobutton(self,padx=5,pady=5,takefocus=FALSE,
|
||||||
indicatoron=FALSE,highlightthickness=0,
|
indicatoron=FALSE,highlightthickness=0,
|
||||||
borderwidth=0,selectcolor=self.cget('bg'))
|
borderwidth=0,selectcolor=self.cget('bg'))
|
||||||
self.button.pack()
|
self.button.pack()
|
||||||
|
|
||||||
class TabPageSet(Frame):
|
class TabPageSet(Frame):
|
||||||
"""
|
"""
|
||||||
a set of 'pages' with TabButtons for controlling their display
|
a set of 'pages' with TabButtons for controlling their display
|
||||||
"""
|
"""
|
||||||
def __init__(self,parent,pageNames=[],**kw):
|
def __init__(self,parent,pageNames=[],**kw):
|
||||||
"""
|
"""
|
||||||
pageNames - a list of strings, each string will be the dictionary key
|
pageNames - a list of strings, each string will be the dictionary key
|
||||||
to a page's data, and the name displayed on the page's tab. Should be
|
to a page's data, and the name displayed on the page's tab. Should be
|
||||||
specified in desired page order. The first page will be the default
|
specified in desired page order. The first page will be the default
|
||||||
and first active page.
|
and first active page.
|
||||||
"""
|
"""
|
||||||
Frame.__init__(self, parent, kw)
|
Frame.__init__(self, parent, kw)
|
||||||
|
@ -48,12 +48,12 @@ class TabPageSet(Frame):
|
||||||
else:
|
else:
|
||||||
raise InvalidTabPage, 'Invalid TabPage Name'
|
raise InvalidTabPage, 'Invalid TabPage Name'
|
||||||
## pop up the active 'tab' only
|
## pop up the active 'tab' only
|
||||||
for page in self.pages.keys():
|
for page in self.pages.keys():
|
||||||
self.pages[page]['tab'].config(relief=RIDGE)
|
self.pages[page]['tab'].config(relief=RIDGE)
|
||||||
self.pages[self.GetActivePage()]['tab'].config(relief=RAISED)
|
self.pages[self.GetActivePage()]['tab'].config(relief=RAISED)
|
||||||
## switch page
|
## switch page
|
||||||
self.pages[self.GetActivePage()]['page'].lift()
|
self.pages[self.GetActivePage()]['page'].lift()
|
||||||
|
|
||||||
def GetActivePage(self):
|
def GetActivePage(self):
|
||||||
return self.activePage.get()
|
return self.activePage.get()
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class TabPageSet(Frame):
|
||||||
value=pageName)
|
value=pageName)
|
||||||
self.pages[pageName]['tab'].pack(side=LEFT)
|
self.pages[pageName]['tab'].pack(side=LEFT)
|
||||||
self.pages[pageName]['page'].grid(row=1,column=0,sticky=NSEW)
|
self.pages[pageName]['page'].grid(row=1,column=0,sticky=NSEW)
|
||||||
if len(self.pages)==1: # adding first page
|
if len(self.pages)==1: # adding first page
|
||||||
self.defaultPage=pageName
|
self.defaultPage=pageName
|
||||||
self.activePage.set(self.defaultPage)
|
self.activePage.set(self.defaultPage)
|
||||||
self.ChangePage()
|
self.ChangePage()
|
||||||
|
@ -83,11 +83,11 @@ class TabPageSet(Frame):
|
||||||
# handle removing last remaining, or default, or active page
|
# handle removing last remaining, or default, or active page
|
||||||
if not self.pages: # removed last remaining page
|
if not self.pages: # removed last remaining page
|
||||||
self.defaultPage=''
|
self.defaultPage=''
|
||||||
return
|
return
|
||||||
if pageName==self.defaultPage: # set a new default page
|
if pageName==self.defaultPage: # set a new default page
|
||||||
self.defaultPage=\
|
self.defaultPage=\
|
||||||
self.tabBar.winfo_children()[0].button.cget('text')
|
self.tabBar.winfo_children()[0].button.cget('text')
|
||||||
if pageName==self.GetActivePage(): # set a new active page
|
if pageName==self.GetActivePage(): # set a new active page
|
||||||
self.activePage.set(self.defaultPage)
|
self.activePage.set(self.defaultPage)
|
||||||
self.ChangePage()
|
self.ChangePage()
|
||||||
|
|
||||||
|
@ -111,4 +111,3 @@ if __name__ == '__main__':
|
||||||
entryPgName.pack(padx=5)
|
entryPgName.pack(padx=5)
|
||||||
tabPage.ChangePage()
|
tabPage.ChangePage()
|
||||||
root.mainloop()
|
root.mainloop()
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
##---------------------------------------------------------------------------##
|
##---------------------------------------------------------------------------##
|
||||||
##
|
##
|
||||||
## idle - simple text view dialog
|
## idle - simple text view dialog
|
||||||
## elguavas
|
## elguavas
|
||||||
##
|
##
|
||||||
##---------------------------------------------------------------------------##
|
##---------------------------------------------------------------------------##
|
||||||
"""
|
"""
|
||||||
simple text browser for idle
|
simple text browser for idle
|
||||||
|
@ -13,7 +13,7 @@ import tkMessageBox
|
||||||
class TextViewer(Toplevel):
|
class TextViewer(Toplevel):
|
||||||
"""
|
"""
|
||||||
simple text viewer dialog for idle
|
simple text viewer dialog for idle
|
||||||
"""
|
"""
|
||||||
def __init__(self,parent,title,fileName):
|
def __init__(self,parent,title,fileName):
|
||||||
"""
|
"""
|
||||||
fileName - string,should be an absoulute filename
|
fileName - string,should be an absoulute filename
|
||||||
|
@ -39,7 +39,7 @@ class TextViewer(Toplevel):
|
||||||
self.LoadTextFile(fileName)
|
self.LoadTextFile(fileName)
|
||||||
self.textView.config(state=DISABLED)
|
self.textView.config(state=DISABLED)
|
||||||
self.wait_window()
|
self.wait_window()
|
||||||
|
|
||||||
def LoadTextFile(self, fileName):
|
def LoadTextFile(self, fileName):
|
||||||
textFile = None
|
textFile = None
|
||||||
try:
|
try:
|
||||||
|
@ -49,7 +49,7 @@ class TextViewer(Toplevel):
|
||||||
message='Unable to load file '+`fileName`+' .')
|
message='Unable to load file '+`fileName`+' .')
|
||||||
else:
|
else:
|
||||||
self.textView.insert(0.0,textFile.read())
|
self.textView.insert(0.0,textFile.read())
|
||||||
|
|
||||||
def CreateWidgets(self):
|
def CreateWidgets(self):
|
||||||
frameText = Frame(self)
|
frameText = Frame(self)
|
||||||
frameButtons = Frame(self)
|
frameButtons = Frame(self)
|
||||||
|
@ -65,7 +65,7 @@ class TextViewer(Toplevel):
|
||||||
self.textView.pack(side=LEFT,expand=TRUE,fill=BOTH)
|
self.textView.pack(side=LEFT,expand=TRUE,fill=BOTH)
|
||||||
frameButtons.pack(side=BOTTOM,fill=X)
|
frameButtons.pack(side=BOTTOM,fill=X)
|
||||||
frameText.pack(side=TOP,expand=TRUE,fill=BOTH)
|
frameText.pack(side=TOP,expand=TRUE,fill=BOTH)
|
||||||
|
|
||||||
def Ok(self, event=None):
|
def Ok(self, event=None):
|
||||||
self.destroy()
|
self.destroy()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue