本文整理汇总了Python中Tkinter.Tk.wait_visibility方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.wait_visibility方法的具体用法?Python Tk.wait_visibility怎么用?Python Tk.wait_visibility使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Tk
的用法示例。
在下文中一共展示了Tk.wait_visibility方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: show
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import wait_visibility [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: UI
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import wait_visibility [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):
#.........这里部分代码省略.........
示例3: render_pix
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import wait_visibility [as 别名]
# Renderfunktion - wird pro Pixel aufgerufen
def render_pix(x, y, color):
img.put(color.toValidatedHexString(), (x, HEIGHT-y))
if x%320 == 0:
canvas.update()
# Fenster & Canvas aufbauen
mw = Tk()
mw._root().wm_title("Raytracer")
cFrame = Frame(mw, width=WIDTH, height=HEIGHT)
cFrame.pack()
canvas = Canvas(cFrame, width=WIDTH, height=HEIGHT, bg="white")
# Bild für Pixelunterstützung
img = PhotoImage(width=WIDTH, height=HEIGHT)
canvas.create_image(0, 0, image=img, anchor=NW)
canvas.pack()
# camera initialisieren
camera = Camera(Point(0,2,10), Vector(0,1,0), Point(0,3,0), FIELD_OF_VIEW)
camera.setScreenSize(WIDTH, HEIGHT)
# Anfangen zu Rendern, nachdem Canvas sichtbar ist
mw.wait_visibility()
camera.render(render_pix, objectList, lightList, level=RENDER_LEVEL)
# start
mw.mainloop()