当前位置: 首页>>代码示例>>Python>>正文


Python Frame.focus_set方法代码示例

本文整理汇总了Python中tkinter.Frame.focus_set方法的典型用法代码示例。如果您正苦于以下问题:Python Frame.focus_set方法的具体用法?Python Frame.focus_set怎么用?Python Frame.focus_set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tkinter.Frame的用法示例。


在下文中一共展示了Frame.focus_set方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: View

# 需要导入模块: from tkinter import Frame [as 别名]
# 或者: from tkinter.Frame import focus_set [as 别名]
class View():
    """This calls contains all the tkinter specific code"""

    def __init__(self, control, master):
        """View constructor"""
        self.control = control  # Link back to talk to controller
        self.master = master
        master.wm_state('zoomed')  # Full screen. Might not work on Mac
        self.frame = Frame(master)

        self.create_menus()
        self.create_context_menus()
        self.create_toolbar()

        self.frame.pack(fill=BOTH, expand=YES)
        self.frame.focus_set()
        
        self.create_events()

    def create_menus(self):
        """creates the menus"""
        # main menu
        menubar = Menu(self.master)

        # file menus
        filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label="New", accelerator="^N",
                             command=self.control.cmd_new)
        filemenu.add_command(label="Open", accelerator="^O",
                             command=self.control.cmd_open)
        filemenu.add_command(label="Save", accelerator="^S",
                             command=self.control.cmd_save)
        filemenu.add_command(label="Save as",
                             command=self.control.cmd_save_as)
        filemenu.add_separator()
        filemenu.add_command(label="Exit",
                             command=self.control.cmd_exit)
        menubar.add_cascade(label="File", menu=filemenu)

        # edit menus
        editmenu = Menu(menubar, tearoff=0)
        editmenu.add_command(label="Undo", accelerator="^Z",
                             command=self.control.cmd_null)
        editmenu.add_command(label="Redo", accelerator="^C",
                             command=self.control.cmd_null)
        editmenu.add_separator()
        editmenu.add_command(label="Cut", accelerator="^X",
                             command=self.control.cmd_null)
        editmenu.add_command(label="Copy", accelerator="^C",
                             command=self.control.cmd_null)
        editmenu.add_command(label="Paste", accelerator="^V"
                             , command=self.control.cmd_null)
        editmenu.add_separator()
        editmenu.add_command(label="Delete",
                             command = self.control.cmd_null)
        editmenu.add_separator()
        editmenu.add_command(label="Select all",
                             command = self.control.cmd_null)
        menubar.add_cascade(label="Edit", menu=editmenu)

        # drawing menus
        drawingmenu = Menu(menubar, tearoff=0)
        drawingmenu.add_command(label="Select",
                                command=self.control.cmd_null)
        drawingmenu.add_command(label="Line",
                                command=self.control.cmd_line)
        drawingmenu.add_command(label="Rectangle",
                                command=self.control.cmd_rectangle)
        drawingmenu.add_command(label="Circle",
                                command=self.control.cmd_circle)
        drawingmenu.add_command(label="Group",
                                command=self.control.cmd_null)
        drawingmenu.add_command(label="Instance",
                                command=self.control.cmd_null)
        menubar.add_cascade(label="Drawing", menu=drawingmenu)

        # toolbar menus
        toolbarmenu = Menu(menubar, tearoff=0)
        toolbarmenu.add_checkbutton(label='Tools',
                                    command=self.control.cmd_tools)
        menubar.add_cascade(label="Toolbar", menu=toolbarmenu)

        # help menus
        helpmenu = Menu(menubar, tearoff=0)
        helpmenu.add_command(label="About",
                             command = self.control.cmd_null)
        menubar.add_cascade(label="Help", menu = helpmenu)

        self.master.config(menu=menubar)  # lock in menubar

    def create_context_menus(self):
        """Creates the connects menus, i.e. for right click"""
        self.context = Menu(self.master, tearoff=0)
        self.context.add_command(label="Dirty",
                                 command=self.control.cmd_dirty)
        self.context.add_command(label="Clean",
                                 command=self.control.cmd_clean)

    def create_toolbar(self):
        """Creates toolbar, hopefully floating dockable but not yet"""
#.........这里部分代码省略.........
开发者ID:Patch67,项目名称:Graphics,代码行数:103,代码来源:View.py


注:本文中的tkinter.Frame.focus_set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。