本文整理汇总了Python中Tkinter.Tk.lift方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.lift方法的具体用法?Python Tk.lift怎么用?Python Tk.lift使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Tk
的用法示例。
在下文中一共展示了Tk.lift方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import lift [as 别名]
def show(text, background="#fff", timeout_ms=DEFAULT_TIMEOUT, font_size=100):
root = Tk()
root.attributes("-topmost", True)
root.lift()
# Set Timeout
root.after(timeout_ms, root.destroy)
# Create Frame
frame = Frame(root)
frame.pack(side=TOP, fill=BOTH, expand=YES)
# Set frame size and position
screen_width = frame.master.winfo_screenwidth()
screen_heigh = frame.master.winfo_screenheight()
w = screen_width * 0.8
h = screen_heigh * 0.6
# Center the window
x = (screen_width/2) - (w/2)
y = (screen_heigh/2) - (h/2)
frame.master.geometry('%dx%d+%d+%d' % (w, h, x, y))
# Adjust frame properties
frame.master.overrideredirect(True) # Set no border or title
frame.config(bg=background)
# Create text label
label = Label(frame, text=text, wraplength=screen_width * 0.8)
label.pack(side=TOP, expand=YES)
label.config(bg=background, justify=CENTER, font=("calibri", font_size))
# Set transparency
root.wait_visibility(root) # Needed for linux (and must come after overrideredirect)
root.attributes('-alpha', 0.6)
# Run Event loop
root.mainloop()
示例2: main
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import lift [as 别名]
def main():
root = Tk() # create tkinter window
root.lower() # send tkinter window to back
# create main app
app = App(root)
# Bring GUI to front # app.master = root
root.lift() # bring tk window to front if initialization finishes
root.focus_force() # make tk window active one (so you don't need to click on it for hotkeys to work)
root.mainloop() # start Tkinter GUI loop
示例3: ask_company
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import lift [as 别名]
def ask_company():
root = Tk()
app = Example(root)
wt = root.winfo_screenwidth()
ht = root.winfo_screenheight()
rootsize = (516, 102)
x = wt/2 - rootsize[0]/2
y = ht/2 - rootsize[1]/2
root.geometry("%dx%d+%d+%d" % (rootsize + (x, y)))
root.lift()
root.mainloop()
company = app.entry.get()
app.quit()
return(company)
示例4: getsavefilename
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import lift [as 别名]
def getsavefilename():
FilePicker = Tk()
FilePicker.withdraw() # we don't want a full GUI, so keep the root window from appearing
FilePicker.lift()
FilePicker.focus_force()
filename = tkFileDialog.asksaveasfilename(defaultextension=".wav")
if filename == "":
print("File select canceled.")
sys.exit(0)
FilePicker.destroy() # Destory our TKinter instance
return filename
示例5: pickvideofile
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import lift [as 别名]
def pickvideofile():
FilePicker = Tk()
FilePicker.withdraw() # we don't want a full GUI, so keep the root window from appearing
FilePicker.lift()
FilePicker.focus_force()
filename = tkFileDialog.askopenfilename(filetypes = [('MOV files', '.mov')])
# Assert file selected
if filename == "":
print("File select canceled.")
sys.exit(0)
FilePicker.destroy() # Destory our TKinter instance
return filename
示例6: TkApplicationWindow
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import lift [as 别名]
class TkApplicationWindow(AbstractApplicationWindow):
def __init__(self, app):
self.root = Tk()
self.root.title("Llia")
self.root.config(background=factory.bg())
super(TkApplicationWindow, self).__init__(app, self.root)
self.root.withdraw()
if app.config()["enable-splash"]:
splash = TkSplashWindow(self.root, app)
self.root.deiconify()
self.root.protocol("WM_DELETE_WINDOW", self.exit_app)
self.llia_graph = None
self._main = layout.BorderFrame(self.root)
self._main.config(background=factory.bg())
self._main.pack(anchor="nw", expand=True, fill=BOTH)
self._progressbar = None
self._init_status_panel()
self._init_menu()
self._init_center_frame(self._main.center)
self.root.minsize(width=665, height=375)
self.group_windows = []
self.add_synth_group()
self._scene_filename = ""
def _init_status_panel(self):
south = self._main.south
south.configure(padx=4, pady=4)
self._lab_status = factory.label(south, "", modal=False)
b_panic = factory.panic_button(south)
b_down = factory.button(south, "-")
b_up = factory.button(south, "+")
b_panic.grid(row=0, column=0)
self._progressbar = Progressbar(south,mode="indeterminate")
self._progressbar.grid(row=0,column=PROGRESSBAR_COLUMN, sticky='w', padx=8)
self._lab_status.grid(row=0,column=4, sticky='w')
south.config(background=factory.bg())
b_down.configure(command=lambda: self.root.lower())
b_up.configure(command=lambda: self.root.lift())
self.update_progressbar(100, 0)
def _tab_change_callback(self, event):
self.llia_graph.sync()
def _init_center_frame(self, master):
nb = ttk.Notebook(master)
nb.pack(expand=True, fill="both")
frame_synths = layout.FlowGrid(nb, 6)
frame_efx = layout.FlowGrid(nb, 6)
frame_controllers = layout.FlowGrid(nb, 6)
self.llia_graph = LliaGraph(nb, self.app)
nb.add(frame_synths, text = "Synths")
nb.add(frame_efx, text = "Effects")
nb.add(frame_controllers, text = "Controllers")
nb.add(self.llia_graph, text="Graph")
nb.bind("<Button-1>", self._tab_change_callback)
def display_info_callback(event):
sp = event.widget.synth_spec
msg = "%s: %s" % (sp["format"],sp["description"])
self.status(msg)
def clear_info_callback(*_):
self.status("")
for st in con.SYNTH_TYPES:
sp = specs[st]
ttp = "Add %s Synthesizer (%s)" % (st, sp["description"])
b = factory.logo_button(frame_synths, st, ttip=ttp)
b.synth_spec = sp
b.bind("<Button-1>", self._show_add_synth_dialog)
b.bind("<Enter>", display_info_callback)
b.bind("<Leave>", clear_info_callback)
frame_synths.add(b)
for st in con.EFFECT_TYPES:
sp = specs[st]
ttp = "Add %s Effect (%s)" % (st, sp["description"])
b = factory.logo_button(frame_efx, st, ttip=ttp)
b.synth_spec = sp
b.bind("<Button-1>", self._show_add_efx_dialog)
b.bind("<Enter>", display_info_callback)
b.bind("<Leave>", clear_info_callback)
frame_efx.add(b)
for st in con.CONTROLLER_SYNTH_TYPES:
sp = specs[st]
ttp = "Add %s Effect (%s)" % (st, sp["description"])
b = factory.logo_button(frame_controllers, st, ttip=ttp)
b.synth_spec = sp
b.bind("<Button-1>", self._show_add_controller_dialog)
b.bind("<Enter>", display_info_callback)
b.bind("<Leave>", clear_info_callback)
frame_controllers.add(b)
@staticmethod
def menu(master):
m = Menu(master, tearoff=0)
m.config(background=factory.bg(), foreground=factory.fg())
return m
def _init_menu(self):
#.........这里部分代码省略.........
示例7: UI
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import lift [as 别名]
class UI(object):
def __init__(self):
self._root = Tk()
self._root.title("^ NotiFire ^")
self._name = StringVar()
self._is_osx = which_system() == 'Darwin'
self._version = None
##########################################################################
#### Public methods #####
##########################################################################
def get_name(self):
frame = DraggableFrame(self._root)
frame.pack(side=TOP, fill=BOTH, expand=YES)
frame.columnconfigure(0, weight=1)
frame.columnconfigure(4, weight=1)
frame.rowconfigure(0, weight=1)
frame.rowconfigure(4, weight=1)
w = self._set_frame_geo(frame, 0.3, 0.3)[2]
self._set_x_button(frame, w, self._close_get_name)
Label(frame, text="Name:").grid(column=1, row=1)
entry_style = SUNKEN if self._is_osx else FLAT
entry = Entry(frame, exportselection=0, relief=entry_style, textvariable=self._name)
entry.grid(column=2, row=1)
entry.focus_set()
error_label = Label(frame, fg='red')
error_label.grid(column=1, row=2, columnspan=3)
ok_cmd = partial(self._validate_name, error_label)
FlatButton(frame, text='OK', width=20, font=("calibri", 15),
command=ok_cmd).grid(column=1, row=3, columnspan=3)
self._root.bind('<Return>', ok_cmd)
self._root.bind('<Escape>', self._close_get_name)
self._run()
return self._name.get() if self._name else self._name
def main_window(self, name, ping_callback):
self._name.set(name)
self._ping_callback = ping_callback
# Create Frame
self.frame = DraggableFrame(self._root)
self.frame.pack(side=TOP, fill=BOTH, expand=YES)
w = self._set_frame_geo(self.frame, 0.5, 0.6)[2]
self._set_x_button(self.frame, w, self._root.destroy)
Label(self.frame, text="Name:").place(x=10, y=15)
Label(self.frame, text=self._name.get(), fg='blue').place(x=80, y=15)
self._version_label = Label(self.frame, text="Newer version detected, please restart the app", fg='#a00', font=("calibri", 25))
FlatButton(self.frame, text="Test", width=26, command=self._test_action).place(x=10, y=50)
FlatButton(self.frame, text='Refresh', width=26, command=self._generate_ping_buttons).place(x=10, y=90)
self.ping_buttons = []
self._auto_refresh()
self._check_version()
self._run()
##########################################################################
#### Private methods #####
##########################################################################
def _run(self):
# Set transparency
self._root.wait_visibility(self._root)
self._root.attributes('-alpha', 0.95)
self._root.lift()
# Run Event loop
self._root.mainloop()
def _close_get_name(self, event=None):
self._name = None
self._root.destroy()
def _set_frame_geo(self, frame, wf, hf):
# Set frame size and position
screen_width = frame.master.winfo_screenwidth()
screen_heigh = frame.master.winfo_screenheight()
w = screen_width * wf
h = screen_heigh * hf
# Center the window
x = (screen_width/2) - (w/2)
y = (screen_heigh/2) - (h/2)
frame.master.geometry('%dx%d+%d+%d' % (w, h, x, y))
if not self._is_osx:
frame.master.overrideredirect(True) # Set no border or title
return x, y, w, h
def _set_x_button(self, frame, w, callback):
x_button_x_coordinate = w-30 if self._is_osx else w-20
FlatButton(frame, text='×', no_bg=True, width=1, font=("calibri", 15), command=callback).place(x=x_button_x_coordinate, y=-10)
def _validate_name(self, error_label, event=None):
name = self._name.get()
if not 0 < len(name) < 25:
error_label.config(text="Name must be 1-25 chars long")
logger.error("Invalid name: %s" % (name))
elif not all(ord(c) < 128 for c in name):
#.........这里部分代码省略.........
示例8: resetRaport
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import lift [as 别名]
failedBinput.delete(0, END)
newSinput.delete(0, END)
newAinput.delete(0, END)
newBinput.delete(0, END)
def resetRaport():
textField.delete(0.0, END)
# rysowanie okna
mainWindow = Tk()
mainWindow.title("Delivery status")
mainWindow.resizable(width=False, height=False)
mainWindow.lift()
inputFrame = Frame(mainWindow, padx=10, pady=10)
inputFrame.pack(fill="both")
resultFrame = LabelFrame(mainWindow, text=" Raport ", font=("Verdana", 15, "bold"), padx=10, pady=10)
resultFrame.pack(pady=5)
label0 = Label(inputFrame, text="Wprowadz wartosci:", font=("Vileda", 15, "bold"))
label0.grid(row=1, column=0, sticky="W")
label1 = Label(inputFrame, text="Ilosc wszystkich TC w spotchecku: ").grid(row=3, column=0, sticky="W")
totalTCinput = Entry(inputFrame)
totalTCinput.grid(row=3, column=1)
label2 = Label(inputFrame, text="Ilosc TC w spotchecku ze statusem Failed:").grid(row=4, column=0, sticky="W")
failedTCinput = Entry(inputFrame)
示例9: guiLogin
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import lift [as 别名]
def guiLogin(title, default_username="", default_password=""):
from Tkinter import Tk, N, S, W, E, StringVar
import ttk
root = Tk()
root.title(title)
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)
username = StringVar()
username.set(default_username)
password = StringVar()
password.set(default_password)
def done(*args):
root.destroy()
ttk.Label(mainframe, text="Username:").grid(column=1, row=1, sticky=(W, E))
username_entry = ttk.Entry(mainframe, width=7, textvariable=username)
username_entry.grid(column=2, row=1, sticky=(W, E))
ttk.Label(mainframe, text="Password:").grid(column=1, row=2, sticky=(W, E))
pass_entry = ttk.Entry(mainframe, width=7, textvariable=password, show="*")
pass_entry.grid(column=2, row=2, sticky=(W, E))
ttk.Button(mainframe, text="Login", command=done).grid(column=2, row=3, sticky=W)
for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=2)
username_entry.focus()
root.bind('<Return>', done)
root.bind('<Escape>', lambda event: root.destroy())
root.lift()
root.call('wm', 'attributes', '.', '-topmost', True)
root.after_idle(root.call, 'wm', 'attributes', '.', '-topmost', False)
root.mainloop()
return username.get(), password.get()
示例10: guiLogin
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import lift [as 别名]
def guiLogin():
root = Tk()
root.title("Enter Lastpass login")
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)
username = StringVar()
password = StringVar()
ret = []
def done(*args):
ret.append((username.get(), password.get()))
root.destroy()
ttk.Label(mainframe, text="Username:").grid(column=1, row=1, sticky=(W, E))
username_entry = ttk.Entry(mainframe, width=7, textvariable=username)
username_entry.grid(column=2, row=1, sticky=(W, E))
ttk.Label(mainframe, text="Password:").grid(column=1, row=2, sticky=(W, E))
pass_entry = ttk.Entry(mainframe, width=7, textvariable=password)
pass_entry.grid(column=2, row=2, sticky=(W, E))
ttk.Button(mainframe, text="Login", command=done).grid(column=2, row=3, sticky=W)
for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=2)
username_entry.focus()
root.bind('<Return>', done)
root.bind('<Escape>', lambda event: root.destroy())
root.lift()
root.call('wm', 'attributes', '.', '-topmost', True)
root.after_idle(root.call, 'wm', 'attributes', '.', '-topmost', False)
root.mainloop()
return ret and ret[-1] or None