def initUI(self): layout = QGridLayout(self) hint = QLabel(self.text) layout.addWidget(QLabel(""), 0, 0) hbox = QHBoxLayout() hbox.setAlignment(Qt.AlignLeft) hbox.addWidget(hint) self.open_text = QLabel(self.browse_text) self.open_text.setObjectName('open') Binder.click(self.open_text, self.onOpen) hbox.addWidget(self.open_text) hbox.addStretch(1) layout.addLayout(hbox, 1, 0, 2, 1) self.target = QLabel("") layout.addWidget(self.target, 3, 0) layout.addWidget(QLabel(""), 4, 0) self.setLayout(layout) self.setObjectName('main') self.setStyleSheet(""" QFrame#main { background: white; border: 1px dashed #bbb; border-radius: 3px; } #open { color:#4a90e2; height: 20px; } """)
def __init__(self, star, listener): self.star = star self.listener = listener self.icon = Star.load_star(abs_path('icons/[email protected]')) self.clicked_icon = Star.load_star( abs_path('icons/star_{}@2x.png'.format(star))) super().__init__() self.setPixmap(self.icon) self.is_clicked = False Binder.click(self, self.onClicked)
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
def ui(self): width = 150 height = 150 layout = QHBoxLayout() layout.setContentsMargins(0, 0, 0, 0) layout.setAlignment(Qt.AlignLeft) for pic in self.pictures.value: tmp = Picture(path=pic, width=width, height=height) layout.addWidget(tmp) add = Picture(path=abs_path('icons/[email protected]'), width=width, height=height) Binder.click(add, self.read_file) layout.addWidget(add) return layout
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_
def ui(self): layout = QVBoxLayout() layout.setAlignment(Qt.AlignTop) first = QHBoxLayout() image = QLabel() image.setObjectName('image') pix = QPixmap(self.image) pix = pix.scaled(96, 96) image.setPixmap(pix) first.addWidget(image) name = Builder().model(self.name).build() first.addWidget(name) first.addStretch(1) layout.addLayout(first) status = ['Order', 'Deliver', 'Receive', 'Confirm', 'Comment'] callbacks = { 'Deliver': self.deliver, 'Receive': self.receive, 'Confirm': self.confirm, 'Comment': self.comment } second = QHBoxLayout() second.setAlignment(Qt.AlignLeft) second.addSpacing(50) second.setSpacing(5) i = 0 h1 = 35 h2 = 15 width = 95 for item in status: mode = 'active' if i == self.current else ( 'todo' if i > self.current else 'finish') if item == 'Deliver' and self.current == 1 and self.is_buyer: mode = 'todo' if item == 'Receive' and self.current == 2 and self.is_seller: mode = 'todo' if item == 'Confirm' and self.current == 3 and self.is_seller: mode = 'todo' if item == 'Comment' and self.current == 4 and self.is_seller: mode = 'todo' timestamp = self.timestamps[i] if i < self.current else None tmp = Status(name=item, mode=mode, timestamp=timestamp, h1=h1, h2=h2, width=width, order_id=self.order_id) cb = callbacks.get(item) if cb and mode == 'active': Binder.click(tmp, cb) second.addWidget(tmp) if item != status[-1]: line = StatusLine(h1, h2) second.addWidget(line) i += 1 second.addStretch(1) layout.addLayout(second) layout.addStretch(1) self.setLayout(layout) self.setStyleSheet(""" """)
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
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; } """)