mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	Added a menu bar to every window.
This commit is contained in:
		
							parent
							
								
									d8d676c289
								
							
						
					
					
						commit
						2aeeb55949
					
				
					 1 changed files with 45 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -2,7 +2,16 @@
 | 
			
		|||
import os
 | 
			
		||||
import string
 | 
			
		||||
from Tkinter import *
 | 
			
		||||
import tkMessageBox
 | 
			
		||||
 | 
			
		||||
about_title = "About IDLE"
 | 
			
		||||
about_text = """\
 | 
			
		||||
IDLE 0.1
 | 
			
		||||
 | 
			
		||||
A not totally unintegrated development environment for Python
 | 
			
		||||
 | 
			
		||||
by Guido van Rossum
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
class EditorWindow:
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -15,11 +24,17 @@ class EditorWindow:
 | 
			
		|||
    from AutoExpand import AutoExpand
 | 
			
		||||
    import Bindings
 | 
			
		||||
    
 | 
			
		||||
    about_title = about_title
 | 
			
		||||
    about_text = about_text    
 | 
			
		||||
 | 
			
		||||
    def __init__(self, root, filename=None):
 | 
			
		||||
        self.top = top = Toplevel(root)
 | 
			
		||||
        self.root = root
 | 
			
		||||
        self.menubar = Menu(root)
 | 
			
		||||
        self.top = top = Toplevel(root, menu=self.menubar)
 | 
			
		||||
        self.vbar = vbar = Scrollbar(top, name='vbar')
 | 
			
		||||
        self.text = text = Text(top, name='text')
 | 
			
		||||
 | 
			
		||||
        self.createmenubar()
 | 
			
		||||
        self.Bindings.apply_bindings(text)
 | 
			
		||||
 | 
			
		||||
        self.top.protocol("WM_DELETE_WINDOW", self.close)
 | 
			
		||||
| 
						 | 
				
			
			@ -60,6 +75,35 @@ def __init__(self, root, filename=None):
 | 
			
		|||
 | 
			
		||||
        self.saved_change_hook()
 | 
			
		||||
 | 
			
		||||
    def createmenubar(self):
 | 
			
		||||
        mbar = self.menubar
 | 
			
		||||
 | 
			
		||||
        self.filemenu = Menu(mbar)
 | 
			
		||||
 | 
			
		||||
        self.editmenu = Menu(mbar)
 | 
			
		||||
 | 
			
		||||
        self.helpmenu = Menu(mbar, name="help")
 | 
			
		||||
        self.helpmenu.add_command(label="Help...", command=self.help_dialog)
 | 
			
		||||
        self.helpmenu.add_separator()
 | 
			
		||||
        self.helpmenu.add_command(label="About...", command=self.about_dialog)
 | 
			
		||||
 | 
			
		||||
        mbar.add_cascade(label="File", menu=self.filemenu)
 | 
			
		||||
        mbar.add_cascade(label="Edit", menu=self.editmenu)
 | 
			
		||||
        mbar.add_cascade(label="Help", menu=self.helpmenu)
 | 
			
		||||
 | 
			
		||||
        dict = {"file": self.filemenu,
 | 
			
		||||
                "edit": self.editmenu,
 | 
			
		||||
                "help": self.helpmenu}
 | 
			
		||||
        self.Bindings.fill_menus(self.text, dict)
 | 
			
		||||
 | 
			
		||||
    def about_dialog(self):
 | 
			
		||||
        tkMessageBox.showinfo(self.about_title, self.about_text,
 | 
			
		||||
                              master=self.text)
 | 
			
		||||
 | 
			
		||||
    def help_dialog(self):
 | 
			
		||||
        from HelpWindow import HelpWindow
 | 
			
		||||
        HelpWindow(root=self.root)
 | 
			
		||||
 | 
			
		||||
    def gotoline(self, lineno):
 | 
			
		||||
        if lineno is not None and lineno > 0:
 | 
			
		||||
            self.text.mark_set("insert", "%d.0" % lineno)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue