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


Python albow.Menu类代码示例

本文整理汇总了Python中albow.Menu的典型用法代码示例。如果您正苦于以下问题:Python Menu类的具体用法?Python Menu怎么用?Python Menu使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

 def __init__(self, inventory, data):
     Panel.__init__(self)
     self.inventory = inventory
     slot, id, count, damage = data
     self.former_id_text = id
     self.slot = slot
     self.id = TextFieldWrapped(text=id, doNotTranslate=True, width=300)
     #&# Prototype for blocks/items names
     self.menu = None
     m = Menu("", [""])
     h = m.font.get_linesize()
     self.menu = Menu("", [""], scrolling=True, scroll_items=(self.root.local_to_global(self.root.bottomleft)[1] - self.root.local_to_global(self.bottomleft)[1] - (m.margin * 2)) / h)
     del m
     self.id.change_action = self.text_entered
     self.id.escape_action = self.close_menu
     self.menu.key_down = self.id.key_down
     #&#
     self.count = IntField(text="%s"%count, min=-64, max=64)
     self.damage = IntField(text="%s"%damage, min=-32768, max=32767)
     header = Label(_("Inventory Slot #%s")%slot, doNotTranslate=True)
     row = Row([Label("id"), self.id,
                Label("Count"), self.count,
                Label("Damage"), self.damage,
                ])
     buttons = Row([Button("Save", action=self.dismiss), Button("Cancel", action=self.cancel)])
     col = Column([header, row, buttons], spacing=2)
     self.add(col)
     self.shrink_wrap()
开发者ID:Pumpkin-Framework,项目名称:MCEdit-Unified,代码行数:28,代码来源:nbtexplorer.py

示例2: MenuButton

class MenuButton(Button):
    def __init__(self, title, choices, **kw):
        Button.__init__(self, title, **kw)
        self.choices = choices
        self.menu = Menu(title, ((c,c) for c in choices))
        
    def action(self):
        index = self.menu.present(self, (0,0))
        if index == -1: return
        self.menu_picked(index)
        
    def menu_picked(self, index):
        pass
开发者ID:codewarrior0,项目名称:mcedit,代码行数:13,代码来源:mceutils.py

示例3: __init__

 def __init__(self, title, choices, **kw):
     Button.__init__(self, title, **kw)
     self.choices = choices
     self.menu = Menu(title, ((c, c) for c in choices))
开发者ID:TrazLander,项目名称:Traz-Fork-MCEdit-Unified,代码行数:4,代码来源:mceutils.py

示例4: SlotEditor

class SlotEditor(Panel):
    def __init__(self, inventory, data):
        Panel.__init__(self)
        self.inventory = inventory
        slot, id, count, damage = data
        self.former_id_text = id
        self.slot = slot
        self.id = TextFieldWrapped(text=id, doNotTranslate=True, width=300)
        #&# Prototype for blocks/items names
        self.menu = None
        m = Menu("", [""])
        h = m.font.get_linesize()
        self.menu = Menu("", [""], scrolling=True, scroll_items=(self.root.local_to_global(self.root.bottomleft)[1] - self.root.local_to_global(self.bottomleft)[1] - (m.margin * 2)) / h)
        del m
        self.id.change_action = self.text_entered
        self.id.escape_action = self.close_menu
        self.menu.key_down = self.id.key_down
        #&#
        self.count = IntField(text="%s"%count, min=-64, max=64)
        self.damage = IntField(text="%s"%damage, min=-32768, max=32767)
        header = Label(_("Inventory Slot #%s")%slot, doNotTranslate=True)
        row = Row([Label("id"), self.id,
                   Label("Count"), self.count,
                   Label("Damage"), self.damage,
                   ])
        buttons = Row([Button("Save", action=self.dismiss), Button("Cancel", action=self.cancel)])
        col = Column([header, row, buttons], spacing=2)
        self.add(col)
        self.shrink_wrap()

    def cancel(self, *args, **kwargs):
        kwargs['save'] = False
        self.dismiss(*args, **kwargs)

    def dismiss(self, *args, **kwargs):
        if kwargs.pop('save', True):
            data = [self.slot, self.id.text, self.count.text, self.damage.text]
            self.inventory.change_value(data)
        Panel.dismiss(self, *args, **kwargs)

    #&# Prototype for blocks/items names
    def text_entered(self):
        text = self.id.get_text()
        if self.former_id_text == text:
            return
        results = []
        for k in map_items.keys():
            k = mclangres.translate(k)
            if text.lower() in k.lower():
                results.append(k)
        results.sort()
        self.menu.set_items([[a] for a in results])
        self.menu.scrolling = True
        self.menu.set_scroll_items((self.root.local_to_global(self.parent.bottomleft)[1] - self.root.local_to_global(self.bottomleft)[1] - (self.menu.margin * 2)) / self.menu.font.get_linesize())
        sel = self.menu.present(self.id, (0, self.id.bottom - self.margin))
        if sel >= 0:
            self.former_id_text = self.menu.items[sel][0]
            self.id.change_text(self.menu.items[sel][0])
            self.former_id_text = self.menu.items[sel][0]

    def close_menu(self):
        if self.menu:
            self.menu.dismiss(-1)
开发者ID:Pumpkin-Framework,项目名称:MCEdit-Unified,代码行数:63,代码来源:nbtexplorer.py


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