Beispiel #1
0
    def __init__(self, root, text_area, menu_bar, methods):
        self.root = root
        self.text_area = text_area
        self.menu_bar = menu_bar
        self.file = None
        self.methods = methods
        self.file_menu = tkinter.Menu(self.menu_bar, tearoff=0)

        #add New, Open, Save, Save As and Exit functions to the File menu
        self.file_menu.add_command(label="New",
                                   command=self.new_file,
                                   accelerator="Ctrl+N")
        self.file_menu.add_command(label="Open",
                                   command=self.open_file,
                                   accelerator="Ctrl+O")
        self.file_menu.add_command(label="Save",
                                   command=self.save_file,
                                   accelerator="Ctrl+S")
        self.file_menu.add_command(label="Save As\t\t\t\t\t",
                                   command=self.save_as_file,
                                   accelerator="Ctrl+Shift+S")
        self.file_menu.add_separator()
        self.file_menu.add_command(label="Exit",
                                   command=self.exit,
                                   accelerator="Ctrl+Q")

        #add File menu to menu bar
        self.menu_bar.add_cascade(label="File", menu=self.file_menu)

        #add shortcuts
        self.shortcuts()
Beispiel #2
0
    def __init__(self, text_area, menu_bar, methods):
        self.text_area = text_area
        self.menu_bar = menu_bar
        self.methods = methods
        self.edit_menu = tkinter.Menu(self.menu_bar, tearoff=0)

        #add Undo, Redo, Cut, Copy and Paste functions to the Edit menu
        self.edit_menu.add_command(label="Undo",
                                   command=self.undo,
                                   accelerator="Ctrl+Z")
        self.edit_menu.add_command(label="Redo",
                                   command=self.redo,
                                   accelerator="Ctrl+Y")
        self.edit_menu.add_separator()
        self.edit_menu.add_command(label="Cut",
                                   command=self.cut,
                                   accelerator="Ctrl+X")
        self.edit_menu.add_command(label="Copy",
                                   command=self.copy,
                                   accelerator="Ctrl+C")
        self.edit_menu.add_command(label="Paste",
                                   command=self.paste,
                                   accelerator="Ctrl+V")
        self.edit_menu.add_command(label="Delete",
                                   command=self.delete,
                                   accelerator="Del")
        self.edit_menu.add_separator()
        self.edit_menu.add_command(label="Select All\t\t\t\t\t",
                                   command=self.select_all,
                                   accelerator="Ctrl+A")

        #add Edit menu to menu bar
        self.menu_bar.add_cascade(label="Edit", menu=self.edit_menu)

        self.assign_functions()
Beispiel #3
0
    def __init__(self, root, text_area, methods):
        self.root = root
        self.text_area = text_area
        self.methods = methods

        self.menu_bar = tkinter.Menu(root)

        FileMenu(self.root, self.text_area, self.menu_bar, self.methods)
        EditMenu(self.text_area, self.menu_bar, self.methods)
        ViewMenu(self.root, self.menu_bar)
        HelpMenu(self.menu_bar)

        self.root.config(menu=self.menu_bar)
Beispiel #4
0
    def __init__(self, root, menu_bar):
        self.root = root
        self.menu_bar = menu_bar
        self.view_menu = tkinter.Menu(self.menu_bar, tearoff=0)
        self.full_status = True

        #add Full Screen functions to the View menu
        self.view_menu.add_command(label="Full Screen", command=self.full_screen, accelerator="F11")

        #add View menu to menu bar
        self.menu_bar.add_cascade(label="View", menu=self.view_menu)

        #add shortcuts
        self.shortcuts()
Beispiel #5
0
    def __init__(self, menu_bar):
        self.menu_bar = menu_bar
        self.help_menu = tkinter.Menu(self.menu_bar, tearoff=0)

        #add About function to the Help menu
        self.help_menu.add_command(label="About Text Editor",
                                   command=self.about)
        self.help_menu.add_separator()
        self.help_menu.add_command(label="View License",
                                   command=self.view_license)
        self.help_menu.add_command(label="View Source Code",
                                   command=self.source_code)

        #add Help menu to menu bar
        self.menu_bar.add_cascade(label="Help", menu=self.help_menu)
Beispiel #6
0
    def __init__(self, root, text_area, methods):
        self.root = root
        self.text_area = text_area
        self.methods = methods

        self.popup_menu = tkinter.Menu(root)
        self.root.bind("<Button-3>", self.do_popup)

        #add Undo, Redo, Cut, Copy and Paste functions to the popup menu
        self.popup_menu.add_command(label="Undo", command=self.methods['Undo'], accelerator="Ctrl+Z")
        self.popup_menu.add_separator()
        self.popup_menu.add_command(label="Cut", command=self.methods['Cut'], accelerator="Ctrl+X")
        self.popup_menu.add_command(label="Copy", command=self.methods['Copy'], accelerator="Ctrl+C")
        self.popup_menu.add_command(label="Paste", command=self.methods['Paste'], accelerator="Ctrl+V")
        self.popup_menu.add_command(label="Delete", command=self.methods['Delete'], accelerator="Del")
        self.popup_menu.add_separator()
        self.popup_menu.add_command(label="Select All\t\t\t\t\t", command=self.methods['SelectAll'], accelerator="Ctrl+A")