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


Python Dialog.__init__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from albow.dialogs import Dialog [as 别名]
# 或者: from albow.dialogs.Dialog import __init__ [as 别名]
    def __init__(self, mcedit):
        Dialog.__init__(self)

        self.mcedit = mcedit

        self.langs = {}
        self.sgnal = {}
开发者ID:Dominic001,项目名称:MCEdit-Unified,代码行数:9,代码来源:options.py

示例2: __init__

# 需要导入模块: from albow.dialogs import Dialog [as 别名]
# 或者: from albow.dialogs.Dialog import __init__ [as 别名]
    def __init__(self, mcedit):
        Dialog.__init__(self)
        self.changes = {}
        self.changesNum = False
        self.enter = 0
        self.root = None
        self.editor = None

        buttonRow = (albow.Button("Assign Key...", action=self.askAssignSelectedKey),
                    albow.Button("Done", action=self.done), albow.Button("Cancel", action=self.cancel))

        buttonRow = albow.Row(buttonRow)

        resetToDefaultRow = albow.Row((albow.Button("Reset to default", action=self.resetDefault),))

        choiceButton = albow.ChoiceButton(["WASD", "ESDF", "Arrows", "Numpad", "WASD Old"], choose=self.choosePreset)
        if config.keys.forward.get() == "E":
            choiceButton.selectedChoice = "ESDF"
        elif config.keys.forward.get() == "Up":
            choiceButton.selectedChoice = "Arrows"
        elif config.keys.forward.get() == "[8]":
            choiceButton.selectedChoice = "Numpad"
        elif config.keys.brake.get() == "Space":
            choiceButton.selectedChoice = "WASD Old"

        self.oldChoice = choiceButton.selectedChoice

        choiceRow = albow.Row((albow.Label("Keybind Presets:"), choiceButton))
        self.choiceButton = choiceButton

        #.#
        spacing = 0
        tb = albow.TableView()
        self.nrows = 581 / tb.font.get_linesize()
        keyConfigTable = albow.TableView(nrows=581 / tb.font.get_linesize(),
            columns=[albow.TableColumn("Command", 200, "l"), albow.TableColumn("Assigned Key", 150, "r")])
        del tb
        keyConfigTable.num_rows = lambda: len(self.keyConfigKeys)
        keyConfigTable.row_data = self.getRowData
        keyConfigTable.row_is_selected = lambda x: x == self.selectedKeyIndex
        keyConfigTable.click_row = self.selectTableRow
        keyConfigTable.key_down = self.key_down
        keyConfigTable.key_up = self.key_up
        tableWidget = albow.Widget()
        tableWidget.add(keyConfigTable)
        tableWidget.shrink_wrap()

        self.keyConfigTable = keyConfigTable
        #.#

        col = albow.Column((tableWidget, choiceRow, buttonRow, resetToDefaultRow), spacing=spacing, margin=0)
        self.add(col)
        self.shrink_wrap()
开发者ID:Iciciliser,项目名称:MCEdit-Unified,代码行数:55,代码来源:keys.py

示例3: __init__

# 需要导入模块: from albow.dialogs import Dialog [as 别名]
# 或者: from albow.dialogs.Dialog import __init__ [as 别名]
    def __init__(self, mcedit):
        Dialog.__init__(self)

        self.mcedit = mcedit

        fieldOfViewRow = mceutils.FloatInputRow("Field of View: ",
                                                ref=config.settings.fov, width=100, min=25, max=120)

        targetFPSRow = mceutils.IntInputRow("Target FPS: ",
                                            ref=config.settings.targetFPS, width=100, min=1, max=60)

        bufferLimitRow = mceutils.IntInputRow("Vertex Buffer Limit (MB): ",
                                              ref=config.settings.vertexBufferLimit, width=100, min=0)

        fastLeavesRow = mceutils.CheckBoxLabel("Fast Leaves",
                                               ref=config.settings.fastLeaves,
                                               tooltipText="Leaves are solid, like Minecraft's 'Fast' graphics")

        roughGraphicsRow = mceutils.CheckBoxLabel("Rough Graphics",
                                                  ref=config.settings.roughGraphics,
                                                  tooltipText="All blocks are drawn the same way (overrides 'Fast Leaves')")

        enableMouseLagRow = mceutils.CheckBoxLabel("Enable Mouse Lag",
                                                   ref=config.settings.enableMouseLag,
                                                 tooltipText="Enable choppy mouse movement for faster loading.")

        packs = resource_packs.packs.get_available_resource_packs()
        packs.remove('Default')
        packs.sort()
        packs.insert(0, 'Default')
        self.resourcePackButton = mceutils.ChoiceButton(packs, choose=self.change_texture)
        self.resourcePackButton.selectedChoice = resource_packs.packs.get_selected_resource_pack_name()

        settingsColumn = albow.Column((fastLeavesRow,
                                       roughGraphicsRow,
                                       enableMouseLagRow,
                                       #                                  texturePackRow,
                                       fieldOfViewRow,
                                       targetFPSRow,
                                       bufferLimitRow,
                                       self.resourcePackButton,
                                      ), align='r')

        settingsColumn = albow.Column((albow.Label("Settings"),
                                       settingsColumn))

        settingsRow = albow.Row((settingsColumn,))

        optionsColumn = albow.Column((settingsRow, albow.Button("OK", action=self.dismiss)))

        self.add(optionsColumn)
        self.shrink_wrap()
开发者ID:Dominic001,项目名称:MCEdit-Unified,代码行数:54,代码来源:graphics.py

示例4: __init__

# 需要导入模块: from albow.dialogs import Dialog [as 别名]
# 或者: from albow.dialogs.Dialog import __init__ [as 别名]
 def __init__(self):
     Dialog.__init__(self)
     emc = EnableMusicControl()
     mvc = MusicVolumeControl()
     controls = Grid([
         [Label("Enable Music"), emc],
         [Label("Music Volume"), mvc],
     ])
     buttons = Button("OK", self.ok)
     contents = Column([controls, buttons], align = 'r', spacing = 20)
     contents.topleft = (20, 20)
     self.add(contents)
     self.shrink_wrap()
开发者ID:codewarrior0,项目名称:mcedit,代码行数:15,代码来源:music.py

示例5: __init__

# 需要导入模块: from albow.dialogs import Dialog [as 别名]
# 或者: from albow.dialogs.Dialog import __init__ [as 别名]
 def __init__(self, prompt=None, suffixes=None, **kwds):
     Dialog.__init__(self, **kwds)
     label = None
     d = self.margin
     self.suffixes = suffixes or ("",)
     up_button = Button(self.up_button_text, action=self.go_up)
     dir_box = DirPathView(self.box_width + 250, self)
     self.dir_box = dir_box
     top_row = Row([dir_box, up_button])
     list_box = FileListView(self.box_width - 16, self)
     self.list_box = list_box
     tree = FSTree(self, inner_width=250, directory="/")
     self.tree = tree
     row = Row((tree, list_box), margin=0)
     ctrls = [top_row, row]
     prompt = prompt or self.default_prompt
     if prompt:
         label = Label(prompt)
     if self.saving:
         filename_box = TextFieldWrapped(self.box_width)
         filename_box.change_action = self.update_filename
         filename_box._enter_action = filename_box.enter_action
         filename_box.enter_action = self.enter_action
         self.filename_box = filename_box
         ctrls.append(Column([label, filename_box], align="l", spacing=0))
     else:
         if label:
             ctrls.insert(0, label)
     ok_button = Button(self.ok_label, action=self.ok, enable=self.ok_enable)
     self.ok_button = ok_button
     cancel_button = Button("Cancel", action=self.cancel)
     vbox = Column(ctrls, align="l", spacing=d)
     vbox.topleft = (d, d)
     y = vbox.bottom + d
     ok_button.topleft = (vbox.left, y)
     cancel_button.topright = (vbox.right, y)
     self.add(vbox)
     self.add(ok_button)
     self.add(cancel_button)
     self.shrink_wrap()
     self._directory = None
     self.directory = os.getcwdu()
     # print "FileDialog: cwd =", repr(self.directory) ###
     if self.saving:
         filename_box.focus()
开发者ID:germanalen,项目名称:MCEdit-Unified,代码行数:47,代码来源:file_dialogs.py

示例6: __init__

# 需要导入模块: from albow.dialogs import Dialog [as 别名]
# 或者: from albow.dialogs.Dialog import __init__ [as 别名]
    def __init__(self):
        Dialog.__init__(self)
        keyConfigTable = albow.TableView(nrows=30,
            columns=[albow.TableColumn("Command", 200, "l"), albow.TableColumn("Assigned Key", 150, "r")])
        keyConfigTable.num_rows = lambda: len(self.keyConfigKeys)
        keyConfigTable.row_data = self.getRowData
        keyConfigTable.row_is_selected = lambda x: x == self.selectedKeyIndex
        keyConfigTable.click_row = self.selectTableRow
        keyConfigTable.key_down = self.key_down
        keyConfigTable.key_up = self.key_up
        self.changes = {}
        self.changesNum = False
        self.enter = 0
        self.root = None
        self.editor = None
        tableWidget = albow.Widget()
        tableWidget.add(keyConfigTable)
        tableWidget.shrink_wrap()

        self.keyConfigTable = keyConfigTable

        buttonRow = (albow.Button("Assign Key...", action=self.askAssignSelectedKey),
                    albow.Button("Done", action=self.done))

        buttonRow = albow.Row(buttonRow)

        choiceButton = mceutils.ChoiceButton(["WASD", "Arrows", "Numpad", "WASD Old"], choose=self.choosePreset)
        if config.keys.forward.get() == "Up":
            choiceButton.selectedChoice = "Arrows"
        elif config.keys.forward.get() == "[8]":
            choiceButton.selectedChoice = "Numpad"
        elif config.keys.brake.get() == "Space":
            choiceButton.selectedChoice = "WASD Old"

        self.oldChoice = choiceButton.selectedChoice

        choiceRow = albow.Row((albow.Label("Presets: "), choiceButton))
        self.choiceButton = choiceButton

        col = albow.Column((tableWidget, choiceRow, buttonRow))
        self.add(col)
        self.shrink_wrap()
开发者ID:Dominic001,项目名称:MCEdit-Unified,代码行数:44,代码来源:keys.py

示例7: __init__

# 需要导入模块: from albow.dialogs import Dialog [as 别名]
# 或者: from albow.dialogs.Dialog import __init__ [as 别名]
    def __init__(self, mcedit):
        Dialog.__init__(self)

        self.mcedit = mcedit

        self.langs = {}
        self.sgnal = {}
        self.portableVar = albow.AttrRef(self, 'portableLabelText')
        self.saveOldPortable = self.portableVar.get()

        self.saveOldConfig = {
            config.controls.autobrake:                        config.controls.autobrake.get(),
            config.controls.swapAxes:                         config.controls.swapAxes.get(),
            config.controls.cameraAccel:                      config.controls.cameraAccel.get(),
            config.controls.cameraDrag:                       config.controls.cameraDrag.get(),
            config.controls.cameraMaxSpeed:                   config.controls.cameraMaxSpeed.get(),
            config.controls.cameraBrakingSpeed:               config.controls.cameraBrakingSpeed.get(),
            config.controls.mouseSpeed:                       config.controls.mouseSpeed.get(),
            config.settings.undoLimit:                        config.settings.undoLimit.get(),
            config.settings.maxCopies:                        config.settings.maxCopies.get(),
            config.controls.invertMousePitch:                 config.controls.invertMousePitch.get(),
            config.settings.spaceHeight:                      config.settings.spaceHeight.get(),
            albow.AttrRef(self, 'blockBuffer'):               albow.AttrRef(self, 'blockBuffer').get(),
            config.settings.setWindowPlacement:               config.settings.setWindowPlacement.get(),
            config.settings.rotateBlockBrush:                 config.settings.rotateBlockBrush.get(),
            config.settings.shouldResizeAlert:                config.settings.shouldResizeAlert.get(),
            config.settings.superSecretSettings:              config.settings.superSecretSettings.get(),
            config.settings.longDistanceMode:                 config.settings.longDistanceMode.get(),
            config.settings.flyMode:                          config.settings.flyMode.get(),
            config.settings.langCode:                         config.settings.langCode.get(),
            config.settings.compassToggle:                    config.settings.compassToggle.get(),
            config.settings.compassSize:                      config.settings.compassSize.get(),
            config.settings.fontProportion:                   config.settings.fontProportion.get(),
            config.settings.fogIntensity:                     config.settings.fogIntensity.get(),
            config.schematicCopying.cancelCommandBlockOffset: config.schematicCopying.cancelCommandBlockOffset.get()
        }
        global old_lang
        if old_lang == None:
            old_lang = config.settings.langCode.get()
        global old_fprop
        if old_fprop == None:
            old_fprop = config.settings.fontProportion.get()
开发者ID:Iciciliser,项目名称:MCEdit-Unified,代码行数:44,代码来源:options.py

示例8: __init__

# 需要导入模块: from albow.dialogs import Dialog [as 别名]
# 或者: from albow.dialogs.Dialog import __init__ [as 别名]
    def __init__(self, inventory, data, *args, **kwargs):
        Dialog.__init__(self, *args, **kwargs)
        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)
        self.id.change_action = self.text_entered
        self.id.escape_action = self.cancel
        self.id.enter_action = self.ok
        self.count = IntField(text="%s"%count, min=0, max=64)
        self.damage = IntField(text="%s"%damage, min=0, max=os.sys.maxint)
        header = Label(_("Inventory Slot #%s")%slot, doNotTranslate=True)
        row = Row([Label("id"), self.id,
                   Label("Count"), self.count,
                   Label("Damage"), self.damage,
                   ])
        
        self.matching_items = [mclangres.translate(k) for k in map_items.keys()]
        self.matching_items.sort()
        self.selected_item_index = None
        if id in self.matching_items:
            self.selected_item_index = self.matching_items.index(id)
        self.tableview = tableview = TableView(columns=[TableColumn("", 415, 'l')])
        tableview.num_rows = lambda: len(self.matching_items)
        tableview.row_data = lambda x: (self.matching_items[x],)
        tableview.row_is_selected = lambda x: x == self.selected_item_index
        tableview.click_row = self.select_tablerow
        
        
        buttons = Row([Button("Save", action=self.dismiss), Button("Cancel", action=self.cancel)])
        col = Column([header, row, tableview, buttons], spacing=2)
        self.add(col)
        self.shrink_wrap()

        try:
            self.tableview.rows.scroll_to_item(self.selected_item_index)
        except Exception, e:
            print e
            pass
开发者ID:vongola12324,项目名称:MCEdit-Unified,代码行数:42,代码来源:nbtexplorer.py

示例9: __init__

# 需要导入模块: from albow.dialogs import Dialog [as 别名]
# 或者: from albow.dialogs.Dialog import __init__ [as 别名]
	def __init__(self, prompt = None, suffixes = None, **kwds):
		Dialog.__init__(self, **kwds)
		label = None
		d = self.margin
		self.suffixes = suffixes
		up_button = Button("<-", action = self.go_up)
		dir_box = DirPathView(self.box_width - up_button.rect.width - 10, self)
		self.dir_box = dir_box
		top_row = Row([dir_box, up_button])
		list_box = FileListView(self.box_width - 16, self)
		self.list_box = list_box
		ctrls = [top_row, list_box]
		prompt = prompt or self.default_prompt
		if prompt:
			label = Label(prompt)
		if self.saving:
			filename_box = TextField(self.box_width)
			filename_box.change_action = self.update
			self.filename_box = filename_box
			ctrls.append(Column([label, filename_box], align = 'l', spacing = 0))
		else:
			if label:
				ctrls.insert(0, label)
		ok_button = Button(self.ok_label, action = self.ok, enable = self.ok_enable)
		self.ok_button = ok_button
		cancel_button = Button("Cancel", action = self.cancel)
		vbox = Column(ctrls, align = 'l', spacing = d)
		vbox.rect.topleft = (d, d)
		y = vbox.rect.bottom + d
		ok_button.rect.topleft = (vbox.rect.left, y)
		cancel_button.rect.topright = (vbox.rect.right, y)
		self.add(vbox)
		self.add(ok_button)
		self.add(cancel_button)
		self.shrink_wrap()
		self._directory = None
		self.directory = os.getcwd()
		if self.saving:
			filename_box.focus()
开发者ID:FinnStokes,项目名称:orpheus,代码行数:41,代码来源:file_dialogs.py

示例10: __init__

# 需要导入模块: from albow.dialogs import Dialog [as 别名]
# 或者: from albow.dialogs.Dialog import __init__ [as 别名]
    def __init__(self, blockInfo, materials, *a, **kw):
        self.allowWildcards = False
        Dialog.__init__(self, *a, **kw)
        panelWidth = 350

        self.materials = materials
        self.anySubtype = blockInfo.wildcard

        self.matchingBlocks = materials.allBlocks

        try:
            self.selectedBlockIndex = self.matchingBlocks.index(blockInfo)
        except ValueError:
            self.selectedBlockIndex = 0
            for i, b in enumerate(self.matchingBlocks):
                if blockInfo.ID == b.ID and blockInfo.blockData == b.blockData:
                    self.selectedBlockIndex = i
                    break


        lbl = Label("Search")
        #lbl.rect.topleft = (0,0)

        fld = TextField(300)
        #fld.rect.topleft = (100, 10)
        #fld.centery = lbl.centery
        #fld.left = lbl.right

        fld.change_action = self.textEntered
        fld.enter_action = self.ok
        fld.escape_action = self.cancel

        self.awesomeField = fld

        searchRow = Row((lbl, fld))


        def formatBlockName(x):
            block = self.matchingBlocks[x]
            r = "({id}:{data}) {name}".format(name=block.name, id=block.ID, data=block.blockData)
            if block.aka:
                r += " [{0}]".format(block.aka)

            return r

        tableview = TableView(columns=[TableColumn(" ", 24, "l", lambda x: ""), TableColumn("(ID) Name [Aliases]", 276, "l", formatBlockName)])
        tableicons = [BlockView(materials) for i in range(tableview.rows.num_rows())]
        for t in tableicons:
            t.size = (16, 16)
            t.margin = 0
        icons = Column(tableicons, spacing=2)

        #tableview.margin = 5
        tableview.num_rows = lambda : len(self.matchingBlocks)
        tableview.row_data = lambda x: (self.matchingBlocks[x], x, x)
        tableview.row_is_selected = lambda x: x == self.selectedBlockIndex
        tableview.click_row = self.selectTableRow
        draw_table_cell = tableview.draw_table_cell
        def draw_block_table_cell(surf, i, data, cell_rect, column):
            if isinstance(data, Block):

                tableicons[i - tableview.rows.scroll].blockInfo = data
            else:
                draw_table_cell(surf, i, data, cell_rect, column)
        tableview.draw_table_cell = draw_block_table_cell
        tableview.width = panelWidth
        tableview.anchor = "lrbt"
        #self.add(tableview)
        self.tableview = tableview
        tableWidget = Widget()
        tableWidget.add(tableview)
        tableWidget.shrink_wrap()
        def wdraw(*args):
            for t in tableicons:
                t.blockInfo = materials.Air
        tableWidget.draw = wdraw
        self.blockButton = blockView = BlockThumbView(materials, self.blockInfo)

        blockView.centerx = self.centerx
        blockView.top = tableview.bottom

        #self.add(blockview)

        but = Button("OK")
        but.action = self.ok
        but.top = blockView.bottom
        but.centerx = self.centerx
        but.align = "c"
        but.height = 30

        if self.allowWildcards:
        #self.add(but)
            anyRow = CheckBoxLabel("Any Subtype", ref=AttrRef(self, 'anySubtype'), tooltipText="Replace blocks with any data value. Only useful for Replace operations.")
            col = Column((searchRow, tableWidget, anyRow, blockView, but))
        else:
            col = Column((searchRow, tableWidget, blockView, but))
        col.anchor = "wh"
        self.anchor = "wh"

        panel = GLBackground()
#.........这里部分代码省略.........
开发者ID:codewarrior0,项目名称:mcedit,代码行数:103,代码来源:toolbasics.py

示例11: __init__

# 需要导入模块: from albow.dialogs import Dialog [as 别名]
# 或者: from albow.dialogs.Dialog import __init__ [as 别名]
    def __init__(self, mcedit):
        Dialog.__init__(self)

        self.mcedit = mcedit

        self.saveOldConfig = {
            config.settings.fov: config.settings.fov.get(),
            config.settings.targetFPS: config.settings.targetFPS.get(),
            config.settings.vertexBufferLimit: config.settings.vertexBufferLimit.get(),
            config.settings.fastLeaves: config.settings.fastLeaves.get(),
            config.settings.roughGraphics: config.settings.roughGraphics.get(),
            config.settings.enableMouseLag: config.settings.enableMouseLag.get(),
            config.settings.maxViewDistance: config.settings.maxViewDistance.get()
        }

        self.saveOldResourcePack = resource_packs.packs.get_selected_resource_pack_name()

        self.fieldOfViewRow = albow.FloatInputRow("Field of View: ",
                                                ref=config.settings.fov, width=100, min=25, max=120)

        self.targetFPSRow = albow.IntInputRow("Target FPS: ",
                                                ref=config.settings.targetFPS, width=100, min=1, max=60)

        self.bufferLimitRow = albow.IntInputRow("Vertex Buffer Limit (MB): ",
                                                ref=config.settings.vertexBufferLimit, width=100, min=0)

        fastLeavesRow = albow.CheckBoxLabel("Fast Leaves",
                                                ref=config.settings.fastLeaves,
                                                tooltipText="Leaves are solid, like Minecraft's 'Fast' graphics")

        roughGraphicsRow = albow.CheckBoxLabel("Rough Graphics",
                                                ref=config.settings.roughGraphics,
                                                tooltipText="All blocks are drawn the same way (overrides 'Fast Leaves')")

        enableMouseLagRow = albow.CheckBoxLabel("Enable Mouse Lag",
                                                ref=config.settings.enableMouseLag,
                                                tooltipText="Enable choppy mouse movement for faster loading.")
        
        playerSkins = albow.CheckBoxLabel("Show Player Skins",
                                             ref=config.settings.downloadPlayerSkins,
                                             tooltipText="Show player skins while editing the world")
        
        self.maxView = albow.IntInputRow("Max View Distance",
                                       ref=config.settings.maxViewDistance,
                                       tooltipText="Sets the maximum view distance for the renderer. Values over 32 can possibly be unstable, so use it at your own risk"
                                       )
        self.maxView.subwidgets[1]._increment = 2

        packs = resource_packs.packs.get_available_resource_packs()
        packs.remove('Default Resource Pack')
        packs.sort()
        packs.insert(0, 'Default Resource Pack')
        self.resourcePackButton = albow.ChoiceButton(packs, choose=self.change_texture, doNotTranslate=True)
        self.resourcePackButton.selectedChoice = self.saveOldResourcePack

        settingsColumn = albow.Column((fastLeavesRow,
                                       roughGraphicsRow,
                                       enableMouseLagRow,
                                       #                                  texturePackRow,
                                       self.fieldOfViewRow,
                                       self.targetFPSRow,
                                       self.bufferLimitRow,
                                       self.maxView,
                                       playerSkins,
                                       self.resourcePackButton,
                                      ), align='r')

        settingsColumn = albow.Column((albow.Label("Graphics Settings"),
                                       settingsColumn))

        settingsRow = albow.Row((settingsColumn,))

        buttonsRow = albow.Row((albow.Button("OK", action=self.dismiss), albow.Button("Cancel", action=self.cancel)))

        resetToDefaultRow = albow.Row((albow.Button("Reset to default", action=self.resetDefault),))

        optionsColumn = albow.Column((settingsRow, buttonsRow, resetToDefaultRow))

        self.add(optionsColumn)
        self.shrink_wrap()
开发者ID:germanalen,项目名称:MCEdit-Unified,代码行数:82,代码来源:graphics.py

示例12: __init__

# 需要导入模块: from albow.dialogs import Dialog [as 别名]
# 或者: from albow.dialogs.Dialog import __init__ [as 别名]
    def __init__(self, blockInfo, materials, *a, **kw):
        self.root = get_root()
        self.allowWildcards = False
        Dialog.__init__(self, *a, **kw)
        panelWidth = 518

        self.click_outside_response = 0
        self.materials = materials
        self.anySubtype = blockInfo.wildcard

        self.matchingBlocks = materials.allBlocks
        #&#
        self.searchNames = [mclangres.translate(a.name).lower() for a in self.matchingBlocks]
        #&#

        try:
            self.selectedBlockIndex = self.matchingBlocks.index(blockInfo)
        except ValueError:
            self.selectedBlockIndex = 0
            for i, b in enumerate(self.matchingBlocks):
                if blockInfo.ID == b.ID and blockInfo.blockData == b.blockData:
                    self.selectedBlockIndex = i
                    break

        lbl = Label("Search")
        # lbl.rect.topleft = (0,0)

        fld = TextFieldWrapped(300)
        # fld.rect.topleft = (100, 10)
        # fld.centery = lbl.centery
        # fld.left = lbl.right

        fld.change_action = self.textEntered
        fld.enter_action = self.ok
        fld.escape_action = self.cancel
        fld.attention_lost = fld.commit

        self.awesomeField = fld

        searchRow = Row((lbl, fld))

        def formatBlockName(x):
            block = self.matchingBlocks[x]
            #&#
            #r = "{name}".format(name=block.name)
            r = u"{name}".format(name=mclangres.translate(block.name))
            #&#
            if block.aka:
                #&#
                #r += " [{0}]".format(block.aka)
                r += u" [{0}]".format(mclangres.translate(block.aka))
                #&#

            return r

        def formatBlockID(x):
            block = self.matchingBlocks[x]
            ident = "({id}:{data})".format(id=block.ID, data=block.blockData)
            return ident

        tableview = TableView(columns=[TableColumn(" ", 24, "l", lambda x: ""),
                                       TableColumn("Name", 415, "l", formatBlockName),
                                       TableColumn("ID", 45, "l", formatBlockID)
                                       ])
        tableicons = [blockview.BlockView(materials) for i in xrange(tableview.rows.num_rows())]
        for t in tableicons:
            t.size = (16, 16)
            t.margin = 0
        spacing = max(tableview.font.get_linesize() - 16, 2)
        icons = Column(tableicons, spacing=spacing)

        # tableview.margin = 5
        tableview.num_rows = lambda: len(self.matchingBlocks)
        tableview.row_data = lambda x: (self.matchingBlocks[x], x, x)
        tableview.row_is_selected = lambda x: x == self.selectedBlockIndex
        tableview.click_row = self.selectTableRow
        draw_table_cell = tableview.draw_table_cell

        def draw_block_table_cell(surf, i, data, cell_rect, column):
            if isinstance(data, Block):

                tableicons[i - tableview.rows.scroll].blockInfo = data
            else:
                draw_table_cell(surf, i, data, cell_rect, column)

        tableview.draw_table_cell = draw_block_table_cell
        tableview.width = panelWidth
        tableview.anchor = "lrbt"
        # self.add(tableview)
        self.tableview = tableview
        tableWidget = Widget()
        tableWidget.add(tableview)
        tableWidget.shrink_wrap()

        def wdraw(*args):
            for t in tableicons:
                t.blockInfo = materials.Air

        tableWidget.draw = wdraw
        self.blockButton = blockView = thumbview.BlockThumbView(materials, self.blockInfo)
#.........这里部分代码省略.........
开发者ID:fhfuih,项目名称:MCEdit-Unified,代码行数:103,代码来源:blockpicker.py

示例13: __init__

# 需要导入模块: from albow.dialogs import Dialog [as 别名]
# 或者: from albow.dialogs.Dialog import __init__ [as 别名]
    def __init__(self, prompt=None, suffixes=None, default_suffix=None, **kwds):
        Dialog.__init__(self, **kwds)
        label = None
        d = self.margin
        self.suffixes = suffixes or ("",)
        self.file_type = self.suffixes[0] # To be removed
        self.compute_file_types()
        self.default_suffix = default_suffix  # The default file extension. Will be searched in 'suffixes'.
        up_button = Button(self.up_button_text, action=self.go_up)
        dir_box = DirPathView(self.box_width + 250, self)
        self.dir_box = dir_box
        top_row = Row([dir_box, up_button])
        list_box = FileListView(self.box_width - 16, self)
        self.list_box = list_box
        tree = FSTree(self, inner_width=250, directory='/')
        self.tree = tree
        row = Row((tree, list_box), margin=0)
        ctrls = [top_row, row]
        prompt = prompt or self.default_prompt
        if prompt:
            label = Label(prompt)
        if suffixes:
            filetype_label = Label("File type", width=250)

            def set_file_type():
                self.file_type = self.filetype_button.get_value() # To be removed
                self.compute_file_types(self.filetype_button.get_value())
                self.list_box.update()

            filetype_button = ChoiceButton(choices=self.suffixes, width=250, choose=set_file_type)
            if default_suffix:
                v = next((s for s in self.suffixes if ("*.%s;"%default_suffix in s or "*.%s)"%default_suffix in s)), None)
                if v:
                    filetype_button.selectedChoice = v
                    self.compute_file_types(v)
            self.filetype_button = filetype_button
        if self.saving:
            filename_box = TextFieldWrapped(self.box_width)
            filename_box.change_action = self.update_filename
            filename_box._enter_action = filename_box.enter_action
            filename_box.enter_action = self.enter_action
            self.filename_box = filename_box
            if suffixes:
                ctrls.append(Row([Column([label, filename_box], align='l', spacing=0),
                                  Column([filetype_label, filetype_button], align='l', spacing=0)
                                  ],
                                 )
                             )
            else:
                ctrls.append(Column([label, filename_box], align='l', spacing=0))
        else:
            if label:
                ctrls.insert(0, label)
            if suffixes:
                ctrls.append(Column([filetype_label, filetype_button], align='l', spacing=0))
        ok_button = Button(self.ok_label, action=self.ok, enable=self.ok_enable)
        self.ok_button = ok_button
        cancel_button = Button("Cancel", action=self.cancel)
        vbox = Column(ctrls, align='l', spacing=d)
        vbox.topleft = (d, d)
        y = vbox.bottom + d
        ok_button.topleft = (vbox.left, y)
        cancel_button.topright = (vbox.right, y)
        self.add(vbox)
        self.add(ok_button)
        self.add(cancel_button)
        self.shrink_wrap()
        self._directory = None
        self.directory = os.getcwdu()
        #print "FileDialog: cwd =", repr(self.directory) ###
        if self.saving:
            filename_box.focus()
开发者ID:fhfuih,项目名称:MCEdit-Unified,代码行数:74,代码来源:file_dialogs.py


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