当前位置: 首页>>代码示例>>Python>>正文


Python CurrentFont.removeLayer方法代码示例

本文整理汇总了Python中mojo.roboFont.CurrentFont.removeLayer方法的典型用法代码示例。如果您正苦于以下问题:Python CurrentFont.removeLayer方法的具体用法?Python CurrentFont.removeLayer怎么用?Python CurrentFont.removeLayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mojo.roboFont.CurrentFont的用法示例。


在下文中一共展示了CurrentFont.removeLayer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: apply_callback

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import removeLayer [as 别名]
 def apply_callback(self, sender):
     font = CurrentFont()
     _layer_name = self.w._layer_name.get()
     if _layer_name in font.layerOrder:
         print 'deleting layer %s...' % _layer_name
         font.removeLayer(_layer_name)
         print '...done.\n'
         font.update()
     else:
         print 'font does not have layer %s.' % _layer_name
开发者ID:miguelsousa,项目名称:hTools2,代码行数:12,代码来源:delete_layer.py

示例2: deleteLayerDialog

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import removeLayer [as 别名]
class deleteLayerDialog(hDialog):

    '''A dialog to delete a layer in a font.

    .. image:: imgs/font/delete-layer.png

    '''

    #: The font which is currently selected.
    font = None

    #: A list of all layers in the current font.
    layers = []

    def __init__(self):
        self.get_font()
        # window
        self.title = 'layers'
        self.height = self.button_height + (self.padding_y*3) + (self.text_height*8)
        self.w = HUDFloatingWindow((self.width, self.height), self.title)
        x = self.padding_x
        y = self.padding_y
        self.w.layers = List(
                    (x, y,
                    -self.padding_x,
                    self.text_height*8),
                    self.layers)
        y += self.padding_y + self.text_height*8
        self.w.button_apply = SquareButton(
                    (x, y,
                    -self.padding_x,
                    self.button_height),
                    "delete",
                    sizeStyle=self.size_style,
                    callback=self.apply_callback)
        # bind
        self.w.bind("became key", self.update_callback)
        self.w.bind("close", self.on_close_window)
        # observers
        addObserver(self, "update_callback", "fontBecameCurrent")
        # open
        self.w.open()

    # callbacks

    def get_font(self):
        self.font = CurrentFont()
        if self.font is not None:
            self.layers = self.font.layerOrder
        else:
            self.layers = []

    def update_ui(self):
        self.layers = self.font.layerOrder
        self.w.layers.set(self.layers)

    def update_callback(self, sender):
        self.get_font()
        self.update_ui()

    def apply_callback(self, sender):
        # no font open
        if self.font is None:
            print no_font_open
        # delete layer
        else:
            layers_index = self.w.layers.getSelection()
            layers = [self.layers[i] for i in layers_index]
            if len(layers):
                print 'deleting layers...\n'
                for layer in layers:
                    if layer in self.font.layerOrder:
                        print '\tdeleting %s...' % layer
                        self.font.removeLayer(layer)
                self.font.changed()
                print
                print '...done.\n'
                # update UI
                self.get_font()
                self.update_ui()
            else:
                print 'no layer selected.'

    def on_close_window(self, sender):
        removeObserver(self, "fontBecameCurrent")
开发者ID:gferreira,项目名称:hTools2,代码行数:87,代码来源:layer_delete.py

示例3: deleteLayerDialog

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import removeLayer [as 别名]
class deleteLayerDialog(hDialog):

    """A dialog to delete a layer in a font.

    .. image:: imgs/font/delete-layer.png

    """

    # attributes

    #: The font which is currently selected.
    font = None

    #: A list of all layers in the current font.
    layers = []

    # methods

    def __init__(self):
        self.get_font()
        # window
        self.title = 'layers'
        self.column_1 = 50
        self.column_2 = 140
        self.height = self.button_height + (self.padding_y * 3) + (self.text_height * 1) #+ 2
        self.w = FloatingWindow((self.width, self.height), self.title)
        x = self.padding_x
        y = self.padding_y
        # self.w.layer_name_label = TextBox(
        #             (x, y - 2,
        #             -self.padding_x,
        #             self.text_height),
        #             "name",
        #             sizeStyle=self.size_style)
        # y += self.text_height
        self.w.layers = PopUpButton(
                    (x, y,
                    -self.padding_x,
                    self.text_height),
                    self.layers,
                    sizeStyle=self.size_style)
        x = self.padding_x
        y += self.padding_y + self.text_height
        self.w.button_apply = SquareButton(
                    (x, y,
                    -self.padding_x,
                    self.button_height),
                    "delete",
                    sizeStyle=self.size_style,
                    callback=self.apply_callback)
        # bind
        self.w.bind("became key", self.update_callback)
        self.w.bind("close", self.on_close_window)
        # observers
        addObserver(self, "update_callback", "fontBecameCurrent")
        # open
        self.w.open()

    # callbacks

    def get_font(self):
        self.font = CurrentFont()
        if self.font is not None:
            self.layers = self.font.layerOrder
        else:
            self.layers = []

    def update_ui(self):
        self.w.layers.setItems(self.layers)

    def update_callback(self, sender):
        self.get_font()
        self.update_ui()

    def apply_callback(self, sender):
        # no font open
        if self.font is None:
            print no_font_open
        # delete layer
        else:
            layer_index = self.w.layers.get()
            layer_name = self.layers[layer_index]
            if layer_name in self.font.layerOrder:
                print 'deleting layer...\n'
                print '\t%s' % layer_name
                self.font.removeLayer(layer_name)
                print
                print '...done.\n'
                self.font.update()
                self.get_font()
                self.update_ui()
            else:
                print 'Font does not have layer %s.' % layer_name

    def on_close_window(self, sender):
        removeObserver(self, "fontBecameCurrent")
开发者ID:jackjennings,项目名称:hTools2_extension,代码行数:98,代码来源:layer_delete.py

示例4: CurrentFont

# 需要导入模块: from mojo.roboFont import CurrentFont [as 别名]
# 或者: from mojo.roboFont.CurrentFont import removeLayer [as 别名]
# [h] delete all layers

'''Delete all layers in the current font.'''

try:
    from mojo.roboFont import CurrentFont
except ImportError:
    from robofab.world import CurrentFont

f = CurrentFont()

while len(f.layerOrder) > 0:
    f.removeLayer(f.layerOrder[0])
    f.update()
开发者ID:SandrineNugue,项目名称:hTools2,代码行数:16,代码来源:delete+all.py


注:本文中的mojo.roboFont.CurrentFont.removeLayer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。