本文整理汇总了Python中tkinter.Toplevel.wm_overrideredirect方法的典型用法代码示例。如果您正苦于以下问题:Python Toplevel.wm_overrideredirect方法的具体用法?Python Toplevel.wm_overrideredirect怎么用?Python Toplevel.wm_overrideredirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Toplevel
的用法示例。
在下文中一共展示了Toplevel.wm_overrideredirect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: do
# 需要导入模块: from tkinter import Toplevel [as 别名]
# 或者: from tkinter.Toplevel import wm_overrideredirect [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)