def ui(self, widget): layout = QVBoxLayout(widget) width = 340 layout.addWidget(Builder().name('field').text('Data name:').build()) layout.addWidget( Input.Builder(width=width).model(self.data_name).name( 'data-name').placeholder('Please input data name').build()) layout.addSpacing(10) layout.addWidget( Builder().name('field').text('Select a Proxy:').build()) combox = ComboBox(self.proxy) combox.setMaximumWidth(width + 24) combox.setMinimumWidth(width + 24) layout.addWidget(combox) hbox = QHBoxLayout() hbox.setAlignment(Qt.AlignRight) hbox.addWidget( Button.Builder(width=100, height=30).text('Cancel').click( lambda _: self.close()).build()) hbox.addSpacing(10) hbox.addWidget( Button.Builder(width=100, height=30).text('Next').click( self.toNext).style('primary').build()) layout.addStretch(1) layout.addLayout(hbox) return layout
def ui(self, layout): layout.setAlignment(Qt.AlignTop) self.add(Builder().text('Balance').name('title').build()) self.addH(Builder(Label).model(self.balance).name( 'amount').build(), 0, align=Qt.AlignBottom | Qt.AlignLeft) self.addH(Builder().text('CPC').name('unit').build()) self.add() width = 90 height = 30 self.addH(Button.Builder(width=width, height=height).text('Receive').click( self.receive).name('receive').style('primary').build()) self.addH(Button.Builder(width=width, height=height).text( 'Send').click(self.send).name('send').build()) self.add(space=20) self.add(Line(wid=1, color='#e1e1e1')) self.add(space=18) self.add(Builder().text('Account').name('title').build()) def buildTable(): header = { 'headers': ['Category', 'Payer', 'Amount(CPC)', 'Time'], 'width': [202, 190, 170, 108] } data = [] self.table_data.value = data def itemHandler(data): items = [] items.append(data.category) items.append(data.payer) wid = QLabel(('+' if data.amount >= 0 else '') + str(data.amount)) wid.setStyleSheet("QLabel{{color: {};}}".format( '#00a20e' if data.amount >= 0 else '#d0021b')) items.append(wid) items.append(data.time) return items table = Table(self, header, self.table_data, itemHandler, sort=None) table.setObjectName('my_table') table.setFixedWidth(802) return table table = buildTable() self.table = table self.buildTable = buildTable self.add(table) # No Data nodata = QLabel('No Data!') nodata.setObjectName('no_data') self.nodata = nodata self.add(nodata) self.nodata.hide() if len(self.table_data.value) == 0: self.nodata.show() layout.addStretch(1) return layout
def ui(self, widget): layout = QVBoxLayout(widget) layout.setSpacing(20) unit1 = Builder().text('CPC').name('unit').build() unit2 = Builder().text('CPC').name('unit').build() unit3 = Builder().text('CPC').name('unit').build() layout.addLayout( self.gen_row('Balance:', Builder().text(self.account_amount.value).build(), unit1)) layout.addLayout( self.gen_row( 'Transfer Amount:', Input.Builder(height=25, width=120).model(self.transfer_amount).build(), unit2)) layout.addLayout( self.gen_row( 'Remark:', Input.Builder(height=25, width=120).model(self.remark).build())) layout.addLayout( self.gen_row( 'Collection Address:', Input.Builder(height=25, width=250).model( self.collection_address).build())) layout.addLayout( self.gen_row( 'Payment Address:', Input.Builder(height=25, width=250).model(self.payaddr).build())) layout.addLayout( self.gen_row('Gas Price:', Builder().text(self.gas.value).build(), unit3)) hbox = QHBoxLayout() hbox.addStretch(1) cancel = Button.Builder( width=100, height=28).click(lambda _: self.close()).text('Cancel').build() hbox.addWidget(cancel) next_ = Button.Builder(width=100, height=28).style('primary').click( self.openPassword).text('Next').build() hbox.addWidget(next_) hbox.addSpacing(5) layout.addLayout(hbox) return layout
def ui(self, widget): layout = QVBoxLayout(widget) width = 300 layout.addWidget(Builder().name('field').text('Data name:').build()) layout.addWidget( Builder(Label).name('value').text( self.data_name.value).wrap(True).model(self.data_name).build()) layout.addSpacing(10) layout.addWidget(Builder().name('field').text('Stream ID:').build()) layout.addWidget( Builder(Label).name('value').text( self.stream_id.value).wrap(True).model(self.stream_id).build()) layout.addSpacing(10) layout.addWidget(Builder().name('copy').text('copy').click( self.copyText).build()) layout.addStretch(1) hbox = QHBoxLayout() hbox.setAlignment(Qt.AlignRight) hbox.addWidget( Button.Builder( width=100, height=30).text('OK').click(lambda _: self.close()).build()) layout.addLayout(hbox) return layout
def ui(self, layout): layout.addSpacing(30) title = Builder().text('Import a keystore file')\ .name('title')\ .build() desc = Builder().text('CPC Wallet uses a keystore format to store encrypted' ' private key information, please drop the file below.')\ .name('desc')\ .wrap(True)\ .height(100)\ .build() self.add(title) self.add(desc, 15) self.file = FileUploadQml(width=247, height=74, background="#f8f8f8", text="Drop keystore file here or", browse_text="browse…") self.add(self.file, 5) password = Input.Builder().placeholder('Password')\ .name('pwd')\ .mode(Input.Password)\ .model(self.password)\ .build() self.add(password, 20) self.import_ = Button.Builder().text('Import')\ .style('primary')\ .click(lambda _: self._import())\ .build() self.add(self.import_, 5) self.loading = Loading() self.loading.hide() self.add(self.loading)
def ui(self, layout): title = Builder().text('Create a new account')\ .name('title')\ .build() desc = Builder().text('The password cannot be modified and we cannot recover it, please backup cautiously.')\ .name('desc')\ .wrap(True)\ .height(80)\ .build() self.add(title) self.add(desc, 40) password = Input.Builder().placeholder('Password')\ .name('pwd')\ .mode(Input.Password)\ .model(self.password)\ .build() self.add(password, 10) repeat = Input.Builder().placeholder('Repeat Password')\ .name('repeat')\ .mode(Input.Password)\ .model(self.repeat)\ .build() self.add(repeat, 10) self.add(Agreement(self.check, width=228, height=30), 40) self.add(Button.Builder().text('Create').style('primary').click( lambda _: self.create()).build())
def ui(self, widget): self.setContentsMargins(0, 0, 0, 0) datas = self.stream.value scroll = QScrollArea() scroll.setContentsMargins(0, 0, 0, 0) scroll.setWidgetResizable(True) self.preview = PreviewWidget() self.obj = self.preview.obj scroll.setWidget(self.preview) _main = QVBoxLayout() _main.addWidget(Builder().text('Stream ID:').build()) _main.addWidget(Builder().text(self.ws_url).build()) _main.addWidget(scroll) hbox = QHBoxLayout() hbox.setAlignment(Qt.AlignRight) hbox.addWidget(Button.Builder(width=100, height=30).text( 'OK').click(lambda _: self.close()).build()) _main.addLayout(hbox) return _main
def ui(self, widget): layout = QVBoxLayout(widget) layout.setContentsMargins(0, 0, 0, 0) layout.addSpacing(16) layout.addLayout( self.gen_row( 'Password:'******'Rate:', Rate())) layout.addSpacing(16) layout.addLayout( self.gen_row( 'Comment:', Text.Builder(width=320, height=80).model(self.comment).placeholder( "Your comment means a lot to all").build())) layout.addSpacing(40) bottom = QHBoxLayout() bottom.addStretch(1) bottom.setSpacing(20) btn_width = 80 btn_height = 30 bottom.addWidget( Button.Builder(width=btn_width, height=btn_height).click( self.cancel).text('Cancel').build()) bottom.addWidget( Button.Builder(width=btn_width, height=btn_height).click( self.ok).style("primary").text('OK').build()) bottom.addSpacing(32) layout.addLayout(bottom) layout.addSpacing(24) layout.addStretch(1) return layout
def ui(self, widget): layout = QVBoxLayout(widget) layout.setSpacing(20) self.loading = Loading() layout.addLayout(self.gen_row('Payment password:'******'', self.loading, left_width=120)) self.loading.hide() hbox = QHBoxLayout() hbox.addStretch(1) self.ok = Button.Builder(width=100, height=28).style( 'primary').click(self.beforeSend).text('OK').build() hbox.addWidget(self.ok) hbox.addSpacing(5) layout.addLayout(hbox) return layout
def ui(self, layout): title = Builder().text('Backup your wallet now')\ .name('title')\ .build() desc = Builder().text('Make sure you backup your keystore file and password.\n\n' 'Keep a copy of the keystore file where you can\'t lose it.')\ .name('desc')\ .wrap(True)\ .height(100)\ .build() self.add(title, 10) self.add(desc, 70) self.add( Button.Builder().text('Check and Backup').style('primary').click( lambda _: self.backup()).build(), 10) self.add( Builder().name('next').text('Next >').align( Qt.AlignRight).click(lambda _: self.to(self.next_)).build(), 10)
def ui(self, layout): title = Builder().text('Create a username')\ .name('title')\ .build() desc = Builder().text('The username will be bound to the keystore file and cannot be modified.')\ .name('desc')\ .wrap(True)\ .height(80)\ .build() self.add(title) self.add(desc, 40) username = Input.Builder().placeholder('Username')\ .name('pwd')\ .model(self.username)\ .build() self.username_elem = username self.add(username, 10) self.add(Button.Builder().text('Enter PDash').style('primary').click( lambda _: self.enter()).build())
def ui(self, widget): layout = QVBoxLayout(widget) row = QHBoxLayout() row.addWidget(Builder().text('Address:').name('address_hint').build()) row.addWidget(Builder().text( self.address.value).name('address').build()) row.addStretch(1) layout.addLayout(row) row2 = QHBoxLayout() row2.setAlignment(Qt.AlignBottom) row2.addWidget(Button.Builder(width=50, height=25).click( self.copy_address).text('copy').name('copy').build()) self.copyed = Builder().text('copyed!').name('copyed').build() row2.addWidget(self.copyed) self.copyed.hide() row2.addStretch(1) layout.addLayout(row2) layout.addWidget(Builder().text('Get CPC for free').name('get_cpc').click( lambda _: self.openUrl(config.account.charge_server)).build()) return layout
def ui(self, vLayout): def buildTable(): header = { 'headers': ['Name', 'Location', 'Size', 'Status'], 'width': [282, 170, 170, 54] } data = fs.get_file_by_data_type() self.table_data.value = data def buildProductClickListener(product_id): def listener(event): app.router.redirectTo('publish_product', product_id=product_id) return listener def itemHandler(data): items = [] items.append(data.name) items.append(data.remote_type) items.append(str(sizeof_fmt(data.size))) status = data.is_published wid = QLabel('Published') if not status: wid.setText('Publish as product') wid.setStyleSheet("QLabel{color: #006bcf;}") Binder.click(wid, buildProductClickListener(data.id)) items.append(wid) return items table = Table(self, header, self.table_data, itemHandler, sort=None) table.setObjectName('my_table') table.setFixedWidth(800) return table table = buildTable() self.table = table self.buildTable = buildTable def buildStreamTable(): def right_menu(row): self.menu = QMenu(self.stream_table) show_id = QAction('Stream ID', self) def open(): uri = self.stream_data.value[row].remote_uri name = self.stream_data.value[row].name if uri: try: uri = json.loads(uri) ws_url = uri.get('ws_url') dlg = StreamUploadedDialog(data_name=name, stream_id=ws_url) dlg.show() except Exception as e: logger.debug(uri) logger.error(e) show_id.triggered.connect(lambda: open()) self.menu.addAction(show_id) self.menu.popup(QCursor.pos()) self.menu.setStyleSheet(""" QMenu::item::selected { color: #666; } """) header = { 'headers': ['Name', 'Location', 'Status'], 'width': [327, 295, 54] } data = fs.get_file_by_data_type('stream') self.stream_data.value = data def buildProductClickListener(product_id): def listener(event): app.router.redirectTo('publish_product', product_id=product_id, type_='stream') return listener def itemHandler(data): items = [] items.append(data.name) items.append(data.remote_type) status = data.is_published wid = QLabel('Published') if not status: wid.setText('Publish as product') wid.setStyleSheet("QLabel{color: #006bcf;}") Binder.click(wid, buildProductClickListener(data.id)) items.append(wid) return items table = Table(self, header, self.stream_data, itemHandler, sort=None) table.setObjectName('my_table') table.setFixedWidth(800) def record_check(item): right_menu(item.row()) table.itemClicked.connect(record_check) return table stream_table = buildStreamTable() self.stream_table = stream_table self.buildStreamTable = buildStreamTable self.addH( Button.Builder(width=150, height=30).style('primary').name( 'btn').text('Upload Batch Data').click( self.onClickUpload).build(), 6) self.addH( Button.Builder( width=180, height=30).name('btn').text('Upload Streaming Data').click( self.onClickStreamUpload).build()) self.add(space=10) # Line self.add(Line(wid=1, color="#dadada"), 20) # My Product self.add(Builder().text('My Product').name('label_hint').build()) # Product List pdsWidget = ProductList(self.products, scroll=False) width = 750 height = 200 pdsWidget.setMinimumWidth(width) pdsWidget.setMaximumWidth(width) self.addH(pdsWidget, align=Qt.AlignTop | Qt.AlignHCenter) # Batch Data self.add(Builder().text('Batch Data').name('label_hint').build()) self.add(table) if len(self.table_data.value) == 0: # No Data self.add(Builder().text('0 Batch Data!').name('no_data').build()) # Stream Data self.add(Builder().text('Streaming Data').name('label_hint').build()) self.add(stream_table) if len(self.stream_data.value) == 0: # No Data self.add( Builder().text('0 Streaming Data!').name('no_data').build()) vLayout.addSpacing(100) vLayout.addStretch(1) return vLayout
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_