예제 #1
0
파일: base.py 프로젝트: sveneberth/flare
    def __init__(self, bone, widgetFactory: callable, **kwargs):
        super().__init__("""
			<div [name]="widgets" class="flr-bone-widgets"></div>
			<div [name]="actions" class="flr-bone-actions input-group"></div>
		""")

        languages = bone.skelStructure[bone.boneName]["languages"]
        assert languages, "This parameter must not be empty!"

        self.bone = bone
        self.languages = languages
        self._languageWidgets = {}

        # Create widget for every language
        for lang in self.languages:
            assert not any([ch in lang for ch in "<>\"'/"
                            ]), "This is not a valid language identifier!"

            langBtn = Button(lang, callback=self.onLangBtnClick)
            langBtn.addClass("btn--lang", "btn--lang-" + lang)

            if lang == conf["defaultLanguage"]:
                langBtn.addClass("is-active")

            self.actions.appendChild(langBtn)

            kwargs["language"] = lang
            langWidget = widgetFactory(self.bone, **kwargs)

            if lang != conf["defaultLanguage"]:
                langWidget.hide()

            self.widgets.appendChild(langWidget)

            self._languageWidgets[lang] = (langBtn, langWidget)
예제 #2
0
	def __init__(self, preview, *args, **kwargs):
		super(FileImagePopup, self).__init__(title=preview.currentFile.get("name", translate("Unnamed Image")), className="image-viewer", *args, **kwargs)
		self.sinkEvent("onClick")
		self.preview = preview

		img = html5.Img()
		img["src"] = getImagePreview(preview.currentFile, size=None)
		self.popupBody.appendChild(img)

		btn = Button(translate("Download"), self.onDownloadBtnClick)
		btn.addClass("btn--download")
		self.popupFoot.appendChild(btn)

		btn = Button(translate("Close"), self.onClick)
		btn.addClass("btn--close")
		self.popupFoot.appendChild(btn)