def __init__(self, flist=None, filename=None, key=None, root=None): if EditorWindow.help_url is None: dochome = os.path.join(sys.prefix, 'Doc', 'index.html') if sys.platform.count('linux'): pyver = 'python-docs-' + '%s.%s.%s' % sys.version_info[:3] if os.path.isdir('/var/www/html/python/'): dochome = '/var/www/html/python/index.html' else: basepath = '/usr/share/doc/' dochome = os.path.join(basepath, pyver, 'Doc', 'index.html') elif sys.platform[:3] == 'win': chmfile = os.path.join(sys.prefix, 'Doc', 'Python%s.chm' % _sphinx_version()) if os.path.isfile(chmfile): dochome = chmfile elif macosxSupport.runningAsOSXApp(): dochome = os.path.join(sys.prefix, 'Resources/English.lproj/Documentation/index.html') dochome = os.path.normpath(dochome) if os.path.isfile(dochome): EditorWindow.help_url = dochome if sys.platform == 'darwin': EditorWindow.help_url = 'file://' + EditorWindow.help_url else: EditorWindow.help_url = 'http://docs.python.org/%d.%d' % sys.version_info[:2] currentTheme = idleConf.CurrentTheme() self.flist = flist root = root or flist.root self.root = root try: sys.ps1 except AttributeError: sys.ps1 = '>>> ' self.menubar = Menu(root) self.top = top = WindowList.ListedToplevel(root, menu=self.menubar) if flist: self.tkinter_vars = flist.vars self.top.instance_dict = flist.inversedict else: self.tkinter_vars = {} self.top.instance_dict = {} self.recent_files_path = os.path.join(idleConf.GetUserCfgDir(), 'recent-files.lst') self.text_frame = text_frame = Frame(top) self.vbar = vbar = Scrollbar(text_frame, name='vbar') self.width = idleConf.GetOption('main', 'EditorWindow', 'width') text_options = {'name': 'text', 'padx': 5, 'wrap': 'none', 'width': self.width, 'height': idleConf.GetOption('main', 'EditorWindow', 'height') } if TkVersion >= 8.5: text_options['tabstyle'] = 'wordprocessor' self.text = text = MultiCallCreator(Text)(text_frame, **text_options) self.top.focused_widget = self.text self.createmenubar() self.apply_bindings() self.top.protocol('WM_DELETE_WINDOW', self.close) self.top.bind('<<close-window>>', self.close_event) if macosxSupport.runningAsOSXApp(): text.bind('<<close-window>>', self.close_event) text.bind('<Control-Button-1>', self.right_menu_event) else: text.bind('<3>', self.right_menu_event) text.bind('<<cut>>', self.cut) text.bind('<<copy>>', self.copy) text.bind('<<paste>>', self.paste) text.bind('<<center-insert>>', self.center_insert_event) text.bind('<<help>>', self.help_dialog) text.bind('<<python-docs>>', self.python_docs) text.bind('<<about-idle>>', self.about_dialog) text.bind('<<open-config-dialog>>', self.config_dialog) text.bind('<<open-module>>', self.open_module) text.bind('<<do-nothing>>', lambda event: 'break') text.bind('<<select-all>>', self.select_all) text.bind('<<remove-selection>>', self.remove_selection) text.bind('<<find>>', self.find_event) text.bind('<<find-again>>', self.find_again_event) text.bind('<<find-in-files>>', self.find_in_files_event) text.bind('<<find-selection>>', self.find_selection_event) text.bind('<<replace>>', self.replace_event) text.bind('<<goto-line>>', self.goto_line_event) text.bind('<<smart-backspace>>', self.smart_backspace_event) text.bind('<<newline-and-indent>>', self.newline_and_indent_event) text.bind('<<smart-indent>>', self.smart_indent_event) text.bind('<<indent-region>>', self.indent_region_event) text.bind('<<dedent-region>>', self.dedent_region_event) text.bind('<<comment-region>>', self.comment_region_event) text.bind('<<uncomment-region>>', self.uncomment_region_event) text.bind('<<tabify-region>>', self.tabify_region_event) text.bind('<<untabify-region>>', self.untabify_region_event) text.bind('<<toggle-tabs>>', self.toggle_tabs_event) text.bind('<<change-indentwidth>>', self.change_indentwidth_event) text.bind('<Left>', self.move_at_edge_if_selection(0)) text.bind('<Right>', self.move_at_edge_if_selection(1)) text.bind('<<del-word-left>>', self.del_word_left) text.bind('<<del-word-right>>', self.del_word_right) text.bind('<<beginning-of-line>>', self.home_callback) if flist: flist.inversedict[self] = key if key: flist.dict[key] = self text.bind('<<open-new-window>>', self.new_callback) text.bind('<<close-all-windows>>', self.flist.close_all_callback) text.bind('<<open-class-browser>>', self.open_class_browser) text.bind('<<open-path-browser>>', self.open_path_browser) self.set_status_bar() vbar['command'] = text.yview vbar.pack(side=RIGHT, fill=Y) text['yscrollcommand'] = vbar.set fontWeight = 'normal' if idleConf.GetOption('main', 'EditorWindow', 'font-bold', type='bool'): fontWeight = 'bold' text.config(font=(idleConf.GetOption('main', 'EditorWindow', 'font'), idleConf.GetOption('main', 'EditorWindow', 'font-size'), fontWeight)) text_frame.pack(side=LEFT, fill=BOTH, expand=1) text.pack(side=TOP, fill=BOTH, expand=1) text.focus_set() usespaces = idleConf.GetOption('main', 'Indent', 'use-spaces', type='bool') self.usetabs = not usespaces self.tabwidth = 8 self.indentwidth = self.tabwidth self.set_notabs_indentwidth() self.context_use_ps1 = False self.num_context_lines = (50, 500, 5000000) self.per = per = self.Percolator(text) self.undo = undo = self.UndoDelegator() per.insertfilter(undo) text.undo_block_start = undo.undo_block_start text.undo_block_stop = undo.undo_block_stop undo.set_saved_change_hook(self.saved_change_hook) self.io = io = self.IOBinding(self) io.set_filename_change_hook(self.filename_change_hook) self.recent_files_menu = Menu(self.menubar) self.menudict['file'].insert_cascade(3, label='Recent Files', underline=0, menu=self.recent_files_menu) self.update_recent_files_list() self.color = None if filename: if os.path.exists(filename) and not os.path.isdir(filename): io.loadfile(filename) else: io.set_filename(filename) self.ResetColorizer() self.saved_change_hook() self.set_indentation_params(self.ispythonsource(filename)) self.load_extensions() menu = self.menudict.get('windows') if menu: end = menu.index('end') if end is None: end = -1 if end >= 0: menu.add_separator() end = end + 1 self.wmenu_end = end WindowList.register_callback(self.postwindowsmenu) self.askyesno = tkMessageBox.askyesno self.askinteger = tkSimpleDialog.askinteger self.showerror = tkMessageBox.showerror return