本文整理汇总了Python中TkUtil.mac方法的典型用法代码示例。如果您正苦于以下问题:Python TkUtil.mac方法的具体用法?Python TkUtil.mac怎么用?Python TkUtil.mac使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TkUtil
的用法示例。
在下文中一共展示了TkUtil.mac方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_widgets
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
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")
示例2: create_widgets
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
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="•")
示例3: body
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
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
示例4: create_file_menu
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
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)
示例5: unextend
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
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()
示例6: extend
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
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()
示例7: create_bindings
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
def create_bindings(self):
if not TkUtil.mac():
self.bind("<Alt-b>",
lambda *args: self.blinkCheckbutton.invoke())
self.bind("<Alt-f>",
lambda *args: self.restoreFontCheckbutton.invoke())
self.bind("<Alt-s>",
lambda *args: self.restoreSessionCheckbutton.invoke())
self.bind("<Alt-w>",
lambda *args: self.restoreWindowCheckbutton.invoke())
示例8: show
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
def show(self):
self.leave()
self.tip = tk.Toplevel(self.master)
self.tip.withdraw() # Don't show until we have the geometry
self.tip.wm_overrideredirect(True) # No window decorations etc.
if TkUtil.mac():
self.tip.tk.call("::tk::unsupported::MacWindowStyle",
"style", self.tip._w, "help", "none")
label = ttk.Label(self.tip, text=self.text, padding=1,
background=self.background, wraplength=480,
relief=None if TkUtil.mac() else tk.GROOVE,
font=tkfont.nametofont("TkTooltipFont"))
label.pack()
x, y = self.position()
self.tip.wm_geometry("+{}+{}".format(x, y))
self.tip.deiconify()
if self.master.winfo_viewable():
self.tip.transient(self.master)
self.tip.update_idletasks()
self.timerId = self.master.after(self.showTime, self.hide)
示例9: create_ui
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
def create_ui(self):
self.helpLabel = ttk.Label(self, text=_TEXT, background="white")
self.closeButton = TkUtil.Button(self, text="Close", underline=0)
self.helpLabel.pack(anchor=tk.N, expand=True, fill=tk.BOTH,
padx=PAD, pady=PAD)
self.closeButton.pack(anchor=tk.S)
self.protocol("WM_DELETE_WINDOW", self.close)
if not TkUtil.mac():
self.bind("<Alt-c>", self.close)
self.bind("<Escape>", self.close)
self.bind("<Expose>", self.reposition)
示例10: update_ui
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
def update_ui(self, *args):
guiState = self.state.value
if guiState == WORKING:
text = "Cancel"
underline = 0 if not TkUtil.mac() else -1
state = "!" + tk.DISABLED
elif guiState in {CANCELED, TERMINATING}:
text = "Canceling..."
underline = -1
state = tk.DISABLED
elif guiState == IDLE:
text = "Scale"
underline = 1 if not TkUtil.mac() else -1
state = ("!" + tk.DISABLED if self.sourceText.get() and
self.targetText.get() else tk.DISABLED)
self.scaleButton.state((state,))
self.scaleButton.config(text=text, underline=underline)
state = tk.DISABLED if guiState != IDLE else "!" + tk.DISABLED
for widget in (self.sourceEntry, self.sourceButton,
self.targetEntry, self.targetButton):
widget.state((state,))
self.master.update() # Make sure the GUI refreshes
示例11: create_help_menu
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
def create_help_menu(self):
helpMenu = tk.Menu(self.menubar, name="help")
if TkUtil.mac():
self.master.createcommand("tkAboutDialog", self.about)
self.master.createcommand("::tk::mac::ShowHelp", self.help)
else:
helpMenu.add_command(label=HELP, underline=0,
command=self.help, image=self.images[HELP],
compound=tk.LEFT, accelerator="F1")
helpMenu.add_command(label=ABOUT, underline=0,
command=self.about, image=self.images[ABOUT],
compound=tk.LEFT)
self.menubar.add_cascade(label=HELP, underline=0,
menu=helpMenu)
示例12: on_modified
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
def on_modified(self, event=None):
if not hasattr(self, "modifiedLabel"):
self.editor.edit_modified(False)
return
if self.editor.edit_modified():
text, mac, state = "MOD", True, tk.NORMAL
else:
text, mac, state = "", False, tk.DISABLED
self.modifiedLabel.config(text=text)
if TkUtil.mac():
self.master.attributes("-modified", mac)
self.fileMenu.entryconfigure(SAVE, state=state)
self.fileMenu.entryconfigure(SAVE_AS + ELLIPSIS, state=state)
self.saveButton.config(state=state)
self.editMenu.entryconfigure(UNDO, state=state)
self.undoButton.config(state=state)
示例13: create_bindings
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
def create_bindings(self):
self.protocol("WM_DELETE_WINDOW", self.close)
if not TkUtil.mac():
self.bind("<Alt-c>", self.close)
self.bind("<Alt-e>", lambda *args: self.replaceEntry.focus())
self.bind("<Alt-f>", self.find)
self.bind("<Alt-i>", lambda *args: self.findEntry.focus())
self.bind("<Alt-r>", self.replace)
self.bind("<Alt-s>",
lambda *args: self.caseSensitiveCheckbutton.invoke())
self.bind("<Alt-w>",
lambda *args: self.wholeWordsCheckbutton.invoke())
self.bind("<Alt-x>", lambda *args: self.extendButton.invoke())
self.bind("<Return>", self.find)
self.bind("<Escape>", self.close)
self.findEntry.bind("<KeyRelease>", self.update_ui)
self.replaceEntry.bind("<KeyRelease>", self.update_ui)
示例14: create_file_menu
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
def create_file_menu(self):
# Ctrl is nicer than Control for menus
modifier = TkUtil.menu_modifier()
fileMenu = tk.Menu(self.menubar, name="apple")
fileMenu.add_command(label=NEW, underline=0,
command=self.board.new_game, compound=tk.LEFT,
image=self.images[NEW], accelerator=modifier + "+N")
if TkUtil.mac():
self.master.createcommand("exit", self.close)
else:
fileMenu.add_separator()
fileMenu.add_command(label="Quit", underline=0,
command=self.close, compound=tk.LEFT,
image=self.images[CLOSE],
accelerator=modifier + "+Q")
self.menubar.add_cascade(label="File", underline=0,
menu=fileMenu)
示例15: create_bindings
# 需要导入模块: import TkUtil [as 别名]
# 或者: from TkUtil import mac [as 别名]
def create_bindings(self):
if not TkUtil.mac():
self.master.bind("<Alt-a>", lambda *args:
self.targetEntry.focus())
self.master.bind("<Alt-b>", self.about)
self.master.bind("<Alt-c>", self.scale_or_cancel)
self.master.bind("<Alt-h>", self.help)
self.master.bind("<Alt-i>", lambda *args:
self.dimensionCombobox.focus())
self.master.bind("<Alt-o>", lambda *args:
self.sourceEntry.focus())
self.master.bind("<Alt-q>", self.close)
self.master.bind("<Alt-s>", lambda *args: self.choose_folder(
SOURCE))
self.master.bind("<Alt-t>", lambda *args: self.choose_folder(
TARGET))
self.master.bind("<F1>", self.help)
self.sourceEntry.bind("<KeyRelease>", self.update_ui)
self.targetEntry.bind("<KeyRelease>", self.update_ui)
self.master.bind("<Return>", self.scale_or_cancel)