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


Python Frame.grid_propagate方法代码示例

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


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

示例1: DialogVidget

# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import grid_propagate [as 别名]
class DialogVidget(ToplevelVidget):
    """
    DialogVidget contains a Toplevel widget, a main Frame widget, a custom view
    widget, and two button widgets for `Confirm` and `Cancel`.
    """

    def __init__(
        self,
        view_widget=None,
        confirm_handler=None,
        confirm_buttion_text='Confirm',
        cancel_handler=None,
        cancel_buttion_text='Cancel',
        close_handler=None,
        master=None,
    ):
        """
        Initialize object.

        @param view_widget: Custom view widget.

        @param confirm_handler: Confirm button event handler.

        @param confirm_buttion_text: Confirm button text.

        @param cancel_handler: Cancel button event handler.

        @param cancel_buttion_text: Cancel button text.

        @param close_handler: Window close button event handler.

        @param master: Master widget.

        @return: None.
        """
        # Initialize ToplevelVidget
        ToplevelVidget.__init__(
            self,
            close_handler=close_handler,
            master=master,
        )

        # Create main frame
        self._frame = Frame(master=self._toplevel)

        # Custom view widget
        self._view_widget = view_widget

        # Confirm button event handler
        self._confirm_handler = confirm_handler \
            if confirm_handler is not None else self._confirm_handler_default

        # Create confirm button
        self._confirm_button = Button(
            master=self._toplevel,
            text=confirm_buttion_text,
            command=self._confirm_handler,
        )

        # Cancel button event handler
        self._cancel_handler = cancel_handler \
            if cancel_handler is not None else self._cancel_handler_default

        # Create cancel button
        self._cancel_button = Button(
            master=self._toplevel,
            text=cancel_buttion_text,
            command=self._cancel_handler,
        )

        # If the view widget is given
        if self._view_widget is not None:
            # Set view widget
            self.view_set(self._view_widget)

        # Update widget
        self._widget_update()

    def _widget_update(self):
        """
        Update widget.

        @return: None.
        """
        # Configure layout weights for children
        self._toplevel.rowconfigure(0, weight=1)

        self._toplevel.columnconfigure(0, weight=1)

        # Lay out the main frame widget
        self._frame.grid(
            in_=self._toplevel,
            row=0,
            column=0,
            sticky='NSEW',
        )

        # Do not use children to compute main frame's geometry info
        self._frame.grid_propagate(False)

#.........这里部分代码省略.........
开发者ID:AoiKuiyuyou,项目名称:AoikRegistryEditor,代码行数:103,代码来源:toplevel.py

示例2: Sudoku

# 需要导入模块: from tkinter.ttk import Frame [as 别名]
# 或者: from tkinter.ttk.Frame import grid_propagate [as 别名]

#.........这里部分代码省略.........
        # --- buttons
        self.b_pause = Button(self, state="disabled", image=self.im_pause,
                              command=self.play_pause)
        self.b_restart = Button(self, state="disabled", image=self.im_restart,
                                command=self.recommence)
        self.b_undo = Button(self, image=self.im_undo, command=self.undo)
        self.b_redo = Button(self, image=self.im_redo, command=self.redo)

        # --- tooltips
        self.tooltip_wrapper = TooltipWrapper(self)
        self.tooltip_wrapper.add_tooltip(self.b_pause, _("Pause game"))
        self.tooltip_wrapper.add_tooltip(self.b_restart, _("Restart game"))
        self.tooltip_wrapper.add_tooltip(self.b_undo, _("Undo"))
        self.tooltip_wrapper.add_tooltip(self.b_redo, _("Redo"))

        # --- numbers
        frame_nb = Frame(self, style='bg.TFrame', width=36)
        self.progression = []
        for i in range(1, 10):
            self.progression.append(Progression(frame_nb, i))
            self.progression[-1].pack(padx=1, pady=1)

        # --- level indication
        frame = Frame(self)
        frame.grid(row=0, columnspan=5, padx=(30, 10), pady=10)
        Label(frame, text=_("Level") + ' - ', font="Arial 16").pack(side='left')
        self.label_level = Label(frame, font="Arial 16", text=_("Unknown"))
        self.label_level.pack(side='left')
        self.level = "unknown"  # puzzle level

        # --- frame contenant la grille de sudoku
        self.frame_puzzle = Frame(self, style="bg.TFrame")
        self.frame_pause = Frame(self, style="case.TFrame")
        self.frame_pause.grid_propagate(False)
        self.frame_pause.columnconfigure(0, weight=1)
        self.frame_pause.rowconfigure(0, weight=1)
        Label(self.frame_pause, text='PAUSE', style='pause.TLabel',
              font='Arial 30 bold').grid()

        # --- placement
        frame_nb.grid(row=1, column=6, sticky='en', pady=0, padx=(0, 30))
        self.frame_puzzle.grid(row=1, columnspan=5, padx=(30, 15))
        self.tps.grid(row=2, column=0, sticky="e", padx=(30, 10), pady=30)
        self.b_pause.grid(row=2, column=1, sticky="w", padx=2, pady=30)
        self.b_restart.grid(row=2, column=2, sticky="w", padx=2, pady=30)
        self.b_undo.grid(row=2, column=3, sticky="e", pady=30, padx=2)
        self.b_redo.grid(row=2, column=4, sticky="w", pady=30, padx=(2, 10))

        # --- menu
        menu = Menu(self, tearoff=0)

        menu_nouveau = Menu(menu, tearoff=0)

        menu_levels = Menu(menu_nouveau, tearoff=0)
        menu_levels.add_command(label=_("Easy"), command=self.new_easy)
        menu_levels.add_command(label=_("Medium"), command=self.new_medium)
        menu_levels.add_command(label=_("Difficult"), command=self.new_difficult)

        menu_nouveau.add_cascade(label=_("Level"), menu=menu_levels)
        menu_nouveau.add_command(label=_("Generate a puzzle"),
                                 command=self.genere_grille,
                                 accelerator="Ctrl+G")
        menu_nouveau.add_command(label=_("Empty grid"),
                                 command=self.grille_vide,
                                 accelerator="Ctrl+N")
开发者ID:j4321,项目名称:Sudoku-Tk,代码行数:69,代码来源:sudoku.py


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