本文整理汇总了Python中tkinter.Menu.grab_release方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.grab_release方法的具体用法?Python Menu.grab_release怎么用?Python Menu.grab_release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tkinter.Menu
的用法示例。
在下文中一共展示了Menu.grab_release方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_button_click
# 需要导入模块: from tkinter import Menu [as 别名]
# 或者: from tkinter.Menu import grab_release [as 别名]
def handle_button_click(self, event):
val = self.button_selected.get() - 1
val = self.radio_buttons.index(event.widget)
if event.state & 0x001: # Shift key down
self.x_flipped[val] = not self.x_flipped[val]
try:
raise IOError
image_file = imget(self.img_lists[val][self.images_selected[val]])
import_image = Image.open(image_file)
except IOError:
image_file = imget_bdgp(self.img_lists[val][self.images_selected[val]])
import_image = Image.open(image_file)
import_image = import_image.resize((180,80), Image.ANTIALIAS)
import_image = import_image.rotate(180*self.x_flipped[val])
embryo_image = ImageTk.PhotoImage(import_image)
label = Label(image=embryo_image)
label.image = embryo_image
self.radio_buttons[val].configure(
#text=image_file,
image=label.image,
)
elif event.state & 0x004: # Control key down
popup = Menu(root, tearoff=0)
popup.add_command(label=self.radio_buttons[val].cget('text'))
popup.add_separator()
popup.add_command(label="Invert X")
popup.add_command(label="Invert Y")
try:
popup.tk_popup(event.x_root, event.y_root, 0)
finally:
# make sure to release the grab (Tk 8.0a1 only)
popup.grab_release()
elif val >= 0:
self.images_selected[val] = ((self.images_selected[val] + 2*event.num
- 3) %
len(self.img_lists[val]))
self.x_flipped[val] = False
if self.images_selected[val] == 0:
stdout.write('\a')
stdout.flush()
try:
raise IOError
image_file = imget(self.img_lists[val][self.images_selected[val]])
import_image = Image.open(image_file)
except IOError:
image_file = imget_bdgp(self.img_lists[val][self.images_selected[val]])
import_image = Image.open(image_file)
import_image = import_image.resize((180,80), Image.ANTIALIAS)
embryo_image = ImageTk.PhotoImage(import_image)
label = Label(image=embryo_image)
label.image = embryo_image
self.radio_buttons[val].configure(
#text=image_file,
image=label.image,
)
self.image_files[val] = image_file
self.button_selected.set(-1)