示例#1
0
class ProductQML(Component):

    qml = qml_path('components/Product.qml')

    def __init__(self,
                 parent,
                 image=None,
                 img_width=None,
                 img_height=None,
                 market_hash=None,
                 show_status=False):
        self.obj = ImageObject(None,
                               image,
                               img_width,
                               img_height,
                               market_hash=market_hash,
                               show_status=show_status)
        super().__init__(parent)

    @component.create
    def create(self):
        pass

    @component.ui
    def ui(self):
        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        widget = QQuickWidget(self)
        widget.setContentsMargins(0, 0, 0, 0)
        widget.rootContext().setContextProperty('self', self.obj)
        widget.setSource(QUrl(self.qml))
        layout.addWidget(widget)
        return layout
示例#2
0
class FileUploadQml(Component):
    qml = qml_path('components/FileUpload.qml')

    def __init__(self,
                 parent=None,
                 width=None,
                 height=None,
                 text="Drop file here or",
                 browse_text="browse",
                 background="#fafafa",
                 gap=3):
        self.obj = FileUploadObject(None, width, height, background, text,
                                    browse_text, gap)
        return super().__init__(parent)

    @property
    def file(self):
        return self.obj.file

    @component.ui
    def ui(self):
        self.setContentsMargins(0, 0, 0, 0)
        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        widget = QQuickWidget(self)
        widget.setContentsMargins(0, 0, 0, 0)
        widget.rootContext().setContextProperty('self', self.obj)
        widget.setSource(QUrl(self.qml))
        layout.addWidget(widget)
        return layout
示例#3
0
class Home(Page):

    qml = qml_path('home.qml')

    def __init__(self, parent):
        self.obj = HomeObject()
        super().__init__(parent)

    @page.method
    def renderProducts(self, products):
        self.products.value = ProductAdapter(products).data

    @page.data
    def data(self):
        return {'products': []}

    @page.create
    def create(self):
        # balance
        amount = account.to_ether(account.get_balance(app.addr))
        self.obj.icon = abs_path('icons/[email protected]', True)
        self.obj.username = '******'.format(app.username)
        self.obj.amount = '{}'.format(amount)
        wallet.market_client.products().addCallbacks(self.renderProducts)

    @page.ui
    def ui(self):
        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        widget = QQuickWidget(self)
        widget.setContentsMargins(0, 0, 0, 0)
        widget.rootContext().setContextProperty('self', self.obj)
        widget.setSource(QtCore.QUrl(self.qml))
        layout.addWidget(widget)
        pdsWidget = ProductList(self.products)

        width = 750
        pdsWidget.setMinimumWidth(width)
        pdsWidget.setMaximumWidth(width)

        product_layout = QHBoxLayout(self)
        product_layout.setContentsMargins(0, 0, 0, 0)
        product_layout.addSpacing(30)
        product_layout.addWidget(pdsWidget)
        product_layout.addStretch(1)

        layout.addLayout(product_layout)
        layout.addStretch(1)
        return layout
示例#4
0
class Header(Component):
    
    qml = qml_path('components/Header.qml')

    def __init__(self, parent):
        self.obj = HeaderObject()
        super().__init__(parent)

    @component.create
    def create(self):
        pass

    @component.ui
    def ui(self):
        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        widget = QQuickWidget(self)
        widget.setContentsMargins(0, 0, 0, 0)
        widget.rootContext().setContextProperty('self', self.obj)
        widget.setSource(QtCore.QUrl(self.qml))
        layout.addWidget(widget)
        return layout
示例#5
0
class PreviewWidget(Component):

    qml = qml_path('components/Preview.qml')

    def __init__(self, parent=None):
        self.obj = PreviewObject(parent)
        super().__init__(parent)

    @component.create
    def create(self):
        pass

    @component.ui
    def ui(self):
        layout = QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        widget = QQuickWidget(self)
        widget.setContentsMargins(0, 0, 0, 0)
        widget.rootContext().setContextProperty('self', self.obj)
        widget.setSource(QUrl(self.qml))
        layout.addWidget(widget)
        self._qml = widget
        return layout