Ejemplo n.º 1
0
def _fontSample(fontName, sampleFn):
    sample = sampleFn(fontName)
    name = Label(fontName)
    return _hoverStyle(
        Bin(
            Column([
                sample,
                _nameStyle(name).padX(10.0, 0.0),
            ]).pad(5.0, 5.0)))
Ejemplo n.º 2
0
	def editUI(self, setPaddingFn):
		box = _boxStyle(Bin(Label('Padded element'))).alignHExpand().alignVExpand()

		left = self.left.editUI(lambda live: RealSpinEntry(live, 0.0, 1048576.0, 1.0, 10.0))
		right = self.right.editUI(lambda live: RealSpinEntry(live, 0.0, 1048576.0, 1.0, 10.0))
		top = self.top.editUI(lambda live: RealSpinEntry(live, 0.0, 1048576.0, 1.0, 10.0))
		bottom = self.bottom.editUI(lambda live: RealSpinEntry(live, 0.0, 1048576.0, 1.0, 10.0))

		return _tableStyle(Table([[None, top, None], [left, box, right], [None, bottom, None]]))
def execResult(resultView):
    return ApplyStyleSheetFromAttribute(
        ExecutionStyle.resultBorderStyle,
        Border(Bin(Paragraph([resultView]))).alignHExpand())
Ejemplo n.º 4
0
    def Package(self, fragment, inheritedState, package):
        def _addPackage(menuItem):
            package.append(ProjectPackage('NewPackage'))

        class _RenameListener(TextEntry.TextEntryListener):
            def onAccept(self, textEntry, text):
                package.name = text

            def onCancel(self, textEntry, originalText):
                nameLive.setLiteralValue(nameBox)

        def _onRename(menuItem):
            textEntry = TextEntry(package.name,
                                  _RenameListener()).regexValidated(
                                      _nameRegex,
                                      'Please enter a valid identifier')
            textEntry.grabCaretOnRealise()
            nameLive.setLiteralValue(textEntry)

        def _onDelete(menuItem):
            if package.parent is not None:
                package.parent.remove(package)

        def _addPage(page):
            package.append(page)

        def _packageContextMenuFactory(element, menu):
            menu.add(MenuItem.menuItemWithLabel('New package', _addPackage))
            newPageMenu = PageData.newPageMenu(_addPage)
            importPageMenu = PageData.importPageMenu(
                element.getRootElement().getComponent(), _addPage)
            menu.add(
                MenuItem.menuItemWithLabel(
                    'New page', newPageMenu,
                    MenuItem.SubmenuPopupDirection.RIGHT))
            menu.add(
                MenuItem.menuItemWithLabel(
                    'Import page', importPageMenu,
                    MenuItem.SubmenuPopupDirection.RIGHT))
            menu.add(HSeparator())
            menu.add(MenuItem.menuItemWithLabel('Rename', _onRename))
            menu.add(HSeparator())
            menu.add(MenuItem.menuItemWithLabel('Delete', _onDelete))
            return True

        nameElement = _packageNameStyle.applyTo(StaticText(package.name))
        nameBox = _itemHoverHighlightStyle.applyTo(
            Row([
                _packageIcon.padX(5.0).alignHPack().alignVCentre(),
                nameElement.alignVCentre()
            ]))

        # Set drop destination and place in box that is h-packed, otherwise attempting to drop items as children could require the user to
        # drop somewhere off to the right of the package, since the h-expand applied further up the presentation tree will expand it beyond
        # its visible bounds
        nameBox = Bin(nameBox).alignHPack()

        nameBox = nameBox.withContextMenuInteractor(_packageContextMenuFactory)
        nameBox = _ProjectTreeController.instance.nestedListItem(
            package, package, nameBox)
        nameBox = AttachTooltip(nameBox, 'Right click to access context menu.',
                                False)

        nameLive = LiveValue(nameBox)
        itemsBox = Column(package[:])
        itemsBox = _ProjectTreeController.instance.editableList(
            package, itemsBox)

        return Column([
            nameLive,
            itemsBox.padX(_packageContentsIndentation, 0.0).alignHExpand()
        ])
Ejemplo n.º 5
0
 def _presentEditableBranchContents(self, child, fragment, inheritedState):
     return Bin(child)