コード例 #1
0
ファイル: purchase.py プロジェクト: jkulesza/pdash
    def ui(self, _):
        layout = QVBoxLayout()
        layout.setAlignment(Qt.AlignTop)

        layout.addWidget(self.gen_row('Price: ', Label(self.price)))
        layout.addWidget(self.gen_row('Gas: ', Label(self.gas)))
        layout.addWidget(
            self.gen_row('Account Ballance: ', Label(self.account)))
        pwd = Input.Builder(width=280, height=25).model(self.password).mode(
            Input.Password).build()
        layout.addWidget(self.gen_row('Payment Password: '******'Proxy: ', ComboBox(self.proxy), 303))

        # Bottom
        btm = QHBoxLayout()
        btm.setAlignment(Qt.AlignRight)
        btm.setContentsMargins(0, 0, 0, 0)
        btm.setSpacing(40)
        btm.addStretch(1)
        cancel = QPushButton('Cancel')
        cancel.setObjectName('pinfo_cancel_btn')
        cancel.clicked.connect(self.handle_cancel)
        btm.addWidget(cancel)
        self.ok = QPushButton('Pay')
        self.ok.setObjectName('pinfo_publish_btn')
        self.ok.clicked.connect(self.handle_confirm)
        btm.addWidget(self.ok)
        layout.addSpacing(30)
        layout.addLayout(btm)
        return layout
コード例 #2
0
 def gen_row(self, name, widget, width=None):
     layout = QHBoxLayout()
     layout.setAlignment(Qt.AlignLeft)
     nameWid = QLabel(name)
     nameWid.setMinimumWidth(160)
     nameWid.setObjectName("name")
     layout.addWidget(nameWid)
     layout.addWidget(widget)
     if width:
         widget.setMinimumWidth(width)
     if isinstance(widget, Label):
         unit = Label('CPC')
         unit.setObjectName('unit')
         widget.setObjectName('value')
         layout.addWidget(unit)
     tmp = QWidget()
     tmp.setLayout(layout)
     tmp.setObjectName('item')
     return tmp
コード例 #3
0
ファイル: detail.py プロジェクト: Alex-Cheng/pdash
    def render_widget(self):
        height = 200
        layout = QVBoxLayout(self)
        layout.setObjectName('body')
        layout.setAlignment(Qt.AlignTop)
        header = QHBoxLayout()

        # Image
        imageWid = Picture(self.image.value, 240, 160)
        Binder.click(imageWid,
                     lambda _: app.event.emit(app.events.DETAIL_UPDATE))
        header.addWidget(imageWid)

        right = QVBoxLayout()
        right.setAlignment(Qt.AlignTop)
        right.setSpacing(15)
        # Title
        title = Label(self.name)
        title.setObjectName('name')
        right.addWidget(title)

        # category
        catbox = QHBoxLayout()
        icon = self.icon.value
        if icon:
            iconL = QLabel()
            iconL.setMaximumWidth(20)
            iconL.setMaximumHeight(20)
            iconL.setObjectName('icon')
            iconL.setPixmap(QPixmap(icon))
            catbox.addWidget(iconL)
        category = Label(self.category)
        category.setObjectName('category')
        category.setAlignment(Qt.AlignCenter)
        category.setMaximumWidth(80)
        catbox.addWidget(category)
        catbox.addStretch(1)

        right.addLayout(catbox)

        # Timestamp and Remain Days
        tbox = QHBoxLayout()
        timestamp = QLabel(self.created.value)
        timestamp.setObjectName('timestamp')
        tbox.addWidget(timestamp)
        sales = QLabel(str(self.sales.value) + ' sales')
        sales.setObjectName('sales')
        tbox.addWidget(sales)

        tbox.addStretch(1)
        right.addLayout(tbox)

        # CPC and Sales
        hbox = QHBoxLayout()
        hbox.setObjectName('hbox1')

        cpc = QLabel(str(self.cpc.value))
        cpc.setObjectName('cpc')
        cpc_unit = QLabel('CPC')
        cpc_unit.setObjectName('cpc_unit')
        hbox.addWidget(cpc)
        hbox.addWidget(cpc_unit)

        # Buy button
        def openPurchaseDialog(_):
            self.buying(True)
            if not self.paying:
                market_hash = self.market_hash
                owner_address = self.owner_address
                purchaseDlg = PurchaseDialog(self,
                                             price=self.cpc,
                                             gas=self.gas,
                                             account=self.account,
                                             storagePath=self.storagePath,
                                             password=self.password,
                                             market_hash=market_hash,
                                             name=self.name.value,
                                             owner_address=owner_address)
                purchaseDlg.show()
        self.buy = Button.Builder(width=100, height=30).text('Buy')\
                                   .style('primary')\
                                   .click(openPurchaseDialog)\
                                   .build()
        hbox.addWidget(self.buy)
        if self.owner_address == wallet.market_client.public_key:
            self.buy.setEnabled(False)

        # Buy Loading
        self.buy_loading = Loading()
        hbox.addWidget(self.buy_loading)
        self.buy_loading.hide()

        hbox.addStretch(1)

        right.addLayout(hbox)
        header.addLayout(right)
        layout.addLayout(header)

        # Description
        desc = DetailHeader('Description')
        layout.addWidget(desc)
        desc = Label(self.description)
        desc.setWordWrap(True)
        layout.addWidget(desc)

        height += 300
        layout.addStretch(1)

        widget_ = QWidget()
        widget_.setObjectName('parent_widget')
        widget_.setLayout(layout)
        widget_.setFixedWidth(720)
        widget_.setFixedHeight(height)
        widget_.setStyleSheet(self.style())
        self.add_orders_ui(widget_)
        return widget_
コード例 #4
0
    def ui(self):
        layout = QVBoxLayout(self)
        layout.setAlignment(Qt.AlignTop)
        layout.setSpacing(21)

        # Title
        title = QLabel('Publish Batch Data')
        title.setObjectName('title')
        layout.addWidget(title)

        layout.addSpacing(23)
        # Name
        layout.addLayout(
            self.gen_row(
                "Name:",
                Input.Builder(width=536, height=30).model(self.name).build()))

        # Type
        type_label = 'Batch' if self.type_ == 'Batch' else 'Streaming'
        layout.addLayout(
            self.gen_row('Type:', QLabel('{} data'.format(type_label))))

        # Category
        category = [
            'Advertising', 'Business Intelligence', 'Communications', 'Crypto',
            'Energy', 'Entertainment', 'Environment', 'Finance', 'Health',
            'Industrial', 'IoT', 'Other', 'Retail', 'Smart Cities',
            'Social Media', 'Sports', 'Transportation', 'Weather'
        ]
        categoryWid = QComboBox()
        for cate in category:
            categoryWid.addItem(cate)

        def itemSelect(index):
            self.category.value = category[index]

        categoryWid.currentIndexChanged.connect(itemSelect)
        layout.addLayout(self.gen_row("Category:", categoryWid))

        # Cover Picture
        openBtn = QLabel('browse...')
        openBtn.setObjectName('openBtn')

        def onOpen(_):
            tmp = QFileDialog.getOpenFileName()[0]
            if tmp:
                self.cover_image.value = tmp

        Binder.click(openBtn, onOpen)
        path = Label(self.cover_image)
        layout.addLayout(self.gen_row('Cover picture:', openBtn))
        layout.addLayout(self.gen_row("", path))

        # Description
        text = Text.Builder(width=536,
                            height=80).model(self.description).build()
        # text.setMaximumHeight(80)
        # text.setMinimumHeight(80)
        # text.setMaximumWidth(536)
        # text.setMinimumWidth(536)
        layout.addLayout(self.gen_row("Description:", text))

        # Price
        layout.addLayout(
            self.gen_row(
                "Price:",
                Input.Builder(width=160, height=30).model(self.price).build(),
                14, QLabel('CPC')))

        # Agreement
        agreement = QLabel("xxxxxx")
        agreement.setObjectName('agreement')
        layout.addLayout(
            self.gen_row("", CheckBox(self.checked), 9,
                         QLabel("I agree with the agreement of"), 5,
                         agreement))

        # Bottom
        cancel = QPushButton('Cancel')
        cancel.setObjectName('pinfo_cancel_btn')
        cancel.clicked.connect(self.handle_cancel)
        ok = QPushButton('Publish')
        ok.setObjectName('pinfo_publish_btn')
        ok.clicked.connect(self.handle_publish)
        layout.addLayout(self.gen_row("", cancel, 20, ok))
        layout.addStretch(1)
        return layout
コード例 #5
0
ファイル: order_detail.py プロジェクト: Alex-Cheng/pdash
    def ui(self):
        layout = QVBoxLayout()
        layout.addWidget(self.gen_row('Order Time:', Label(self.order_time)))
        layout.addWidget(self.gen_row('Stauts:', Label(self.status)))

        # Bottom
        btm = QHBoxLayout()
        btm.setAlignment(Qt.AlignLeft)
        btm.setContentsMargins(0, 0, 0, 0)
        btm.setSpacing(15)

        if self.data_type == 'batch':
            ok = QPushButton('Download')
            ok.setObjectName('pinfo_publish_btn')
            btm.addWidget(ok)
            ok.clicked.connect(self.download)
            confirm = QPushButton('Confirm')
            confirm.setObjectName('pinfo_cancel_btn')
            confirm.clicked.connect(self.confirm)
            btm.addWidget(confirm)
            btm.addStretch(1)
            layout.addLayout(btm)

            storage = QLabel('Open Storage Path…')
            storage.setStyleSheet("""
                margin-top: 12px;
                font-family:SFUIDisplay-Medium;
                font-size:14px;
                color:#0073df;
            """)
            Binder.click(storage, self.select_storage_path)
            layout.addWidget(storage)
        else:
            ok = QPushButton('Get Streaming ID')
            ok.setObjectName('pinfo_stream_btn')

            def openStreamID(_):
                def cb(path):
                    if path:
                        stream_id = json.loads(path)
                        self.open1.emit(stream_id[0])

                deferToThread(lambda: fs.buyer_file_by_order_id(self.order_id).
                              path).addCallback(cb)

            ok.clicked.connect(openStreamID)
            btm.addWidget(ok)
            preview = QPushButton('Preview')
            preview.setObjectName('pinfo_cancel_btn')

            def openPreview(_):
                dlg = PreviewDialog(ws_url=self.ws_url)
                dlg.show()

            preview.clicked.connect(openPreview)
            btm.addWidget(preview)
            confirm = QPushButton('Confirm')
            confirm.setObjectName('pinfo_cancel_btn')
            btm.addWidget(confirm)
            btm.addStretch(1)
            layout.addLayout(btm)
        self.confirmBtn = confirm
        if self.has_comfirmed:
            self.confirmBtn.hide()

        self.setLayout(layout)
        self.setStyleSheet("""
            QWidget#order_item {
                margin-top: 20px;
                margin-bottom: 20px;
            }
            QLabel#order_item_name {
                font-family:SFUIDisplay-Regular;
                font-size:14px;
                color:#666666;
                text-align:left;
            }
            Label#order_item_value {
                font-family:SFUIDisplay-Regular;
                font-size:14px;
                color:#000000;
                text-align:left;
            }
            QPushButton#pinfo_cancel_btn{
                padding-left: 10px;
                padding-right: 10px;
                border: 1px solid #3173d8; 
                border-radius: 3px;
                color: #3173d8;
                min-height: 30px;
                max-height: 30px;
                background: #ffffff;
                min-width: 80px;
                max-width: 80px;
            }

            QPushButton#pinfo_cancel_btn:hover{
                border: 1px solid #3984f7; 
                color: #3984f6;
            }

            QPushButton#pinfo_cancel_btn:pressed{
                border: 1px solid #2e6dcd; 
                color: #2e6dcd;
                background: #e5ecf4;
            }

            QPushbutton#pinfo_cancel_btn:disabled{
                border: 1px solid #8cb8ea; 
                color: #8cb8ea;
            }

            QPushButton#pinfo_publish_btn, QPushButton#pinfo_stream_btn{
                padding-left: 10px;
                padding-right: 10px;
                border: 1px solid #3173d8; 
                border-radius: 3px;
                color: #ffffff;
                min-height: 30px;
                max-height: 30px;
                min-width: 80px;
                max-width: 80px;
                background: #3173d8;
            }

            QPushButton#pinfo_publish_btn:hover, QPushButton#pinfo_stream_btn:hover{
                background: #3984f7; 
                border: 1px solid #3984f7;
            }

            QPushButton#pinfo_publish_btn:pressed, QPushButton#pinfo_stream_btn:pressed{
                border: 1px solid #2e6dcd; 
                background: #2e6dcd;
            }

            QPushbutton#pinfo_publish_btn:disabled, QPushButton#pinfo_stream_btn:disabled{
                border: 1px solid #8cb8ea; 
                background: #98b9eb;
            }

            QPushButton#pinfo_stream_btn {
                min-width: 120px;
                max-width: 120px;
            }
        """)