Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(291)

Delta Between Two Patch Sets: Lib/idlelib/macosxSupport.py

Issue 13884: IDLE 2.6.5 Recent Files undocks
Left Patch Set: Created 4 years, 6 months ago
Right Patch Set: Created 4 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « Lib/idlelib/help.txt ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 """ 1 """
2 A number of functions that enhance IDLE on Mac OSX. 2 A number of functions that enhance IDLE on Mac OSX.
3 """ 3 """
4 import sys 4 import sys
5 import tkinter 5 import Tkinter
6 from os import path 6 from os import path
7
8
7 import warnings 9 import warnings
8 10
9 def runningAsOSXApp(): 11 def runningAsOSXApp():
10 warnings.warn("runningAsOSXApp() is deprecated, use isAquaTk()", 12 warnings.warn("runningAsOSXApp() is deprecated, use isAquaTk()",
11 DeprecationWarning, stacklevel=2) 13 DeprecationWarning, stacklevel=2)
12 return isAquaTk() 14 return isAquaTk()
13 15
14 def isCarbonAquaTk(root): 16 def isCarbonAquaTk(root):
15 warnings.warn("isCarbonAquaTk(root) is deprecated, use isCarbonTk()", 17 warnings.warn("isCarbonAquaTk(root) is deprecated, use isCarbonTk()",
16 DeprecationWarning, stacklevel=2) 18 DeprecationWarning, stacklevel=2)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 flist.open(fn) 98 flist.open(fn)
97 99
98 # The command below is a hook in aquatk that is called whenever the app 100 # The command below is a hook in aquatk that is called whenever the app
99 # receives a file open event. The callback can have multiple arguments, 101 # receives a file open event. The callback can have multiple arguments,
100 # one for every file that should be opened. 102 # one for every file that should be opened.
101 root.createcommand("::tk::mac::OpenDocument", doOpenFile) 103 root.createcommand("::tk::mac::OpenDocument", doOpenFile)
102 104
103 def hideTkConsole(root): 105 def hideTkConsole(root):
104 try: 106 try:
105 root.tk.call('console', 'hide') 107 root.tk.call('console', 'hide')
106 except tkinter.TclError: 108 except Tkinter.TclError:
107 # Some versions of the Tk framework don't have a console object 109 # Some versions of the Tk framework don't have a console object
108 pass 110 pass
109 111
110 def overrideRootMenu(root, flist): 112 def overrideRootMenu(root, flist):
111 """ 113 """
112 Replace the Tk root menu by something that is more appropriate for 114 Replace the Tk root menu by something that is more appropriate for
113 IDLE with an Aqua Tk. 115 IDLE with an Aqua Tk.
114 """ 116 """
115 # The menu that is attached to the Tk root (".") is also used by AquaTk for 117 # The menu that is attached to the Tk root (".") is also used by AquaTk for
116 # all windows that don't specify a menu of their own. The default menubar 118 # all windows that don't specify a menu of their own. The default menubar
117 # contains a number of menus, none of which are appropriate for IDLE. The 119 # contains a number of menus, none of which are appropriate for IDLE. The
118 # Most annoying of those is an 'About Tck/Tk...' menu in the application 120 # Most annoying of those is an 'About Tck/Tk...' menu in the application
119 # menu. 121 # menu.
120 # 122 #
121 # This function replaces the default menubar by a mostly empty one, it 123 # This function replaces the default menubar by a mostly empty one, it
122 # should only contain the correct application menu and the window menu. 124 # should only contain the correct application menu and the window menu.
123 # 125 #
124 # Due to a (mis-)feature of TkAqua the user will also see an empty Help 126 # Due to a (mis-)feature of TkAqua the user will also see an empty Help
125 # menu. 127 # menu.
126 from tkinter import Menu 128 from Tkinter import Menu
127 from idlelib import Bindings 129 from idlelib import Bindings
128 from idlelib import WindowList 130 from idlelib import WindowList
129 131
130 closeItem = Bindings.menudefs[0][1][-2] 132 closeItem = Bindings.menudefs[0][1][-2]
131 133
132 # Remove the last 3 items of the file menu: a separator, close window and 134 # Remove the last 3 items of the file menu: a separator, close window and
133 # quit. Close window will be reinserted just above the save item, where 135 # quit. Close window will be reinserted just above the save item, where
134 # it should be according to the HIG. Quit is in the application menu. 136 # it should be according to the HIG. Quit is in the application menu.
135 del Bindings.menudefs[0][1][-3:] 137 del Bindings.menudefs[0][1][-3:]
136 Bindings.menudefs[0][1].insert(6, closeItem) 138 Bindings.menudefs[0][1].insert(6, closeItem)
(...skipping 20 matching lines...) Expand all
157 menu.delete(0, end) 159 menu.delete(0, end)
158 WindowList.add_windows_to_menu(menu) 160 WindowList.add_windows_to_menu(menu)
159 WindowList.register_callback(postwindowsmenu) 161 WindowList.register_callback(postwindowsmenu)
160 162
161 def about_dialog(event=None): 163 def about_dialog(event=None):
162 from idlelib import aboutDialog 164 from idlelib import aboutDialog
163 aboutDialog.AboutDialog(root, 'About IDLE') 165 aboutDialog.AboutDialog(root, 'About IDLE')
164 166
165 def config_dialog(event=None): 167 def config_dialog(event=None):
166 from idlelib import configDialog 168 from idlelib import configDialog
167
168 # Ensure that the root object has an instance_dict attribute,
169 # mirrors code in EditorWindow (although that sets the attribute
170 # on an EditorWindow instance that is then passed as the first
171 # argument to ConfigDialog)
172 root.instance_dict = flist.inversedict
173 root.instance_dict = flist.inversedict 169 root.instance_dict = flist.inversedict
174 configDialog.ConfigDialog(root, 'Settings') 170 configDialog.ConfigDialog(root, 'Settings')
175 171
176 def help_dialog(event=None): 172 def help_dialog(event=None):
177 from idlelib import textView 173 from idlelib import textView
178 fn = path.join(path.abspath(path.dirname(__file__)), 'help.txt') 174 fn = path.join(path.abspath(path.dirname(__file__)), 'help.txt')
179 textView.view_file(root, 'Help', fn) 175 textView.view_file(root, 'Help', fn)
180 176
181 root.bind('<<about-idle>>', about_dialog) 177 root.bind('<<about-idle>>', about_dialog)
182 root.bind('<<open-config-dialog>>', config_dialog) 178 root.bind('<<open-config-dialog>>', config_dialog)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 Some one-time customizations are performed here. 223 Some one-time customizations are performed here.
228 Others are dynamically tested throughout idlelib by calls to the 224 Others are dynamically tested throughout idlelib by calls to the
229 isAquaTk(), isCarbonTk(), isCocoaTk(), isXQuartz() functions which 225 isAquaTk(), isCarbonTk(), isCocoaTk(), isXQuartz() functions which
230 are initialized here as well. 226 are initialized here as well.
231 """ 227 """
232 _initializeTkVariantTests(root) 228 _initializeTkVariantTests(root)
233 if isAquaTk(): 229 if isAquaTk():
234 hideTkConsole(root) 230 hideTkConsole(root)
235 overrideRootMenu(root, flist) 231 overrideRootMenu(root, flist)
236 addOpenEventSupport(root, flist) 232 addOpenEventSupport(root, flist)
LEFTRIGHT

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+