Ejemplo n.º 1
0
 def create_toolbar(self):
     self.toolbar = ttk.Frame(self.master)
     newButton = ttk.Button(self.toolbar,
                            text=NEW,
                            takefocus=False,
                            image=self.images[NEW],
                            command=self.board.new_game)
     TkUtil.Tooltip.Tooltip(newButton, text="New Game")
     zoomLabel = ttk.Label(self.toolbar, text="Zoom:")
     self.zoomSpinbox = Spinbox(self.toolbar,
                                textvariable=self.zoom,
                                from_=Board.MIN_ZOOM,
                                to=Board.MAX_ZOOM,
                                increment=Board.ZOOM_INC,
                                width=3,
                                justify=tk.RIGHT,
                                validate="all")
     self.zoomSpinbox.config(
         validatecommand=(self.zoomSpinbox.register(self.validate_int),
                          "%P"))
     TkUtil.Tooltip.Tooltip(self.zoomSpinbox, text="Zoom level (%)")
     self.shapeCombobox = ttk.Combobox(self.toolbar,
                                       width=8,
                                       textvariable=self.shapeName,
                                       state="readonly",
                                       values=sorted(
                                           Shapes.ShapeForName.keys()))
     TkUtil.Tooltip.Tooltip(self.shapeCombobox, text="Tile Shape")
     TkUtil.add_toolbar_buttons(
         self.toolbar,
         (newButton, None, zoomLabel, self.zoomSpinbox, self.shapeCombobox))
     self.toolbar.pack(side=tk.TOP, fill=tk.X, before=self.board)
Ejemplo n.º 2
0
 def create_alignment_toolbar(self):
     settings = TkUtil.Settings.Data
     self.alignmentToolbar = ttk.Frame(self.toolbarFrame,
             relief=tk.RAISED)
     self.alignmentToolbar.text = ALIGNMENT_TOOLBAR
     self.alignmentToolbar.underline = 0
     menuButton = ttk.Button(self.alignmentToolbar,
             text="Alignment Toolbar Menu", 
             image=self.toolbarImages[TOOLBARMENU],
             command=self.toolbar_menu)
     TkUtil.bind_context_menu(menuButton, self.toolbar_menu)
     TkUtil.Tooltip.Tooltip(menuButton, text="Alignment Toolbar Menu")
     self.leftButton = ttk.Button(self.alignmentToolbar,
             text=ALIGN_LEFT, image=self.toolbarImages[ALIGNLEFT])
     self.leftButton.config(
             command=lambda: self.toggle_alignment(tk.LEFT))
     TkUtil.Tooltip.Tooltip(self.leftButton, text=ALIGN_LEFT)
     self.centerButton = ttk.Button(self.alignmentToolbar,
             text=ALIGN_CENTER, 
             image=self.toolbarImages[ALIGNCENTER])
     self.centerButton.config(
             command=lambda: self.toggle_alignment(tk.CENTER))
     TkUtil.Tooltip.Tooltip(self.centerButton, text=ALIGN_CENTER)
     self.rightButton = ttk.Button(self.alignmentToolbar,
             text=ALIGN_RIGHT, image=self.toolbarImages[ALIGNRIGHT])
     self.rightButton.config(
             command=lambda: self.toggle_alignment(tk.RIGHT))
     TkUtil.Tooltip.Tooltip(self.rightButton, text=ALIGN_RIGHT)
     TkUtil.add_toolbar_buttons(self.alignmentToolbar, (menuButton,
             self.leftButton, self.centerButton, self.rightButton))
     self.toolbars.append(self.alignmentToolbar)
     self.leftButton.state((TkUtil.SELECTED,))
     self.alignment.set(tk.LEFT)
Ejemplo n.º 3
0
 def create_file_toolbar(self):
     settings = TkUtil.Settings.Data
     self.fileToolbar = ttk.Frame(self.toolbarFrame, relief=tk.RAISED)
     self.fileToolbar.text = FILE_TOOLBAR
     self.fileToolbar.underline = 0
     menuButton = ttk.Button(self.fileToolbar,
             text="File Toolbar Menu", 
             image=self.toolbarImages[TOOLBARMENU],
             command=self.toolbar_menu)
     TkUtil.bind_context_menu(menuButton, self.toolbar_menu)
     TkUtil.Tooltip.Tooltip(menuButton, text="File Toolbar Menu")
     newButton = ttk.Button(self.fileToolbar, text=NEW,
             image=self.toolbarImages[NEW], command=self.new)
     TkUtil.Tooltip.Tooltip(newButton, text="New Document")
     openButton = ttk.Button(self.fileToolbar, text=OPEN,
             image=self.toolbarImages[OPEN], command=self.open)
     TkUtil.Tooltip.Tooltip(openButton, text="Open Document")
     self.saveButton = ttk.Button(self.fileToolbar, text=SAVE,
             image=self.toolbarImages[SAVE], command=self.save)
     TkUtil.Tooltip.Tooltip(self.saveButton, text="Save Document")
     preferencesButton = ttk.Button(self.fileToolbar,
             text=PREFERENCES, image=self.toolbarImages[PREFERENCES],
             command=self.preferences)
     TkUtil.Tooltip.Tooltip(preferencesButton, text=PREFERENCES)
     TkUtil.add_toolbar_buttons(self.fileToolbar, (menuButton,
             newButton, openButton, self.saveButton, None,
             preferencesButton))
     self.toolbars.append(self.fileToolbar)
Ejemplo n.º 4
0
 def create_alignment_toolbar(self):
     settings = TkUtil.Settings.Data
     self.alignmentToolbar = ttk.Frame(self.toolbarFrame, relief=tk.RAISED)
     self.alignmentToolbar.text = ALIGNMENT_TOOLBAR
     self.alignmentToolbar.underline = 0
     menuButton = ttk.Button(self.alignmentToolbar,
                             text="Alignment Toolbar Menu",
                             image=self.toolbarImages[TOOLBARMENU],
                             command=self.toolbar_menu)
     TkUtil.bind_context_menu(menuButton, self.toolbar_menu)
     TkUtil.Tooltip.Tooltip(menuButton, text="Alignment Toolbar Menu")
     self.leftButton = ttk.Button(self.alignmentToolbar,
                                  text=ALIGN_LEFT,
                                  image=self.toolbarImages[ALIGNLEFT])
     self.leftButton.config(command=lambda: self.toggle_alignment(tk.LEFT))
     TkUtil.Tooltip.Tooltip(self.leftButton, text=ALIGN_LEFT)
     self.centerButton = ttk.Button(self.alignmentToolbar,
                                    text=ALIGN_CENTER,
                                    image=self.toolbarImages[ALIGNCENTER])
     self.centerButton.config(
         command=lambda: self.toggle_alignment(tk.CENTER))
     TkUtil.Tooltip.Tooltip(self.centerButton, text=ALIGN_CENTER)
     self.rightButton = ttk.Button(self.alignmentToolbar,
                                   text=ALIGN_RIGHT,
                                   image=self.toolbarImages[ALIGNRIGHT])
     self.rightButton.config(
         command=lambda: self.toggle_alignment(tk.RIGHT))
     TkUtil.Tooltip.Tooltip(self.rightButton, text=ALIGN_RIGHT)
     TkUtil.add_toolbar_buttons(
         self.alignmentToolbar,
         (menuButton, self.leftButton, self.centerButton, self.rightButton))
     self.toolbars.append(self.alignmentToolbar)
     self.leftButton.state((TkUtil.SELECTED, ))
     self.alignment.set(tk.LEFT)
Ejemplo n.º 5
0
 def create_file_toolbar(self):
     settings = TkUtil.Settings.Data
     self.fileToolbar = ttk.Frame(self.toolbarFrame, relief=tk.RAISED)
     self.fileToolbar.text = FILE_TOOLBAR
     self.fileToolbar.underline = 0
     menuButton = ttk.Button(self.fileToolbar,
                             text="File Toolbar Menu",
                             image=self.toolbarImages[TOOLBARMENU],
                             command=self.toolbar_menu)
     TkUtil.bind_context_menu(menuButton, self.toolbar_menu)
     TkUtil.Tooltip.Tooltip(menuButton, text="File Toolbar Menu")
     newButton = ttk.Button(self.fileToolbar,
                            text=NEW,
                            image=self.toolbarImages[NEW],
                            command=self.new)
     TkUtil.Tooltip.Tooltip(newButton, text="New Document")
     openButton = ttk.Button(self.fileToolbar,
                             text=OPEN,
                             image=self.toolbarImages[OPEN],
                             command=self.open)
     TkUtil.Tooltip.Tooltip(openButton, text="Open Document")
     self.saveButton = ttk.Button(self.fileToolbar,
                                  text=SAVE,
                                  image=self.toolbarImages[SAVE],
                                  command=self.save)
     TkUtil.Tooltip.Tooltip(self.saveButton, text="Save Document")
     preferencesButton = ttk.Button(self.fileToolbar,
                                    text=PREFERENCES,
                                    image=self.toolbarImages[PREFERENCES],
                                    command=self.preferences)
     TkUtil.Tooltip.Tooltip(preferencesButton, text=PREFERENCES)
     TkUtil.add_toolbar_buttons(self.fileToolbar,
                                (menuButton, newButton, openButton,
                                 self.saveButton, None, preferencesButton))
     self.toolbars.append(self.fileToolbar)
Ejemplo n.º 6
0
 def create_edit_toolbar(self):
     settings = TkUtil.Settings.Data
     self.editToolbar = ttk.Frame(self.toolbarFrame, relief=tk.RAISED)
     self.editToolbar.text = EDIT_TOOLBAR
     self.editToolbar.underline = 0
     menuButton = ttk.Button(
         self.editToolbar, text="Edit Toolbar Menu", image=self.toolbarImages[TOOLBARMENU], command=self.toolbar_menu
     )
     TkUtil.bind_context_menu(menuButton, self.toolbar_menu)
     TkUtil.Tooltip.Tooltip(menuButton, text="Edit Toolbar Menu")
     self.undoButton = ttk.Button(
         self.editToolbar, text=UNDO, image=self.toolbarImages[UNDO], command=self.editor.edit_undo
     )
     TkUtil.Tooltip.Tooltip(self.undoButton, text=UNDO)
     self.redoButton = ttk.Button(
         self.editToolbar, text=REDO, image=self.toolbarImages[REDO], command=self.editor.edit_redo
     )
     TkUtil.Tooltip.Tooltip(self.redoButton, text=REDO)
     self.copyButton = ttk.Button(
         self.editToolbar,
         text=COPY,
         image=self.toolbarImages[COPY],
         command=self.editor.text.event_generate("<<Copy>>"),
     )
     TkUtil.Tooltip.Tooltip(self.copyButton, text=COPY)
     self.cutButton = ttk.Button(
         self.editToolbar,
         text=CUT,
         image=self.toolbarImages[CUT],
         command=self.editor.text.event_generate("<<Cut>>"),
     )
     TkUtil.Tooltip.Tooltip(self.cutButton, text=CUT)
     self.pasteButton = ttk.Button(
         self.editToolbar,
         text=PASTE,
         image=self.toolbarImages[PASTE],
         command=self.editor.text.event_generate("<<Paste>>"),
     )
     TkUtil.Tooltip.Tooltip(self.pasteButton, text=PASTE)
     self.findButton = ttk.Button(self.editToolbar, text=FIND, image=self.toolbarImages[FIND], command=self.find)
     TkUtil.Tooltip.Tooltip(self.findButton, text=FIND)
     TkUtil.add_toolbar_buttons(
         self.editToolbar,
         (
             menuButton,
             self.undoButton,
             self.redoButton,
             None,
             self.copyButton,
             self.cutButton,
             self.pasteButton,
             None,
             self.findButton,
         ),
     )
     self.toolbars.append(self.editToolbar)
Ejemplo n.º 7
0
 def create_edit_toolbar(self):
     settings = TkUtil.Settings.Data
     self.editToolbar = ttk.Frame(self.toolbarFrame, relief=tk.RAISED)
     self.editToolbar.text = EDIT_TOOLBAR
     self.editToolbar.underline = 0
     menuButton = ttk.Button(self.editToolbar,
                             text="Edit Toolbar Menu",
                             image=self.toolbarImages[TOOLBARMENU],
                             command=self.toolbar_menu)
     TkUtil.bind_context_menu(menuButton, self.toolbar_menu)
     TkUtil.Tooltip.Tooltip(menuButton, text="Edit Toolbar Menu")
     self.undoButton = ttk.Button(self.editToolbar,
                                  text=UNDO,
                                  image=self.toolbarImages[UNDO],
                                  command=self.editor.edit_undo)
     TkUtil.Tooltip.Tooltip(self.undoButton, text=UNDO)
     self.redoButton = ttk.Button(self.editToolbar,
                                  text=REDO,
                                  image=self.toolbarImages[REDO],
                                  command=self.editor.edit_redo)
     TkUtil.Tooltip.Tooltip(self.redoButton, text=REDO)
     self.copyButton = ttk.Button(
         self.editToolbar,
         text=COPY,
         image=self.toolbarImages[COPY],
         command=self.editor.text.event_generate("<<Copy>>"))
     TkUtil.Tooltip.Tooltip(self.copyButton, text=COPY)
     self.cutButton = ttk.Button(
         self.editToolbar,
         text=CUT,
         image=self.toolbarImages[CUT],
         command=self.editor.text.event_generate("<<Cut>>"))
     TkUtil.Tooltip.Tooltip(self.cutButton, text=CUT)
     self.pasteButton = ttk.Button(
         self.editToolbar,
         text=PASTE,
         image=self.toolbarImages[PASTE],
         command=self.editor.text.event_generate("<<Paste>>"))
     TkUtil.Tooltip.Tooltip(self.pasteButton, text=PASTE)
     self.findButton = ttk.Button(self.editToolbar,
                                  text=FIND,
                                  image=self.toolbarImages[FIND],
                                  command=self.find)
     TkUtil.Tooltip.Tooltip(self.findButton, text=FIND)
     TkUtil.add_toolbar_buttons(
         self.editToolbar, (menuButton, self.undoButton, self.redoButton,
                            None, self.copyButton, self.cutButton,
                            self.pasteButton, None, self.findButton))
     self.toolbars.append(self.editToolbar)
Ejemplo n.º 8
0
 def create_view_toolbar(self):
     settings = TkUtil.Settings.Data
     self.viewToolbar = ttk.Frame(self.toolbarFrame, relief=tk.RAISED)
     self.viewToolbar.text = FORMAT_TOOLBAR
     self.viewToolbar.underline = 1
     menuButton = ttk.Button(self.viewToolbar,
                             text="Format Toolbar Menu",
                             image=self.toolbarImages[TOOLBARMENU],
                             command=self.toolbar_menu)
     TkUtil.bind_context_menu(menuButton, self.toolbar_menu)
     TkUtil.Tooltip.Tooltip(menuButton, text="Format Toolbar Menu")
     self.fontFamilyCombobox = ttk.Combobox(self.viewToolbar,
                                            width=15,
                                            textvariable=self.fontFamily,
                                            state="readonly",
                                            values=TkUtil.font_families())
     self.fontFamilyCombobox.bind("<<ComboboxSelected>>", self.update_font)
     TkUtil.set_combobox_item(self.fontFamilyCombobox,
                              self.fontFamily.get())
     TkUtil.Tooltip.Tooltip(self.fontFamilyCombobox, text="Font Family")
     self.fontSizeSpinbox = Spinbox(self.viewToolbar,
                                    width=2,
                                    textvariable=self.fontPointSize,
                                    from_=6,
                                    to=72,
                                    justify=tk.RIGHT,
                                    validate="all")
     self.fontSizeSpinbox.config(
         validatecommand=(self.fontSizeSpinbox.register(self.validate_int),
                          "fontSizeSpinbox", "%P"))
     TkUtil.Tooltip.Tooltip(self.fontSizeSpinbox, text="Font Point Size")
     self.boldButton = ttk.Button(self.viewToolbar,
                                  text=BOLD,
                                  image=self.toolbarImages[BOLD])
     self.boldButton.config(
         command=lambda: self.toggle_button(self.boldButton, self.bold))
     TkUtil.Tooltip.Tooltip(self.boldButton, text=BOLD)
     self.italicButton = ttk.Button(self.viewToolbar,
                                    text=ITALIC,
                                    image=self.toolbarImages[ITALIC])
     self.italicButton.config(
         command=lambda: self.toggle_button(self.italicButton, self.italic))
     TkUtil.Tooltip.Tooltip(self.italicButton, text=ITALIC)
     TkUtil.add_toolbar_buttons(
         self.viewToolbar,
         (menuButton, self.fontFamilyCombobox, self.fontSizeSpinbox,
          self.boldButton, self.italicButton))
     self.toolbars.append(self.viewToolbar)
Ejemplo n.º 9
0
 def create_view_toolbar(self):
     settings = TkUtil.Settings.Data
     self.viewToolbar = ttk.Frame(self.toolbarFrame, relief=tk.RAISED)
     self.viewToolbar.text = FORMAT_TOOLBAR
     self.viewToolbar.underline = 1
     menuButton = ttk.Button(self.viewToolbar,
             text="Format Toolbar Menu", 
             image=self.toolbarImages[TOOLBARMENU],
             command=self.toolbar_menu)
     TkUtil.bind_context_menu(menuButton, self.toolbar_menu)
     TkUtil.Tooltip.Tooltip(menuButton, text="Format Toolbar Menu")
     self.fontFamilyCombobox = ttk.Combobox(self.viewToolbar,
             width=15, textvariable=self.fontFamily,
             state="readonly", values=TkUtil.font_families())
     self.fontFamilyCombobox.bind("<<ComboboxSelected>>",
             self.update_font)
     TkUtil.set_combobox_item(self.fontFamilyCombobox,
             self.fontFamily.get())
     TkUtil.Tooltip.Tooltip(self.fontFamilyCombobox, text="Font Family")
     self.fontSizeSpinbox = Spinbox(self.viewToolbar, width=2,
             textvariable=self.fontPointSize, from_=6, to=72,
             justify=tk.RIGHT, validate="all")
     self.fontSizeSpinbox.config(validatecommand=(
             self.fontSizeSpinbox.register(self.validate_int),
                 "fontSizeSpinbox", "%P"))
     TkUtil.Tooltip.Tooltip(self.fontSizeSpinbox,
             text="Font Point Size")
     self.boldButton = ttk.Button(self.viewToolbar,
             text=BOLD, image=self.toolbarImages[BOLD])
     self.boldButton.config(
             command=lambda: self.toggle_button(self.boldButton,
                 self.bold))
     TkUtil.Tooltip.Tooltip(self.boldButton, text=BOLD)
     self.italicButton = ttk.Button(self.viewToolbar,
             text=ITALIC,
             image=self.toolbarImages[ITALIC])
     self.italicButton.config(
             command=lambda: self.toggle_button(self.italicButton,
                 self.italic))
     TkUtil.Tooltip.Tooltip(self.italicButton, text=ITALIC)
     TkUtil.add_toolbar_buttons(self.viewToolbar, (menuButton,
             self.fontFamilyCombobox, self.fontSizeSpinbox,
             self.boldButton, self.italicButton))
     self.toolbars.append(self.viewToolbar)
 def create_toolbar(self):
     self.toolbar = ttk.Frame(self.master)
     newButton = ttk.Button(self.toolbar, text=NEW, takefocus=False,
             image=self.images[NEW], command=self.board.new_game)
     TkUtil.Tooltip.Tooltip(newButton, text="New Game")
     zoomLabel = ttk.Label(self.toolbar, text="Zoom:")
     self.zoomSpinbox = Spinbox(self.toolbar,
             textvariable=self.zoom, from_=Board.MIN_ZOOM,
             to=Board.MAX_ZOOM, increment=Board.ZOOM_INC, width=3,
             justify=tk.RIGHT, validate="all")
     self.zoomSpinbox.config(validatecommand=(
             self.zoomSpinbox.register(self.validate_int), "%P"))
     TkUtil.Tooltip.Tooltip(self.zoomSpinbox, text="Zoom level (%)")
     self.shapeCombobox = ttk.Combobox(self.toolbar, width=8,
             textvariable=self.shapeName, state="readonly",
             values=sorted(Shapes.ShapeForName.keys()))
     TkUtil.Tooltip.Tooltip(self.shapeCombobox, text="Tile Shape")
     TkUtil.add_toolbar_buttons(self.toolbar, (newButton, None,
             zoomLabel, self.zoomSpinbox, self.shapeCombobox))
     self.toolbar.pack(side=tk.TOP, fill=tk.X, before=self.board)