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


Python TkUtil类代码示例

本文整理汇总了Python中TkUtil的典型用法代码示例。如果您正苦于以下问题:Python TkUtil类的具体用法?Python TkUtil怎么用?Python TkUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: create_alignment_toolbar

 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)
开发者ID:ShuyaMotouchi,项目名称:joke,代码行数:33,代码来源:Main.py

示例2: create_edit_menu

 def create_edit_menu(self):
     modifier = TkUtil.menu_modifier()
     self.editMenu = tk.Menu(self.menubar)
     self.editMenu.add_command(label=UNDO, underline=0,
             command=self.editor.edit_undo,
             image=self.menuImages[UNDO], compound=tk.LEFT,
             accelerator=modifier + "+Z")
     redo = "+Shift+Z"
     if TkUtil.windows():
         redo = "+Y"
     self.editMenu.add_command(label=REDO, underline=0,
             command=self.editor.edit_redo,
             image=self.menuImages[REDO], compound=tk.LEFT,
             accelerator=modifier + redo)
     self.editMenu.add_separator()
     self.editMenu.add_command(label=COPY, underline=0,
             command=lambda: self.editor.text.event_generate(
                 "<<Copy>>"), image=self.menuImages[COPY],
             compound=tk.LEFT, accelerator=modifier + "+C")
     self.editMenu.add_command(label=CUT, underline=2,
             command=lambda: self.editor.text.event_generate("<<Cut>>"),
             image=self.menuImages[CUT], compound=tk.LEFT,
             accelerator=modifier + "+X")
     self.editMenu.add_command(label=PASTE, underline=0,
             command=lambda: self.editor.text.event_generate(
                 "<<Paste>>"), image=self.menuImages[PASTE],
             compound=tk.LEFT, accelerator=modifier + "+V")
     self.editMenu.add_separator()
     self.editMenu.add_command(label=FIND + ELLIPSIS, underline=0,
             command=self.find, image=self.menuImages[FIND],
             compound=tk.LEFT, accelerator=modifier + "+F")
     self.menubar.add_cascade(label="Edit", underline=0,
             menu=self.editMenu)
开发者ID:ShuyaMotouchi,项目名称:joke,代码行数:33,代码来源:Main.py

示例3: create_file_toolbar

 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)
开发者ID:ShuyaMotouchi,项目名称:joke,代码行数:28,代码来源:Main.py

示例4: create_widgets

 def create_widgets(self):
     self.sourceLabel = ttk.Label(self, text="Source Folder:",
             underline=-1 if TkUtil.mac() else 1)
     self.sourceEntry = ttk.Entry(self, width=30,
             textvariable=self.sourceText)
     self.sourceButton = TkUtil.Button(self, text="Source...",
             underline=0, command=lambda *args:
                 self.choose_folder(SOURCE))
     self.helpButton = TkUtil.Button(self, text="Help", underline=0,
             command=self.help)
     self.targetLabel = ttk.Label(self, text="Target Folder:",
             underline=-1 if TkUtil.mac() else 1)
     self.targetEntry = ttk.Entry(self, width=30,
             textvariable=self.targetText)
     self.targetButton = TkUtil.Button(self, text="Target...",
             underline=0, command=lambda *args:
                 self.choose_folder(TARGET))
     self.aboutButton = TkUtil.Button(self, text="About", underline=1,
             command=self.about)
     self.statusLabel = ttk.Label(self, textvariable=self.statusText)
     self.scaleButton = TkUtil.Button(self, text="Scale",
             underline=1, command=self.scale_or_cancel,
             default=tk.ACTIVE, state=tk.DISABLED)
     self.quitButton = TkUtil.Button(self, text="Quit", underline=0,
             command=self.close)
     self.dimensionLabel = ttk.Label(self, text="Max. Dimension:",
             underline=-1 if TkUtil.mac() else 6)
     self.dimensionCombobox = ttk.Combobox(self,
             textvariable=self.dimensionText, state="readonly",
             values=("50", "100", "150", "200", "250", "300", "350",
                     "400", "450", "500"))
     TkUtil.set_combobox_item(self.dimensionCombobox, "400")
开发者ID:ShuyaMotouchi,项目名称:joke,代码行数:32,代码来源:Main.py

示例5: create_file_menu

 def create_file_menu(self):
     modifier = TkUtil.menu_modifier()
     self.fileMenu = tk.Menu(self.menubar, name="apple")
     self.fileMenu.add_command(label=NEW, underline=0,
             command=self.new, image=self.menuImages[NEW],
             compound=tk.LEFT, accelerator=modifier + "+N")
     self.fileMenu.add_command(label=OPEN + ELLIPSIS, underline=0,
             command=self.open, image=self.menuImages[OPEN],
             compound=tk.LEFT, accelerator=modifier + "+O")
     self.fileMenu.add_cascade(label=OPEN_RECENT,
             underline=5, image=self.menuImages[OPEN],
             compound=tk.LEFT)
     self.fileMenu.add_command(label=SAVE, underline=0,
             command=self.save, image=self.menuImages[SAVE],
             compound=tk.LEFT, accelerator=modifier + "+S")
     self.fileMenu.add_command(label=SAVE_AS + ELLIPSIS, underline=5,
             command=self.save_as, image=self.menuImages[SAVEAS],
             compound=tk.LEFT)
     if TkUtil.mac():
         self.master.createcommand("::tk::mac::ShowPreferences",
                 self.preferences)
         self.master.createcommand("exit", self.close)
     else:
         self.fileMenu.add_separator()
         self.fileMenu.add_command(label=PREFERENCES + ELLIPSIS,
                 underline=0, image=self.menuImages[PREFERENCES],
                 compound=tk.LEFT, command=self.preferences)
         self.fileMenu.add_separator()
         self.fileMenu.add_command(label=QUIT, underline=0,
                 command=self.close, compound=tk.LEFT,
                 image=self.menuImages[QUIT],
                 accelerator=modifier + "+Q")
     self.menubar.add_cascade(label="File", underline=0,
             menu=self.fileMenu)
开发者ID:ShuyaMotouchi,项目名称:joke,代码行数:34,代码来源:Main.py

示例6: populate_comboboxes

 def populate_comboboxes(self):
     currencies = sorted(self.rates.keys())
     for combobox in (self.currencyFromCombobox, self.currencyToCombobox):
         combobox.state(("readonly",))
         combobox.config(values=currencies)
     TkUtil.set_combobox_item(self.currencyFromCombobox, "USD", True)
     TkUtil.set_combobox_item(self.currencyToCombobox, "GBP", True)
     self.calculate()
开发者ID:johnobrien,项目名称:PyPractice,代码行数:8,代码来源:Main.py

示例7: create_widgets

 def create_widgets(self, master):
     self.frame = ttk.Frame(master)
     self.usernameLabel = ttk.Label(self.frame, text="Username:",
             underline=-1 if TkUtil.mac() else 0)
     self.usernameEntry = ttk.Entry(self.frame, width=25)
     self.usernameEntry.insert(0, getpass.getuser())
     self.passwordLabel = ttk.Label(self.frame, text="Password:",
             underline=-1 if TkUtil.mac() else 0)
     self.passwordEntry = ttk.Entry(self.frame, width=25, show="•")
开发者ID:ShuyaMotouchi,项目名称:joke,代码行数:9,代码来源:MeterLogin.py

示例8: unextend

 def unextend(self):
     self.extendButton.state((TkUtil.NOT_SELECTED,))
     self.extendButton.config(text="Extend",
             underline=1 if not TkUtil.mac() else -1)
     if not TkUtil.x11():
         self.extendButton.config(image=self.images[EXTEND])
     self.title("Find \u2014 {}".format(APPNAME))
     for widget in self.extensionWidgets:
         widget.grid_remove()
开发者ID:ShuyaMotouchi,项目名称:joke,代码行数:9,代码来源:Find.py

示例9: extend

 def extend(self):
     self.extendButton.state((TkUtil.SELECTED,))
     self.extendButton.config(text="Unextend",
             underline=3 if not TkUtil.mac() else -1)
     if not TkUtil.x11():
         self.extendButton.config(image=self.images[UNEXTEND])
     self.title("Find and Replace \u2014 {}".format(APPNAME))
     for widget in self.extensionWidgets:
         widget.grid()
开发者ID:ShuyaMotouchi,项目名称:joke,代码行数:9,代码来源:Find.py

示例10: create_edit_toolbar

 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)
开发者ID:johnobrien,项目名称:PyPractice,代码行数:56,代码来源:Main.py

示例11: create_bindings

 def create_bindings(self):
     modifier = TkUtil.key_modifier()
     self.master.bind("<{}-f>".format(modifier), self.find)
     self.master.bind("<{}-n>".format(modifier), self.new)
     self.master.bind("<{}-o>".format(modifier), self.open)
     self.master.bind("<{}-q>".format(modifier), self.close)
     self.master.bind("<{}-s>".format(modifier), self.save)
     self.master.bind("<F1>", self.help)
     for key in "fnoqs": # Avoid conflicts
         self.unbind_class("Text", "<{}-{}>".format(modifier, key))
     # Ctrl+C etc. from the edit menu are already supported by the
     # Text (Editor) widget.
     TkUtil.bind_context_menu(self.editor.text, self.context_menu)
开发者ID:ShuyaMotouchi,项目名称:joke,代码行数:13,代码来源:Main.py

示例12: close

 def close(self, event=None):
     settings = TkUtil.Settings.Data
     settings.put(GENERAL, RESTORE, self.restore)
     if self.restore:
         geometry = TkUtil.geometry_for_str(self.master.geometry())
         position = TkUtil.str_for_geometry(x=geometry.x, y= geometry.y)
         settings.put(GENERAL, POSITION, position)
     TkUtil.Settings.save()
     if self.worker is not None and self.worker.is_alive():
         self.state.value = TERMINATING
         self.update_ui()
         self.worker.join() # Wait for worker to finish
     self.quit()
开发者ID:ShuyaMotouchi,项目名称:joke,代码行数:13,代码来源:Main.py

示例13: create_window_menu

 def create_window_menu(self):
     modifier = TkUtil.menu_modifier()
     self.windowMenu = tk.Menu(self.menubar, name="window")
     self.windowToolbarMenu = tk.Menu(self.windowMenu)
     self.windowMenu.add_cascade(label="Toolbars", underline=0, menu=self.windowToolbarMenu)
     self.windowMenu.add_cascade(label="Dock Windows", underline=0)
     self.menubar.add_cascade(label="Window", underline=0, menu=self.windowMenu)
开发者ID:johnobrien,项目名称:PyPractice,代码行数:7,代码来源:Main.py

示例14: body

 def body(self, master):
     self.notebook = ttk.Notebook(master)
     self.notebook.enable_traversal()
     self.generalFrame = ttk.Frame(self.notebook)
     self.create_general_widgets(self.generalFrame)
     self.layout_general_widgets(self.generalFrame)
     self.advancedFrame = ttk.Frame(self.notebook)
     self.create_advanced_widgets(self.advancedFrame)
     self.layout_advanced_widgets(self.advancedFrame)
     self.notebook.add(self.generalFrame, text=GENERAL,
             underline=-1 if TkUtil.mac() else 0, padding=PAD)
     self.notebook.add(self.advancedFrame, text=ADVANCED,
             underline=-1 if TkUtil.mac() else 0, padding=PAD)
     self.notebook.pack(fill=tk.BOTH)
     self.create_bindings()
     return self.notebook
开发者ID:ShuyaMotouchi,项目名称:joke,代码行数:16,代码来源:Preferences.py

示例15: create_widgets

 def create_widgets(self):
     self.findLabel = TkUtil.Label(self, text="Find:", underline=1)
     self.findEntry = ttk.Entry(self, width=25)
     self.replaceLabel = TkUtil.Label(self, text="Replace:",
             underline=1)
     self.replaceEntry = ttk.Entry(self, width=25)
     self.caseSensitiveCheckbutton = TkUtil.Checkbutton(self,
             text="Case Sensitive", underline=5,
             variable=self.caseSensitive)
     self.wholeWordsCheckbutton = TkUtil.Checkbutton(self,
             text="Whole Words", underline=0,
             variable=self.wholeWords)
     self.findButton = TkUtil.Button(self, text="Find", underline=0,
             command=self.find, default=tk.ACTIVE, state=tk.DISABLED)
     self.replaceButton = TkUtil.Button(self, text="Replace",
             underline=0, command=self.replace, state=tk.DISABLED)
     self.closeButton = TkUtil.Button(self, text="Close", underline=0,
             command=self.close)
     if TkUtil.x11():
         self.extendButton = TkUtil.ToggleButton(self, text="Extend",
                 underline=1, command=self.toggle_extend)
     else:
         self.extendButton = ttk.Button(self, text="Extend",
                 underline=1, command=self.toggle_extend,
                 image=self.images[UNEXTEND], compound=tk.LEFT)
     self.extensionWidgets = (self.replaceLabel, self.replaceEntry,
             self.replaceButton)
开发者ID:ShuyaMotouchi,项目名称:joke,代码行数:27,代码来源:Find.py


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