本文整理汇总了Python中tkinter.Toplevel.wm_attributes方法的典型用法代码示例。如果您正苦于以下问题:Python Toplevel.wm_attributes方法的具体用法?Python Toplevel.wm_attributes怎么用?Python Toplevel.wm_attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Toplevel
的用法示例。
在下文中一共展示了Toplevel.wm_attributes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import wm_attributes [as 别名]
class MailListWindow:
def __init__(self, title, after_close):
self.win = Toplevel()
self.win.title(title)
self.win.geometry('400x200')
self.win.wm_attributes('-toolwindow', True)
self.win.protocol("WM_DELETE_WINDOW", after_close)
inner_frame = tk.Frame(self.win)#inner_frame = tk.Frame(canvas)
inner_frame.pack(side='left', fill='both', expand = 1)
scrollbar = tk.Scrollbar(self.win,orient="vertical",command=self.scrolly)
scrollbar.pack(side='right', fill='y')
self.btn_count = 0
self.btns = []
self.texts = []
self.callbacks = []
self.frame = inner_frame
self.scrollbar = scrollbar
self.btn_per_page = 4
self.first_btn = 0
self.scrolly('', '0.0')
def scrolly(self, cmd, pos, what=''):
if self.btn_per_page <= self.btn_count:
bar_len = self.btn_per_page/self.btn_count
else:
bar_len=1
self.first_btn = int(float(pos)*self.btn_count)
pos = str(self.getScrollPos())
self.scrollbar.set(pos, str(float(pos)+bar_len))
for i in range(len(self.btns)):
mail_index = i+self.first_btn
self.btns[i].config(text=self.texts[mail_index], command=self.callbacks[mail_index])
def insertButton(self, text, callback):
if self.btn_count < self.btn_per_page:
btn = tk.Button(self.frame, bg='#fafafa',text=text, command=callback)
btn.pack(fill='both', expand=1)
self.btns.append(btn)
self.btn_count += 1
self.texts.append(text)
self.callbacks.append(callback)
self.scrolly('', self.getScrollPos())
def getScrollPos(self):
if self.btn_per_page >= self.btn_count:
return 0.0
if self.btn_count == 0:
return 0.0
return self.first_btn/self.btn_count
def callback(self):
print('click')
def destroy(self):
self.win.destroy()
示例2: splash
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import wm_attributes [as 别名]
class splash():
# try:
def __init__(self):
moduleDir = dirname(__file__)
moduleDir = moduleDir.rsplit('\\',2)[0]
image = moduleDir+'\\resources\\sirbot\\splash.gif'
self.root = Tk()
self.root.withdraw()
self.loadingSplash = Toplevel()
splashimage = PhotoImage(file=image)
self.loading = ttk.Label(self.loadingSplash,image=splashimage)
self.loadingSplash.overrideredirect(True)
self.loading.pack()
h = self.loading.winfo_screenheight()
w = self.loading.winfo_screenwidth()
self.loadingSplash.wm_attributes('-alpha',0.75)
self.loadingSplash.update_idletasks()
self.loadingSplash.geometry('262x112+'+str(int(w/2)-131*1)+
'+'+str(int(h/2)-56*1))
self.loadingSplash.update_idletasks()
self.loadingSplash.update()
# except:
## #log
## loadingSplash = Tk()
## #myfont = tkFont.families()[0]
## loading = Label(loadingSplash,text='SirBot')
## loadingSplash.overrideredirect(True)
## loading.pack()
##
## h = loading.winfo_screenheight()
## w = loading.winfo_screenwidth()
##
## loadingSplash.wm_attributes('-alpha',0.75)
## loadingSplash.update_idletasks()
## loadingSplash.geometry('262x112+'+str(int(w/2)-131*1)+
## '+'+str(int(h/2)-56*1))
## loadingSplash.update_idletasks()
## loadingSplash.update()
def destroy(self):
try:
self.loadingSplash.destroy()
except:
#log
pass
def getroot(self):
return(self.root)
示例3: do
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import wm_attributes [as 别名]
def do():
r, c = self.get_cursor_pos('insert')
script = jedi.api.Interpreter(
self.text.get(f'{r}.4', 'end-1c'),
[Scripting.namespaces['locals'],
Scripting.namespaces['globals']])
if len(script.completions())==0:
return 'break'
if len(script.completions())==1:
cstr = script.completions()[0].complete
self.text.insert('end', cstr)
return 'break'
acw = Toplevel(self.text)
acw.wm_overrideredirect(1)
acw.wm_attributes('-topmost', True)
seltext = Label(acw, anchor='w', justify='left')
seltext.pack(expand='yes', fill='x')
namelist = ScrolledList(acw)
namelist.pack(expand='yes', fill='both')
namelist.list_config(selectmode='single')
x, y, w, h = self.text.bbox('insert')
x += self.text.winfo_rootx()
y += self.text.winfo_rooty()
# y+h is the position below the current line.
acw.geometry(f'+{x}+{y}')
namelist.list.focus_set()
def on_exit(event):
acw.destroy()
acw.bind('<FocusOut>', on_exit)
namelist.list.bind('<Escape>', on_exit)
def on_updown(event, direction):
cursel = int(namelist.current_selection[0])
newsel = cursel + direction
if not (0<= newsel < namelist.length):
return 'break'
namelist.selection_clear(cursel)
namelist.selection_set(newsel)
namelist.see(newsel)
return 'break'
namelist.list.bind('<Down>', lambda event:on_updown(event, 1))
namelist.list.bind('<Tab>', lambda event:on_updown(event, 1))
namelist.list.bind('<Up>', lambda event:on_updown(event, -1))
namelist.list.bind('<Shift-Tab>', lambda event:on_updown(event, -1))
for completion in script.completions():
namelist.append(completion.name)
# init
namelist.selection_set(0)
def on_select(event):
cursel = int(namelist.current_selection[0])
cstr = script.completions()[cursel].complete
self.text.insert('end', cstr)
on_exit(None)
namelist.list.bind('<Return>', on_select)
namelist.list.bind('<ButtonRelease-1>', on_select)
keyseq = ['']
def on_key_press(event):
if (event.keysym not in self.root_node.lang_center.wavesynscript.constants.KEYSYM_MODIFIERS.value) and \
(event.keysym not in self.root_node.lang_center.wavesynscript.constants.KEYSYM_CURSORKEYS.value):
if event.keysym=='BackSpace':
keyseq[0] = keyseq[0][:-1]
else:
keyseq[0] += event.keysym
seltext['text'] = keyseq[0]
for idx, completion in enumerate(script.completions()):
if completion.complete.startswith(keyseq[0]):
cursel = int(namelist.current_selection[0])
namelist.selection_clear(cursel)
namelist.selection_set(idx)
namelist.see(idx)
return
on_exit(None)
else:
return
namelist.list.bind('<KeyPress>', on_key_press)