本文整理汇总了Python中tkinter.Listbox.event_generate方法的典型用法代码示例。如果您正苦于以下问题:Python Listbox.event_generate方法的具体用法?Python Listbox.event_generate怎么用?Python Listbox.event_generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Listbox
的用法示例。
在下文中一共展示了Listbox.event_generate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from tkinter import Listbox [as 别名]
# 或者: from tkinter.Listbox import event_generate [as 别名]
#.........这里部分代码省略.........
if self._is_drawing_polygon:
x, y = self._canvas.window_to_canvas_coords(event.x, event.y)
self._current_layer.get_polygon_at(-1).get_vertex_at(-1)\
.set_coords(x, y)
self._canvas.notify_polygon_change(self._current_layer
.get_polygon_count()-1)
def _layer_change(self, event):
selection = self._layer_list.curselection()
if len(selection) > 0 and self._scene:
layer = self._scene.get_layer_at(selection[0])
if layer:
self._is_drawing_polygon = False
self._current_layer = layer
self._canvas.notify_new_layer(self._current_layer)
def _set_scene(self, scene: Scene) -> bool:
if scene.get_layer_count() <= 0:
messagebox.showerror("Error!", "Scene has no layers!")
return False
self._scene = scene
# Prepare canvas
# TODO Extra 10px padding for canvas
width, height = self._scene.get_size()
self._canvas.config(scrollregion=(0, 0, width, height))
# Empty listbox, fill it, select first entry
self._layer_list.delete(0, self._layer_list.size()-1)
for i in range(0, self._scene.get_layer_count()):
self._layer_list.insert(i, self._scene.get_layer_at(i).get_name())
self._layer_list.selection_set(0)
self._layer_list.event_generate("<<ListboxSelect>>")
return True
def _set_current_path(self, path):
self._current_path = path
if path:
self._tk.title(path + " - Layered Polygons")
else:
self._tk.title("Untitled - Layered Polygons")
def _new_scene(self):
path = filedialog.askopenfilename(defaultextension=".ora",
filetypes=[("OpenRaster files",
".ora")])
if not path:
return
scene = ora.read(path)
if not scene:
messagebox.showerror("Error!", "File could not be opened!")
return
if self._set_scene(scene):
self._set_current_path(None)
def _open_scene(self):
path = filedialog.askopenfilename(defaultextension=".lp",
filetypes=[("Layered polygons"
" files", ".lp")])
if not path:
return