本文整理汇总了Python中canvas.Canvas.setCurrentLayer方法的典型用法代码示例。如果您正苦于以下问题:Python Canvas.setCurrentLayer方法的具体用法?Python Canvas.setCurrentLayer怎么用?Python Canvas.setCurrentLayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类canvas.Canvas
的用法示例。
在下文中一共展示了Canvas.setCurrentLayer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from canvas import Canvas [as 别名]
# 或者: from canvas.Canvas import setCurrentLayer [as 别名]
#.........这里部分代码省略.........
def on_select(filename):
print("Directory: %s" % filename)
self.on_escape(dialog)
dialog = kytten.DirectorySelectDialog(
window=self.window, batch=self.canvas.batch, group=self.fg_group,
anchor=kytten.ANCHOR_CENTER,
theme=self.cobalt, on_escape=self.on_escape, on_select=on_select)
def on_select(self, choice):
if choice == 'Open File':
self.create_file_load_dialog()
elif choice == 'Save File':
self.create_file_save_dialog()
elif choice == 'Directory Select':
self.create_directory_select_dialog()
else:
print("Unexpected menu selection: %s" % choice)
def mainDialog(self):
def brushMenu(command):
if command == 'Increase Brush Size' or command =='Decrease Brush Size':
self.canvas.setBrushSize(command)
elif command == 'Pencil':
self.canvas.setPencil()
elif command == 'Eraser':
self.canvas.setEraser()
# Set up a Dialog to choose test dialogs to show
dialog = kytten.Dialog(
kytten.Frame(
kytten.HorizontalLayout([
kytten.Dropdown(['Save File', 'Open File'],
on_select=self.on_select, text="File"),
kytten.Dropdown(['Copy', 'Cut', 'Paste'],
on_select=self.on_select, text="Edit"),
kytten.Dropdown(['Pencil', 'Eraser', 'Increase Brush Size', 'Decrease Brush Size'],
on_select=brushMenu, text="Brush"),
], padding=0, align=kytten.VALIGN_TOP)
),
window=self.window, batch=self.canvas.batch, group=self.fg_group,
anchor=kytten.ANCHOR_TOP_LEFT,
on_mouse_release=self.on_mouse_release,
theme=self.cobalt)
def layerDialog(self):
# Set up a Dialog to choose test dialogs to show
def createLayer():
self.canvas.addLayer()
dialog.teardown()
self.layerDialog()
def focusLayer(foo):
def func():
self.canvas.setCurrentLayer(foo)
return func
def incLayer(foo):
def func():
self.canvas.incrementLayer(foo)
dialog.teardown()
self.layerDialog()
return func
def decLayer(foo):
def func():
self.canvas.decrementLayer(foo)
dialog.teardown()
self.layerDialog()
return func
def delLayer(foo):
def func():
self.canvas.deleteLayer(foo)
dialog.teardown()
self.layerDialog()
return func
content = [item for sublist in
[
[kytten.HorizontalLayout([
kytten.Button("S", on_click=focusLayer(layer.index)),
kytten.Checkbox(layer.name, is_checked=layer.visible,
on_click=layer.toggleVisibility),
kytten.Button("^", on_click=incLayer(layer.index)),
kytten.Button("v", on_click=decLayer(layer.index))
])
] for layer in self.canvas.layers]
for item in sublist]
content.append(kytten.Button("Create Layer", on_click=createLayer))
dialog = kytten.Dialog(
kytten.Frame(
kytten.VerticalLayout(
content,
padding=0, align=kytten.VALIGN_TOP)
),
window=self.window, batch=self.canvas.batch, group=self.fg_group,
anchor=kytten.ANCHOR_TOP_RIGHT,
on_mouse_release=self.on_mouse_release,
theme=self.cobalt)