def build_attributes(items): rows = [] attributes = items[0] names = [a['Name'].value for a in attributes] indexes = [] + names names.sort() for name in names: item = attributes[indexes.index(name)] rows.append( Row([Label(name.split('.')[-1], align='l')] + NBTExplorerToolPanel.build_field(item['Base']), margin=0)) mods = item.get('Modifiers', []) for mod in mods: keys = mod.keys() keys.remove('Name') rows.append( Row([Label("-> Name", align='l')] + NBTExplorerToolPanel.build_field(mod['Name']), margin=0)) keys.sort() for key in keys: rows.append(Row([Label(' %s'%key, align='l', doNotTranslate=True, tooltipText=mod[key].__class__.__name__)] \ + NBTExplorerToolPanel.build_field(mod[key]), margin=0)) return rows
def openSavePresetDialog(self): """ Opens up a dialgo to input the name of the to save Preset. """ panel = Dialog() label = Label("Preset Name:") nameField = TextFieldWrapped(width=200) def okPressed(): panel.dismiss() name = nameField.value if name in ['Load Preset', 'Remove Presets', '__temp__']: alert( "That preset name is reserved. Try pick another preset name." ) return for p in ['<', '>', ':', '\"', '/', '\\', '|', '?', '*', '.']: if p in name: alert('Invalid character in file name') return self.tool.saveBrushPreset(name) self.tool.showPanel() okButton = Button("OK", action=okPressed) cancelButton = Button("Cancel", action=panel.dismiss) namerow = Row([label, nameField]) buttonRow = Row([okButton, cancelButton]) panel.add(Column([namerow, buttonRow])) panel.shrink_wrap() panel.present()
def build_pos(items): rows = [] pos = items[0] rows.append(Row([Label("X", align='l'), FloatField(ref=AttrRef(pos[0], 'value'))])) rows.append(Row([Label("Y", align='l'), FloatField(ref=AttrRef(pos[1], 'value'))])) rows.append(Row([Label("Z", align='l'), FloatField(ref=AttrRef(pos[2], 'value'))])) return rows
def __init__(self, editor, nbtObject=None, fileName=None, savePolicy=0, dataKeyName='Data', close_text="Close", load_text="Open", **kwargs): """...""" Panel.__init__(self) self.editor = editor self.nbtObject = nbtObject self.fileName = fileName self.savePolicy = savePolicy self.displayed_item = None self.dataKeyName = dataKeyName self.copy_data = kwargs.get('copy_data', True) self.init_data() btns = [] if load_text: btns.append(Button(load_text, action=self.editor.nbtTool.loadFile)) btns += [ Button({True: "Save", False: "OK"}[fileName != None], action=kwargs.get('ok_action', self.save_NBT), tooltipText="Save your change in the NBT data."), Button("Reset", action=kwargs.get('reset_action', self.reset), tooltipText="Reset ALL your changes in the NBT data."), ] if close_text: btns.append(Button(close_text, action=kwargs.get('close_action', self.close))) btnRow = Row(btns, margin=1, spacing=4) btnRow.shrink_wrap() self.btnRow = btnRow if kwargs.get('no_header', False): self.max_height = max_height = kwargs.get('height', editor.mainViewport.height - editor.toolbar.height - editor.subwidgets[0].height) - ( self.margin * 2) - btnRow.height - 2 else: title = _("NBT Explorer") if fileName: title += " - %s" % os.path.split(fileName)[-1] header = Label(title, doNotTranslate=True) self.max_height = max_height = kwargs.get('height', editor.mainViewport.height - editor.toolbar.height - editor.subwidgets[0].height) - header.height - ( self.margin * 2) - btnRow.height - 2 self.setCompounds() self.tree = NBTTree(height=max_height - btnRow.height - 2, inner_width=250, data=self.data, compound_types=self.compounds, copyBuffer=editor.nbtCopyBuffer, draw_zebra=False, _parent=self, styles=bullet_styles) self.tree.update_side_panel = self.update_side_panel self.side_panel_width = 350 row = [self.tree, Column([Label("", width=self.side_panel_width), ], margin=0)] self.displayRow = Row(row, height=max_height, margin=0, spacing=0) if kwargs.get('no_header', False): self.add(Column([self.displayRow, btnRow], margin=0)) else: self.add(Column([header, self.displayRow, btnRow], margin=0)) self.shrink_wrap() self.side_panel = None # &# Prototype for Blocks/item names mclangres.buildResources(lang=getLang())
def __init__(self, tool): Panel.__init__(self) self.tool = tool useStyleBox = CheckBoxLabel(title="Use Bullet Styles", ref=config.nbtTreeSettings.useBulletStyles) self.useStyleBox = useStyleBox useTextBox = CheckBoxLabel(title="Use Bullet Text", ref=config.nbtTreeSettings.useBulletText) self.useTextBox = useTextBox useImagesBox = CheckBoxLabel(title="Use Bullet Images", ref=config.nbtTreeSettings.useBulletImages) self.useImagesBox = useImagesBox bulletFilePath = Row((Button("Bullet Images File", action=self.open_bullet_file), TextFieldWrapped(ref=config.nbtTreeSettings.bulletFileName, width=300)), margin=0) def mouse_down(e): if self.bulletFilePath.subwidgets[1].enabled: TextFieldWrapped.mouse_down(self.bulletFilePath.subwidgets[1], e) bulletFilePath.subwidgets[1].mouse_down = mouse_down self.bulletFilePath = bulletFilePath def mouse_down(e): CheckBox.mouse_down(useImagesBox.subwidgets[1], e) for sub in bulletFilePath.subwidgets: sub.enabled = config.nbtTreeSettings.useBulletImages.get() if type(sub) == TextFieldWrapped: if config.nbtTreeSettings.useBulletImages.get(): sub.fg_color = fg_color else: sub.fg_color = disabled_color useImagesBox.subwidgets[0].mouse_down = useImagesBox.subwidgets[1].mouse_down = mouse_down def mouse_down(e): CheckBox.mouse_down(useStyleBox.subwidgets[1], e) useImagesBox.mouse_down(e) self.useStyleBox_click(e) useStyleBox.subwidgets[0].mouse_down = useStyleBox.subwidgets[1].mouse_down = mouse_down showAllTags = CheckBoxLabel(title="Show all the tags in the tree", ref=config.nbtTreeSettings.showAllTags) col = Column(( Label("NBT Tree Settings"), Row((useStyleBox, useTextBox, useImagesBox)), bulletFilePath, showAllTags, # Button("Load NBT file...", action=tool.loadFile), Button("OK", action=self.dismiss), )) self.add(col) self.shrink_wrap() self.useStyleBox_click(None)
def update_side_panel(self, item): if item == self.displayed_item: return self.displayed_item = item if self.side_panel: self.side_panel.set_parent(None) items = [a for a in item[1]] rows = [] if config.nbtTreeSettings.showAllTags.get(): meth = None else: meth = getattr(self, 'build_%s' % item[3].lower(), None) col = True if meth and len(items) == 1: rows = meth(items) else: height = 0 for itm in items: t = itm.__class__.__name__ rows.append(Row([Label("Data Type:"), Label(t)], margin=1)) fields = self.build_field(itm) for field in fields: if type(field) == TextFieldWrapped: field.set_size_for_text(self.side_panel_width) row = Row([ field, ], margin=1) rows.append(row) height += row.height if height > self.displayRow.height: col = False if rows: if col: col = Column(rows, align='l', spacing=0, height=self.displayRow.height) else: col = ScrollPanel(rows=rows, align='l', spacing=0, height=self.displayRow.height, draw_zebra=False, inner_width=self.side_panel_width - scroll_button_size) col.set_parent(self.displayRow) col.top = self.displayRow.top col.left = self.displayRow.subwidgets[0].right col.bottom = self.displayRow.subwidgets[0].bottom col.shrink_wrap() self.side_panel = col
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=str(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
def build_rotation(items): rows = [] rotation = items[0] rows.append( Row([ Label("Y", align='l'), FloatField(ref=AttrRef(rotation[0], 'value')) ])) rows.append( Row([ Label("X", align='l'), FloatField(ref=AttrRef(rotation[1], 'value')) ])) return rows
def __init__(self, tool): Panel.__init__(self, name='Panel.BrushPanel') self.tool = tool """ presets, modeRow and styleRow are always created, no matter what brush is selected. styleRow can be disabled by putting disableStyleButton = True in the brush file. """ presets = self.createPresetRow() self.brushModeButtonLabel = Label("Mode:") self.brushModeButton = ChoiceButton( sorted([mode for mode in tool.brushModes]), width=150, choose=self.brushModeChanged, doNotTranslate=True, ) modeRow = Row([self.brushModeButtonLabel, self.brushModeButton]) self.brushStyleButtonLabel = Label("Style:") self.brushStyleButton = ValueButton(ref=ItemRef( self.tool.options, "Style"), action=self.tool.swapBrushStyles, width=150) styleRow = Row([self.brushStyleButtonLabel, self.brushStyleButton]) self.brushModeButton.selectedChoice = self.tool.selectedBrushMode optionsColumn = [] optionsColumn.extend([presets, modeRow]) if not getattr(tool.brushMode, 'disableStyleButton', False): optionsColumn.append(styleRow) """ We're going over all options in the selected brush module, and making a field for all of them. """ for r in tool.brushMode.inputs: row = [] for key, value in r.items(): field = self.createField(key, value) row.append(field) row = Row(row) optionsColumn.append(row) if getattr(tool.brushMode, 'addPasteButton', False): importButton = Button("Import", action=tool.importPaste) importRow = Row([importButton]) optionsColumn.append(importRow) optionsColumn = Column(optionsColumn, spacing=0) self.add(optionsColumn) self.shrink_wrap()
def removePreset(self): """ Brings up a panel to remove presets. """ panel = Dialog() p = self.getBrushFileList() if not p: alert('No presets saved') return def okPressed(): panel.dismiss() name = p[presetTable.selectedIndex] + ".preset" os.remove(os.path.join(directories.brushesDir, name)) self.tool.showPanel() def selectTableRow(i, evt): presetTable.selectedIndex = i if evt.num_clicks == 2: okPressed() presetTable = TableView(columns=(TableColumn("", 200),)) presetTable.num_rows = lambda: len(p) presetTable.row_data = lambda i: (p[i],) presetTable.row_is_selected = lambda x: x == presetTable.selectedIndex presetTable.click_row = selectTableRow presetTable.selectedIndex = 0 choiceCol = Column((ValueDisplay(width=200, get_value=lambda: "Select preset to delete"), presetTable)) okButton = Button("OK", action=okPressed) cancelButton = Button("Cancel", action=panel.dismiss) row = Row([okButton, cancelButton]) panel.add(Column((choiceCol, row))) panel.shrink_wrap() panel.present()
def __init__(self, tool): Panel.__init__(self) self.tool = tool self.autoPlaceCheckBox = CheckBox( ref=AttrRef(tool, "placeImmediately")) self.autoPlaceLabel = Label("Place Immediately") self.autoPlaceLabel.mouse_down = self.autoPlaceCheckBox.mouse_down tooltipText = "When the clone tool is chosen, place the clone at the selection right away." self.autoPlaceLabel.tooltipText = self.autoPlaceCheckBox.tooltipText = tooltipText spaceLabel = Label("") cloneNudgeLabel = Label("Clone Fast Nudge Settings") cloneNudgeCheckBox = CheckBoxLabel( "Move by the width of selection ", ref=config.fastNudgeSettings.cloneWidth, tooltipText="Moves clone by his width") cloneNudgeNumber = IntInputRow( "Width of clone movement: ", ref=config.fastNudgeSettings.cloneWidthNumber, width=100, min=2, max=50) row = Row((self.autoPlaceCheckBox, self.autoPlaceLabel)) col = Column((Label("Clone Options"), row, spaceLabel, cloneNudgeLabel, cloneNudgeCheckBox, cloneNudgeNumber, Button("OK", action=self.dismiss))) self.add(col) self.shrink_wrap()
def __init__(self, tool): ToolOptions.__init__(self, name='Panel.BrushToolOptions') alphaField = FloatField(ref=ItemRef(tool.settings, 'brushAlpha'), min=0.0, max=1.0, width=60) alphaField.increment = 0.1 alphaRow = Row((Label("Alpha: "), alphaField)) autoChooseCheckBox = CheckBoxLabel( "Choose Block Immediately", ref=ItemRef(tool.settings, "chooseBlockImmediately"), tooltipText= "When the brush tool is chosen, prompt for a block type.") updateOffsetCheckBox = CheckBoxLabel( "Reset Distance When Brush Size Changes", ref=ItemRef(tool.settings, "updateBrushOffset"), tooltipText= "Whenever the brush size changes, reset the distance to the brush blocks." ) col = Column((Label("Brush Options"), alphaRow, autoChooseCheckBox, updateOffsetCheckBox, Button("OK", action=self.dismiss))) self.add(col) self.shrink_wrap() return
def createChunks(self): panel = GeneratorPanel() col = [panel] label = Label( "Create chunks using the settings above? This cannot be undone.") col.append(Row([Label("")])) col.append(label) col = Column(col) if Dialog(client=col, responses=["OK", "Cancel"]).present() == "Cancel": return chunks = self.selectedChunks() createChunks = panel.generate(self.editor.level, chunks) try: with setWindowCaption("CREATING - "): showProgress("Creating {0} chunks...".format(len(chunks)), createChunks, cancel=True) except Exception as e: traceback.print_exc() alert(_("Failed to start the chunk generator. {0!r}").format(e)) finally: self.editor.renderer.invalidateChunkMarkers() self.editor.renderer.loadNearbyChunks()
def __init__(self, tool): Panel.__init__(self) self.macro_steps = [] self.current_step = 0 self._filter_json = None self.keys_panel = None self.filterOptionsPanel = None self.filterSelect = ChoiceButton([], choose=self.filterChanged, doNotTranslate=True) self.binding_button = Button( "", action=self.bind_key, tooltipText="Click to bind this filter to a key") self.filterLabel = Label("Filter:", fg_color=(177, 177, 255, 255)) self.filterLabel.mouse_down = lambda x: mcplatform.platform_open( directories.getFiltersDir()) self.filterLabel.tooltipText = "Click to open filters folder" self.macro_button = Button("Record Macro", action=self.start_record_macro) self.filterSelectRow = Row((self.filterLabel, self.filterSelect, self.macro_button, self.binding_button)) self.confirmButton = Button("Filter", action=self.confirm) self._recording = False self._save_macro = False self.tool = tool self.selectedName = self.filter_json.get("Last Filter Opened", "")
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()
def addNumField(page, optionName, oName, val, min_value=None, max_value=None, increment=0.1): if isinstance(val, float): field_type = FloatField if isinstance(increment, int): increment = float(increment) else: field_type = IntField if increment == 0.1: increment = 1 if isinstance(increment, float): increment = int(round(increment)) if min_value == max_value: min_value = None max_value = None field = field_type(value=val, width=200, min=min_value, max=max_value) field._increment = increment page.optionDict[optionName] = AttrRef(field, 'value') row = Row([Label(oName, doNotTranslate=True), field]) return row
def __init__(self, materials, blockInfo=None, ref=None, recentBlocks=None, *a, **kw): self.allowWildcards = False Panel.__init__(self, *a, **kw) self.bg_color = (1, 1, 1, 0.25) self._ref = ref if blockInfo is None and ref is not None: blockInfo = ref.get() blockInfo = blockInfo or materials.Air if recentBlocks is not None: self.recentBlocks = recentBlocks else: self.recentBlocks = [] self.blockView = thumbview.BlockThumbView(materials, blockInfo, size=(48, 48)) self.blockLabel = ValueDisplay(ref=AttrRef(self, 'labelText'), width=180, align="l") row = Row((self.blockView, self.blockLabel), align="b") # col = Column( (self.blockButton, self.blockNameLabel) ) self.add(row) self.shrink_wrap() # self.blockLabel.bottom = self.blockButton.bottom # self.blockLabel.centerx = self.blockButton.centerx # self.add(self.blockLabel) self.materials = materials self.blockInfo = blockInfo # self._ref = ref self.updateRecentBlockView()
def __init__(self, inventory, data): Panel.__init__(self) self.inventory = inventory slot, id, count, damage = data self.slot = slot self.id = TextFieldWrapped(text=id, doNotTranslate=True, width=300) 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 stop_record_macro(self): macro_dialog = Dialog() macroNameLabel = Label("Macro Name: ") macroNameField = TextFieldWrapped(width=200) def save_macro(): macro_name = "{Macro} " + macroNameField.get_text() self.filter_json["Macros"][macro_name] = {} self.filter_json["Macros"][macro_name]["Number of steps"] = len( self.macro_steps) self.filterSelect.choices.append(macro_name) for entry in self.macro_steps: for inp in entry["Inputs"].keys(): if not isinstance(entry["Inputs"][inp], pymclevel.materials.Block): if not entry["Inputs"][inp] == "blocktype": continue _inp = entry["Inputs"][inp] entry["Inputs"][inp] = "block-{0}:{1}".format( _inp.ID, _inp.blockData) self.filter_json["Macros"][macro_name][entry["Step"]] = { "Name": entry["Name"], "Inputs": entry["Inputs"] } stop_dialog() self.filterSelect.selectedChoice = macro_name self.filterChanged() def stop_dialog(): self.macro_button.text = "Record Macro" self.macro_button.tooltipText = None self.macro_button.action = self.start_record_macro macro_dialog.dismiss() self.macro_steps = [] self.current_step = 0 self._recording = False input_row = Row((macroNameLabel, macroNameField)) saveButton = Button("Save", action=save_macro) closeButton = Button("Cancel", action=stop_dialog) button_row = Row((saveButton, closeButton)) macro_dialog.add(Column((input_row, button_row))) macro_dialog.shrink_wrap() macro_dialog.present()
class FilterToolPanel(Panel): def __init__(self, tool): Panel.__init__(self) self.savedOptions = {} self.tool = tool self.selectedFilterName = None if len(self.tool.filterModules): self.reload() def reload(self): for i in list(self.subwidgets): self.remove(i) tool = self.tool if len(tool.filterModules) is 0: self.add(Label("No filter modules found!")) self.shrink_wrap() return if self.selectedFilterName is None or self.selectedFilterName not in tool.filterNames: self.selectedFilterName = tool.filterNames[0] self.filterOptionsPanel = None while self.filterOptionsPanel is None: module = self.tool.filterModules[self.selectedFilterName] try: self.filterOptionsPanel = FilterModuleOptions(self.tool, module) except Exception, e: alert(_("Error creating filter inputs for {0}: {1}").format(module, e)) traceback.print_exc() self.tool.filterModules.pop(self.selectedFilterName) self.selectedFilterName = tool.filterNames[0] if len(tool.filterNames) == 0: raise ValueError("No filters loaded!") self.filterSelect = ChoiceButton(tool.filterNames, choose=self.filterChanged) self.filterSelect.selectedChoice = self.selectedFilterName self.confirmButton = Button("Filter", action=self.tool.confirm) filterLabel = Label("Filter:", fg_color=(177, 177, 255, 255)) filterLabel.mouse_down = lambda x: mcplatform.platform_open(mcplatform.filtersDir) filterLabel.tooltipText = "Click to open filters folder" filterSelectRow = Row((filterLabel, self.filterSelect)) self.add(Column((filterSelectRow, self.filterOptionsPanel, self.confirmButton))) self.shrink_wrap() if self.parent: self.centery = self.parent.centery if self.selectedFilterName in self.savedOptions: self.filterOptionsPanel.options = self.savedOptions[self.selectedFilterName]
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()
def createPresetRow(self): """ Creates the brush preset widget, called by BrushPanel when creating the panel. """ self.presets = ["Load Preset"] self.presets.extend(self.getBrushFileList()) self.presets.append('Remove Presets') self.presetListButton = ChoiceButton(self.presets, width=100, choose=self.presetSelected) self.presetListButton.selectedChoice = "Load Preset" self.saveButton = Button("Save as Preset", action=self.openSavePresetDialog) presetListButtonRow = Row([self.presetListButton]) saveButtonRow = Row([self.saveButton]) row = Row([presetListButtonRow, saveButtonRow]) widget = GLBackground() widget.bg_color = (0.8, 0.8, 0.8, 0.8) widget.add(row) widget.shrink_wrap() widget.anchor = "whtr" return widget
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((Row( (Label('X'), self.xField)), Row( (Label('Y'), self.yField)), Row((Label('Z'), self.zField)))) nudgeOffsetRow = Row((offsetCol, self.nudgeButton)) self.add(nudgeOffsetRow) self.shrink_wrap()
def addNumField(page, optionName, val, min=None, max=None): if isinstance(val, float): ftype = FloatField else: ftype = IntField if min == max: min = None max = None field = ftype(value=val, width=100, min=min, max=max) page.optionDict[optionName] = AttrRef(field, 'value') row = Row([Label(optionName), field]) return row
def __init__(self, tool): Panel.__init__(self) self.tool = tool self.autoPlaceCheckBox = CheckBox(ref=AttrRef(tool, "placeImmediately")) self.autoPlaceLabel = Label("Place Immediately") self.autoPlaceLabel.mouse_down = self.autoPlaceCheckBox.mouse_down tooltipText = "When the clone tool is chosen, place the clone at the selection right away." self.autoPlaceLabel.tooltipText = self.autoPlaceCheckBox.tooltipText = tooltipText row = Row((self.autoPlaceCheckBox, self.autoPlaceLabel)) col = Column((Label("Clone Options"), row, Button("OK", action=self.dismiss))) self.add(col) self.shrink_wrap()
def __init__(self, tool): Panel.__init__(self) self.tool = tool self.spawnProtectionCheckBox = CheckBox(ref=AttrRef(tool, "spawnProtection")) self.spawnProtectionLabel = Label("Spawn Position Safety") self.spawnProtectionLabel.mouse_down = self.spawnProtectionCheckBox.mouse_down tooltipText = "Minecraft will randomly move your spawn point if you try to respawn in a column where there are no blocks at Y=63 and Y=64. Only uncheck this box if Minecraft is changed." self.spawnProtectionLabel.tooltipText = self.spawnProtectionCheckBox.tooltipText = tooltipText row = Row((self.spawnProtectionCheckBox, self.spawnProtectionLabel)) col = Column((Label("Spawn Point Options"), row, Button("OK", action=self.dismiss))) self.add(col) self.shrink_wrap()
def __init__(self, editor): Panel.__init__(self, name='Panel.ControlPanel') self.editor = editor self.bg_color = (0, 0, 0, 0.8) header = self.getHeader() keysColumn = [Label("")] buttonsColumn = [header] hotkeys = ([ (config.keys.newWorld.get(), "Create New World", editor.mcedit.createNewWorld), (config.keys.quickLoad.get(), "Quick Load", editor.askLoadWorld), (config.keys.open.get(), "Open...", editor.askOpenFile), (config.keys.save.get(), "Save", editor.saveFile), (config.keys.saveAs.get(), "Save As", editor.saveAs), (config.keys.reloadWorld.get(), "Reload", editor.reload), (config.keys.closeWorld.get(), "Close", editor.closeEditor), (config.keys.uploadWorld.get(), "Upload to FTP Server", editor.uploadChanges), (config.keys.gotoPanel.get(), "Waypoints/Goto", editor.showWaypointsDialog), (config.keys.worldInfo.get(), "World Info", editor.showWorldInfo), (config.keys.undo.get(), "Undo", editor.undo), (config.keys.redo.get(), "Redo", editor.redo), (config.keys.selectAll.get(), "Select All", editor.selectAll), (config.keys.deselect.get(), "Deselect", editor.deselect), (config.keys.viewDistance.get(), AttrRef(editor, 'viewDistanceLabelText'), editor.swapViewDistance), (config.keys.quit.get(), "Quit", editor.quit), ]) buttons = HotkeyColumn(hotkeys, keysColumn, buttonsColumn, item_spacing=2) sideColumn1 = editor.mcedit.makeSideColumn1() sideColumn2 = editor.mcedit.makeSideColumn2() spaceLabel = Label("") sideColumn = Column((sideColumn1, spaceLabel, sideColumn2)) self.add(Row([buttons, sideColumn])) self.shrink_wrap()
def createRecentBlockView(self): def makeBlockView(bi): bv = BlockView(self.materials, bi) bv.size = (16, 16) def action(evt): self.blockInfo = bi bv.mouse_up = action return bv row = [makeBlockView(bi) for bi in self.recentBlocks] row = Row(row) widget = GLBackground() widget.bg_color = (0.8, 0.8, 0.8, 0.8) widget.add(row) widget.shrink_wrap() widget.anchor = "whtr" return widget
def __init__(self, editor): Panel.__init__(self) self.editor = editor self.bg_color = (0, 0, 0, 0.8) header = self.getHeader() keysColumn = [Label("")] buttonsColumn = [header] hotkeys = ([ (config.keys.newWorld.get(), "Create New World", editor.mcedit.createNewWorld), (config.keys.quickLoad.get(), "Quick Load", editor.askLoadWorld), (config.keys.open.get(), "Open...", editor.askOpenFile), (config.keys.save.get(), "Save", editor.saveFile), (config.keys.reloadWorld.get(), "Reload", editor.reload), (config.keys.closeWorld.get(), "Close", editor.closeEditor), (config.keys.gotoPanel.get(), "Goto", editor.showGotoPanel), (config.keys.worldInfo.get(), "World Info", editor.showWorldInfo), (config.keys.undo.get(), "Undo", editor.undo), (config.keys.redo.get(), "Redo", editor.redo), (config.keys.selectAll.get(), "Select All", editor.selectAll), (config.keys.deselect.get(), "Deselect", editor.deselect), (config.keys.viewDistance.get(), AttrRef(editor, 'viewDistanceLabelText'), editor.swapViewDistance), (config.keys.quit.get(), "Quit", editor.quit), ]) buttons = mceutils.HotkeyColumn(hotkeys, keysColumn, buttonsColumn) sideColumn = editor.mcedit.makeSideColumn() self.add(Row([buttons, sideColumn])) self.shrink_wrap()
def __init__(self, tool): Panel.__init__(self, name='Panel.FilterToolPanel') self.macro_steps = [] self.current_step = 0 self._filter_json = None self.keys_panel = None self.filterOptionsPanel = None self.filterSelect = ChoiceButton([], choose=self.filterChanged, doNotTranslate=True) self.binding_button = Button("", action=self.bind_key, tooltipText="Click to bind this filter to a key") self.filterLabel = Label("Filter:", fg_color=(177, 177, 255, 255)) self.filterLabel.mouse_down = lambda x: mcplatform.platform_open(directories.getFiltersDir()) self.filterLabel.tooltipText = "Click to open filters folder" self.macro_button = Button("Record Macro", action=self.start_record_macro) self.filterSelectRow = Row((self.filterLabel, self.filterSelect, self.macro_button, self.binding_button)) self.confirmButton = Button("Filter", action=self.confirm) self._recording = False self._save_macro = False self.tool = tool self.selectedName = self.filter_json.get("Last Filter Opened", "") utils = FilterUtils( editor=tool.editor, materials=self.tool.editor.level.materials, custom_widget=tool.editor.addExternalWidget, resize_selection_box=tool.editor._resize_selection_box ) utils_module = imp.new_module("filter_utils") utils_module = utils sys.modules["filter_utils"] = utils_module