本文整理汇总了Python中tkinter.Toplevel.lift方法的典型用法代码示例。如果您正苦于以下问题:Python Toplevel.lift方法的具体用法?Python Toplevel.lift怎么用?Python Toplevel.lift使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Toplevel
的用法示例。
在下文中一共展示了Toplevel.lift方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: average_normals
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import lift [as 别名]
def average_normals( self ):
""" Applies Gouraud normalization to the module
"""
# Set up updater
top = Toplevel()
pb = Progressbar(top,orient ="horizontal",length = 200, mode ="determinate")
pb['maximum'] = len(self.__elements__)
pb['value'] = 10
pb.grid(row=0,column=0)
tx = Label(top)
tx.grid(row=1,column=0)
top.update_idletasks()
top.lift()
t0 = time.time()
# run the loop, if we're visible and phong shading
if not self.invisible == 'gouroud':
try:
buf = np.array([0,0,0,1])
for i,polygon in enumerate(self.__elements__):
if not ispoly(polygon): continue
polygon._onorms = np.array([polygon.normals.astype(float)+buf for i in range(len(polygon.coordinates))])
# Update the user as to what's going on
if i % 50 == 0 and i > 0:
pb['value'] = i
tmp = i/len(self.__elements__)
estimation = int(tmp*(time.time()-t0) * (1-tmp)/tmp)
tx.configure(text=str(int(100*i/len(self.__elements__)))+"%"+' Estimated time: '+str(estimation)+'s' )
top.update_idletasks()
for c,coordinate in enumerate(polygon.coordinates):
for j,opolygon in enumerate(self.__elements__):
if i == j or not ispoly(opolygon): continue
for k,ocoordinate in enumerate(opolygon.coordinates):
if all(coordinate == ocoordinate): # same vertex, finally
polygon._onorms[c] += (opolygon.normals+buf)
polygon._onorms /= polygon._onorms[:,3,None]
for polygon in self.__elements__:
if ispoly(polygon):
polygon.normals = polygon._onorms
del polygon._onorms
except IndexError as ie: pass
top.destroy()
if self.invisible == 'gouroud':
self.invisible = False
return self # for chaining
示例2: Overlay
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import lift [as 别名]
class Overlay(threading.Thread):
def __init__(self,
width, height,
xpos, ypos,
bgcolor, fgcolor,
fontsize, opacity,
messages, close):
threading.Thread.__init__(self, daemon=True)
self.width = width
self.height = height
self.xpos = xpos
self.ypos = ypos
self.bgcolor = bgcolor
self.fgcolor = fgcolor
self.fontsize = fontsize
self.opacity = opacity
self.messages = messages
self.close = close
username_colors = [
'#0000ff',
'#ff7f50',
'#1e90ff',
'#00ff7f',
'#9acd32',
'#00ff00',
'#ff4500',
'#ff0000',
'#daa520',
'#ff69b4',
'#5f9ea0',
'#2e8b57',
'#d2691e',
'#8a2be2',
'#b22222',
]
self.color_for = defaultdict(lambda: random.choice(username_colors))
self.start()
self.images = []
def die(self):
self.images = None
self.close.put('killme')
self.root.quit()
def run(self):
self.root = MyRoot()
self.root.lower()
self.root.iconify()
self.root.title('poetato overlay')
self.root.protocol('WM_DELETE_WINDOW', self.die)
self.app = Toplevel(self.root)
self.app.geometry("%dx%d+%d+%d" % (self.width, self.height,
self.xpos, self.ypos))
self.app.resizable(width=False, height=False)
self.app.overrideredirect(1)
self.app.minsize(width=self.width, height=self.height)
self.app.maxsize(width=self.width, height=self.height)
self.app.attributes(
'-alpha', self.opacity,
'-topmost', True,
'-disabled', True,
)
self.text = Text(self.app,
bg=self.bgcolor, fg=self.fgcolor,
wrap='word', state='disabled')
self.text.configure(font=('Helvetica', self.fontsize, 'bold'))
self.text.pack()
self.app.lift()
# tell Windows(tm) to allow clicks to pass through our overlay.
hWindow = pywintypes.HANDLE(int(self.root.frame(), 16))
exStyle = (win32con.WS_EX_LAYERED |
win32con.WS_EX_TRANSPARENT |
win32con.WS_EX_NOACTIVATE)
win32api.SetWindowLong(hWindow, win32con.GWL_EXSTYLE, exStyle)
self.app.after(100, self.update)
self.app.mainloop()
def update(self):
if self.messages.empty():
self.app.after(100, self.update)
return
msg = self.messages.get_nowait()
self.text['state'] = 'normal'
if self.text.index('end-1c') != '1.0':
self.text.insert('end', '\n')
self.text.insert('end', "{0}: ".format(msg.display_name))
emote_insertions = {}
for eid, pos in msg.emotes.items():
for p in pos:
emote_insertions[p[0]] = (msg.localemotes[eid], p[1]+1)
#.........这里部分代码省略.........