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


Python albow.Widget类代码示例

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


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

示例1: __init__

    def __init__(self, tool, module, *args, **kw):
        Widget.__init__(self, *args, **kw)
        self.tool = tool
        pages = TabPanel()
        pages.is_gl_container = True
        self.pages = pages
        self.optionDict = {}
        pageTabContents = []

        self.giveEditorObject(module)
        print "Creating options for ", module
        if hasattr(module, "inputs"):
            if isinstance(module.inputs, list):
                for tabData in module.inputs:
                    title, page, pageRect = self.makeTabPage(self.tool, tabData)
                    pages.add_page(title, page)
                    pages.set_rect(pageRect.union(pages._rect))
            elif isinstance(module.inputs, tuple):
                title, page, pageRect = self.makeTabPage(self.tool, module.inputs)
                pages.add_page(title, page)
                pages.set_rect(pageRect)
        else:
            self.size = (0, 0)

        pages.shrink_wrap()
        self.add(pages)
        self.shrink_wrap()
        if len(pages.pages):
            if (pages.current_page != None):
                pages.show_page(pages.current_page)
            else:
                pages.show_page(pages.pages[0])

        for eachPage in pages.pages:
            self.optionDict = dict(self.optionDict.items() + eachPage.optionDict.items())
开发者ID:LaChal,项目名称:MCEdit-Unified,代码行数:35,代码来源:filter.py

示例2: __init__

    def __init__(self, items, keysColumn=None, buttonsColumn=None):
        if keysColumn is None:
            keysColumn = []
        if buttonsColumn is None:
            buttonsColumn = []

        Widget.__init__(self)
        for (hotkey, title, action) in items:
            if isinstance(title, (str, unicode)):
                button = Button(title, action=action)
            else:
                button = ValueButton(ref=title, action=action, width=200)
            button.anchor = self.anchor

            label = Label(hotkey, width=75, margin=button.margin)
            label.anchor = "wh"

            label.height = button.height

            keysColumn.append(label)
            buttonsColumn.append(button)

        self.buttons = list(buttonsColumn)

        buttonsColumn = Column(buttonsColumn)
        buttonsColumn.anchor = self.anchor
        keysColumn = Column(keysColumn)

        commandRow = Row((keysColumn, buttonsColumn))
        self.add(commandRow)
        self.shrink_wrap()
开发者ID:TrazLander,项目名称:Traz-Fork-MCEdit-Unified,代码行数:31,代码来源:mceutils.py

示例3: __init__

    def __init__(self, items, keysColumn=None, buttonsColumn=None, item_spacing=None):
        warn(self)
        if keysColumn is None:
            keysColumn = []
        if buttonsColumn is None:
            buttonsColumn = []
        labels = []

        Widget.__init__(self)
        for t in items:
            if len(t) == 3:
                (hotkey, title, action) = t
                tooltipText = None
            else:
                (hotkey, title, action, tooltipText) = t
            if isinstance(title, (str, unicode)):
                button = Button(title, action=action)
            else:
                button = ValueButton(ref=title, action=action, width=200)
            button.anchor = self.anchor

            label = Label(hotkey, width=100, margin=button.margin)
            label.anchor = "wh"

            label.height = button.height

            labels.append(label)

            if tooltipText:
                button.tooltipText = tooltipText

            keysColumn.append(label)
            buttonsColumn.append(button)

        self.buttons = list(buttonsColumn)

        #.#
        if item_spacing == None:
            buttonsColumn = Column(buttonsColumn)
        else:
            buttonsColumn = Column(buttonsColumn, spacing=item_spacing)
        #.#
        buttonsColumn.anchor = self.anchor
        #.#
        if item_spacing == None:
            keysColumn = Column(keysColumn)
        else:
            keysColumn = Column(keysColumn, spacing=item_spacing)

        commandRow = Row((keysColumn, buttonsColumn))
        self.labels = labels
        self.add(commandRow)
        self.shrink_wrap()
开发者ID:BossosaurusRex,项目名称:MCEdit-Unified,代码行数:53,代码来源:mceutils.py

示例4: updateFilters

 def updateFilters(self):
     totalFilters = 0
     updatedFilters = 0
     filtersDir = directories.getFiltersDir()
     try:
         os.mkdir(os.path.join(filtersDir, "updates"))
     except OSError:
         pass
     for module in self.filterModules.values():
         totalFilters += 1
         if hasattr(module, "UPDATE_URL") and hasattr(module, "VERSION"):
             if isinstance(module.UPDATE_URL, (str, unicode)) and isinstance(module.VERSION, (str, unicode)):
                 versionJSON = json.loads(urllib2.urlopen(module.UPDATE_URL).read())
                 if module.VERSION != versionJSON["Version"]:
                     urllib.urlretrieve(versionJSON["Download-URL"],
                                        os.path.join(filtersDir, "updates", versionJSON["Name"]))
                     updatedFilters += 1
     for f in os.listdir(os.path.join(filtersDir, "updates")):
         shutil.copy(os.path.join(filtersDir, "updates", f), filtersDir)
     shutil.rmtree(os.path.join(filtersDir, "updates"))
     finishedUpdatingWidget = Widget()
     lbl = Label("Updated %s filter(s) out of %s" % (updatedFilters, totalFilters))
     closeBTN = Button("Close this message", action=finishedUpdatingWidget.dismiss)
     col = Column((lbl, closeBTN))
     finishedUpdatingWidget.bg_color = (0.0, 0.0, 0.6)
     finishedUpdatingWidget.add(col)
     finishedUpdatingWidget.shrink_wrap()
     finishedUpdatingWidget.present()
开发者ID:gwpantazes,项目名称:MCEdit-Unified,代码行数:28,代码来源:filter.py

示例5: updateFilters

 def updateFilters(self):
     totalFilters = 0
     updatedFilters = 0
     try:
         os.mkdir(mcplatform.filtersDir + "/updates")
     except OSError:
         pass
     for module in self.filterModules.values():
         totalFilters = totalFilters + 1
         if hasattr(module, "UPDATE_URL") and hasattr(module, "VERSION"):
             if isinstance(module.UPDATE_URL, (str, unicode)) and isinstance(module.VERSION, (str, unicode)):
                 versionJSON = json.loads(urllib2.urlopen(module.UPDATE_URL).read())
                 if module.VERSION != versionJSON["Version"]:
                     urllib.urlretrieve(versionJSON["Download-URL"],
                                        mcplatform.filtersDir + "/updates/" + versionJSON["Name"])
                     updatedFilters = updatedFilters + 1
     for f in os.listdir(mcplatform.filtersDir + "/updates"):
         shutil.copy(mcplatform.filtersDir + "/updates/" + f, mcplatform.filtersDir)
     shutil.rmtree(mcplatform.filtersDir + "/updates/")
     self.finishedUpdatingWidget = Widget()
     lbl = Label("Updated " + str(updatedFilters) + " filter(s) out of " + str(totalFilters))
     closeBTN = Button("Close this message", action=self.closeFinishedUpdatingWidget)
     col = Column((lbl, closeBTN))
     self.finishedUpdatingWidget.bg_color = (0.0, 0.0, 0.6)
     self.finishedUpdatingWidget.add(col)
     self.finishedUpdatingWidget.shrink_wrap()
     self.finishedUpdatingWidget.present()
开发者ID:LaChal,项目名称:MCEdit-Unified,代码行数:27,代码来源:filter.py

示例6: __init__

    def __init__(self, macro_data, *args, **kw):
        self._parent = None
        self._macro_data = macro_data
        if '_parent' in kw.keys():
            self._parent = kw.pop('_parent')

        Widget.__init__(self, *args, **kw)

        infoColList = []
        stepsLabel = wrapped_label("Number of steps: %s" % macro_data["Number of steps"], 300)
        infoColList.append(stepsLabel)
        for step in sorted(macro_data.keys()):
            if step != "Number of steps":
                infoColList.append(wrapped_label("Step %s: %s" % (int(step) + 1, macro_data[step]["Name"]), 300))
        self.add(Column(infoColList))
        self.shrink_wrap()
开发者ID:gwpantazes,项目名称:MCEdit-Unified,代码行数:16,代码来源:filter.py

示例7: __init__

 def __init__(self, file_types=None, operation=0, **kwds):
     Widget.__init__(self, **kwds)
     if file_types is None:
         self.file_types = ["*.*",]
     else:
         self.file_types = file_types
     self.file_path = None
     self._button = None
         
     if operation == self.OPEN_FILE:
         self._button = Button("Choose a file", action=self._open_file)
     elif operation == self.SAVE_FILE:
         self._button = Button("Save a file", action=self._save_file)
         
     self.add(self._button)
     
     self.shrink_wrap()
开发者ID:TropicSapling,项目名称:MCEdit-Unified,代码行数:17,代码来源:filter.py

示例8: draw

        def draw(self, surface):
            if self.root is None:
                self.root = self.get_root()
            Widget.draw(self, surface)
            frameStart = datetime.now()
            frameInterval = timedelta(0, 1, 0) / 2
            amount = None

            try:
                while datetime.now() < frameStart + frameInterval:
                    amount = progressIterator.next()
                    if self.firstDraw is False:
                        self.firstDraw = True
                        break

            except StopIteration:
                self.dismiss()

            infoText = ""
            if amount is not None:

                if isinstance(amount, tuple):
                    if len(amount) > 2:
                        infoText = ": " + amount[2]

                    amount, max = amount[:2]

                else:
                    max = amount
                maxwidth = (self.width - self.margin * 2)
                if amount is None:
                    self.progressBar.width = maxwidth
                    self.progressBar.bg_color = (255, 255, 25, 255)
                elif isinstance(amount, basestring):
                    self.statusText = amount
                else:
                    self.progressAmount = amount
                    if isinstance(amount, (int, float)):
                        self.progressFraction = float(amount) / (float(max) or 1)
                        self.progressBar.width = maxwidth * self.progressFraction
                        self.statusText = str("{0} / {1}".format(amount, max))
                    else:
                        self.statusText = str(amount)

                if infoText:
                    self.statusText += infoText
开发者ID:BossosaurusRex,项目名称:MCEdit-Unified,代码行数:46,代码来源:mceutils.py

示例9: __init__

    def __init__(self, editor):
        Widget.__init__(self)

        self.nudgeButton = NudgeButton(editor)
        self.nudgeButton.nudge = self._nudge

        self.xField = IntField(value=0)
        self.yField = IntField(value=0)
        self.zField = IntField(value=0)

        for field in (self.xField, self.yField, self.zField):
            field.change_action = self._coordsChanged
            field.enter_passes = False

        offsetCol = Column((self.xField, self.yField, self.zField))

        nudgeOffsetRow = Row((offsetCol, self.nudgeButton))

        self.add(nudgeOffsetRow)
        self.shrink_wrap()
开发者ID:Crayder,项目名称:MCEdit-Unified,代码行数:20,代码来源:clone.py

示例10: perform

def perform(level, box, options):
    op = options["Operation"]
    #print dir(level.scoreboard.Objectives)
    #print level.init_scoreboard().PlayerScores["Chevalerie94"]
    print "Test Filter Ran"
    if op == "Yes/No Dialog":
        choice = editor.YesNoWidget("Place a sponge block here?")
        if choice:
            yesFunc(level, box)
            raise Exception("Response was Yes")
        else:
            raise Exception("Response was No")
    elif op == "Custom Dialog (Hi Button)":
        widget = Widget()
        widget.bg_color = (0.0, 0.0, 0.6)
        lbl = Label("Test Message from a External Widget")
        btn = Button("Hi", action=hiAction)
        widget.add(lbl)
        widget.add(btn)
        widget.shrink_wrap()
        editor.addExternalWidget(widget)        
    elif op == "Scoreboard Editing (Objective)":
        scoreboard = level.init_scoreboard()
        test_objective = TAG_Compound()
        test_objective["Name"] = TAG_String("FilterObjective")
        test_objective["DisplayName"] = TAG_String("FilterObjective")
        test_objective["CriteriaName"] = TAG_String("dummy")
        test_objective["RenderType"] = TAG_String("integer")
        scoreboard["data"]["Objectives"].append(test_objective)
        level.save_scoreboard(scorebaord)
        for objective in score.Objectives:
            print "Objective Name: " + str(objective["Name"].value)
    elif op == "Scoreboard Editing (Team)":
        if level.scoreboard != None:
            for team in level.scoreboard.Teams:
                print "Team Name: " + str(team.DisplayName)
    elif op == "Player Data":
        players = level.init_player_data()
        for p in players:
            print p.name
            for item in p.inventory:
                print item["id"].value
                print "==="
            p.save()
开发者ID:freundTech,项目名称:MCEdit-Unified,代码行数:44,代码来源:Test.py

示例11: FilterTool

class FilterTool(EditorTool):
    tooltipText = "Filter"
    toolIconName = "filter"

    def __init__(self, editor):
        EditorTool.__init__(self, editor)

        self.filterModules = {}

        self.panel = FilterToolPanel(self)

    @property
    def statusText(self):
        return "Choose a filter, then click Filter or press ENTER to apply it."

    def toolEnabled(self):
        return not (self.selectionBox() is None)

    def toolSelected(self):
        self.showPanel()

    @alertException
    def showPanel(self):
        if self.panel.parent:
            self.editor.remove(self.panel)

        self.reloadFilters()

        # self.panel = FilterToolPanel(self)
        self.panel.reload()

        self.panel.midleft = self.editor.midleft

        self.editor.add(self.panel)

        self.updatePanel = Panel()
        updateButton = Button("Update Filters", action=self.updateFilters)
        self.updatePanel.add(updateButton)
        self.updatePanel.shrink_wrap()

        self.updatePanel.bottomleft = self.editor.viewportContainer.bottomleft
        self.editor.add(self.updatePanel)

    def hidePanel(self):
        self.panel.saveOptions()
        if self.panel.parent:
            self.panel.parent.remove(self.panel)
            self.updatePanel.parent.remove(self.updatePanel)

    def updateFilters(self):
        totalFilters = 0
        updatedFilters = 0
        try:
            os.mkdir(mcplatform.filtersDir + "/updates")
        except OSError:
            pass
        for module in self.filterModules.values():
            totalFilters = totalFilters + 1
            if hasattr(module, "UPDATE_URL") and hasattr(module, "VERSION"):
                if isinstance(module.UPDATE_URL, (str, unicode)) and isinstance(module.VERSION, (str, unicode)):
                    versionJSON = json.loads(urllib2.urlopen(module.UPDATE_URL).read())
                    if module.VERSION != versionJSON["Version"]:
                        urllib.urlretrieve(versionJSON["Download-URL"],
                                           mcplatform.filtersDir + "/updates/" + versionJSON["Name"])
                        updatedFilters = updatedFilters + 1
        for f in os.listdir(mcplatform.filtersDir + "/updates"):
            shutil.copy(mcplatform.filtersDir + "/updates/" + f, mcplatform.filtersDir)
        shutil.rmtree(mcplatform.filtersDir + "/updates/")
        self.finishedUpdatingWidget = Widget()
        lbl = Label("Updated " + str(updatedFilters) + " filter(s) out of " + str(totalFilters))
        closeBTN = Button("Close this message", action=self.closeFinishedUpdatingWidget)
        col = Column((lbl, closeBTN))
        self.finishedUpdatingWidget.bg_color = (0.0, 0.0, 0.6)
        self.finishedUpdatingWidget.add(col)
        self.finishedUpdatingWidget.shrink_wrap()
        self.finishedUpdatingWidget.present()

    def closeFinishedUpdatingWidget(self):
        self.finishedUpdatingWidget.dismiss()

    def reloadFilters(self):
        filterDir = mcplatform.filtersDir
        filterFiles = os.listdir(filterDir)
        filterPyfiles = filter(lambda x: x.endswith(".py"), filterFiles)

        def tryImport(name):
            try:
                return __import__(name)
            except Exception, e:
                print traceback.format_exc()
                alert(_(u"Exception while importing filter module {}. See console for details.\n\n{}").format(name, e))
                return object()

        filterModules = (tryImport(x[:-3]) for x in filterPyfiles)
        filterModules = filter(lambda module: hasattr(module, "perform"), filterModules)

        self.filterModules = collections.OrderedDict(sorted((self.moduleDisplayName(x), x) for x in filterModules))
        for m in self.filterModules.itervalues():
            try:
                reload(m)
#.........这里部分代码省略.........
开发者ID:LaChal,项目名称:MCEdit-Unified,代码行数:101,代码来源:filter.py

示例12: makeTabPage

    def makeTabPage(self, tool, inputs):
        page = Widget()
        page.is_gl_container = True
        rows = []
        cols = []
        height = 0
        max_height = 550
        page.optionDict = {}
        page.tool = tool
        title = "Tab"

        for optionName, optionType in inputs:
            if isinstance(optionType, tuple):
                if isinstance(optionType[0], (int, long, float)):
                    if len(optionType) > 2:
                        val, min, max = optionType
                    elif len(optionType) == 2:
                        min, max = optionType
                        val = min

                    rows.append(addNumField(page, optionName, val, min, max))

                if isinstance(optionType[0], (str, unicode)):
                    isChoiceButton = False

                    if optionType[0] == "string":
                        kwds = []
                        wid = None
                        val = None
                        for keyword in optionType:
                            if isinstance(keyword, (str, unicode)) and keyword != "string":
                                kwds.append(keyword)
                        for keyword in kwds:
                            splitWord = keyword.split('=')
                            if len(splitWord) > 1:
                                v = None
                                key = None

                                try:
                                    v = int(splitWord[1])
                                except:
                                    pass

                                key = splitWord[0]
                                if v is not None:
                                    if key == "lines":
                                        lin = v
                                    elif key == "width":
                                        wid = v
                                else:
                                    if key == "value":
                                        val = splitWord[1]

                        if val is None:
                            val = ""
                        if wid is None:
                            wid = 200

                        field = TextField(value=val, width=wid)
                        page.optionDict[optionName] = AttrRef(field, 'value')

                        row = Row((Label(optionName), field))
                        rows.append(row)
                    else:
                        isChoiceButton = True

                    if isChoiceButton:
                        choiceButton = ChoiceButton(map(str, optionType))
                        page.optionDict[optionName] = AttrRef(choiceButton, 'selectedChoice')

                        rows.append(Row((Label(optionName), choiceButton)))

            elif isinstance(optionType, bool):
                cbox = CheckBox(value=optionType)
                page.optionDict[optionName] = AttrRef(cbox, 'value')

                row = Row((Label(optionName), cbox))
                rows.append(row)

            elif isinstance(optionType, (int, float)):
                rows.append(addNumField(self, optionName, optionType))

            elif optionType == "blocktype" or isinstance(optionType, pymclevel.materials.Block):
                blockButton = BlockButton(tool.editor.level.materials)
                if isinstance(optionType, pymclevel.materials.Block):
                    blockButton.blockInfo = optionType

                row = Column((Label(optionName), blockButton))
                page.optionDict[optionName] = AttrRef(blockButton, 'blockInfo')

                rows.append(row)
            elif optionType == "label":
                rows.append(wrapped_label(optionName, 50))

            elif optionType == "string":
                input = None  # not sure how to pull values from filters, but leaves it open for the future. Use this variable to set field width.
                if input != None:
                    size = input
                else:
                    size = 200
#.........这里部分代码省略.........
开发者ID:LaChal,项目名称:MCEdit-Unified,代码行数:101,代码来源:filter.py

示例13: makeTabPage

    def makeTabPage(self, tool, inputs, trn=None, **kwargs):
        page = Widget(**kwargs)
        page.is_gl_container = True
        rows = []
        cols = []
        max_height = tool.editor.mainViewport.height - tool.editor.toolbar.height - tool.editor.subwidgets[0].height -\
            self._parent.filterSelectRow.height - self._parent.confirmButton.height - self.pages.tab_height

        page.optionDict = {}
        page.tool = tool
        title = "Tab"

        for optionSpec in inputs:
            optionName = optionSpec[0]
            optionType = optionSpec[1]
            if trn is not None:
                n = trn._(optionName)
            else:
                n = optionName
            if n == optionName:
                oName = _(optionName)
            else:
                oName = n
            if isinstance(optionType, tuple):
                if isinstance(optionType[0], (int, long, float)):
                    if len(optionType) == 3:
                        val, min, max = optionType
                        increment = 0.1
                    elif len(optionType) == 2:
                        min, max = optionType
                        val = min
                        increment = 0.1
                    else:
                        val, min, max, increment = optionType

                    rows.append(addNumField(page, optionName, oName, val, min, max, increment))

                if isinstance(optionType[0], (str, unicode)):
                    isChoiceButton = False

                    if optionType[0] == "string":
                        kwds = []
                        wid = None
                        val = None
                        for keyword in optionType:
                            if isinstance(keyword, (str, unicode)) and keyword != "string":
                                kwds.append(keyword)
                        for keyword in kwds:
                            splitWord = keyword.split('=')
                            if len(splitWord) > 1:
                                v = None

                                try:
                                    v = int(splitWord[1])
                                except ValueError:
                                    pass

                                key = splitWord[0]
                                if v is not None:
                                    if key == "width":
                                        wid = v
                                else:
                                    if key == "value":
                                        val = "=".join(splitWord[1:])

                        if val is None:
                            val = ""
                        if wid is None:
                            wid = 200

                        field = TextFieldWrapped(value=val, width=wid)
                        page.optionDict[optionName] = AttrRef(field, 'value')

                        row = Row((Label(oName, doNotTranslate=True), field))
                        rows.append(row)
                    else:
                        isChoiceButton = True

                    if isChoiceButton:
                        if trn is not None:
                            __ = trn._
                        else:
                            __ = _
                        choices = [__("%s" % a) for a in optionType]
                        choiceButton = ChoiceButton(choices, doNotTranslate=True)
                        page.optionDict[optionName] = AttrRef(choiceButton, 'selectedChoice')

                        rows.append(Row((Label(oName, doNotTranslate=True), choiceButton)))

            elif isinstance(optionType, bool):
                cbox = CheckBox(value=optionType)
                page.optionDict[optionName] = AttrRef(cbox, 'value')

                row = Row((Label(oName, doNotTranslate=True), cbox))
                rows.append(row)

            elif isinstance(optionType, (int, float)):
                rows.append(addNumField(self, optionName, oName, optionType))

            elif optionType == "blocktype" or isinstance(optionType, pymclevel.materials.Block):
#.........这里部分代码省略.........
开发者ID:gwpantazes,项目名称:MCEdit-Unified,代码行数:101,代码来源:filter.py

示例14: __init__

 def __init__(self, materials, blockInfo=None, **kw):
     Widget.__init__(self, **kw)
     self.materials = materials
     self.blockInfo = blockInfo
开发者ID:Aiybe,项目名称:MCEdit-Unified,代码行数:4,代码来源:thumbview.py

示例15: __init__

 def __init__(self, value=None):
     Widget.__init__(self)
     self.choiceButton = ChoiceButton(self.choices)
     self.add(self.choiceButton)
     self.shrink_wrap()
开发者ID:vongola12324,项目名称:MCEdit-Unified,代码行数:5,代码来源:nbtexplorer.py


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