def __init__(self, title, file, *args, **kwargs): super(PDFContentPopup, self).__init__(*args, **kwargs) self.setAttribute(Qt.WA_DeleteOnClose) self.file = file self.file_name = title # auth doc type self.setWindowTitle(title) self.resize(1010, 600) self.download = QPushButton("下载PDF", self) self.download.setIcon(QIcon('media/download-file.png')) self.setWindowIcon(QIcon("media/reader.png")) # scroll scroll_area = QScrollArea() scroll_area.setParent(self) scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) # 设置滚动条样式 with open("media/ScrollBar.qss", "rb") as fp: content = fp.read() encoding = chardet.detect(content) or {} content = content.decode(encoding.get("encoding") or "utf-8") scroll_area.setStyleSheet(content) # content self.page_container = QWidget(self) self.page_container.setLayout(QVBoxLayout(self.page_container)) layout = QVBoxLayout(margin=0) layout.setParent(self) # initial data self.add_pages() # add to show scroll_area.setWidget(self.page_container) # add layout # layout.addWidget(self.download, alignment=Qt.AlignLeft) layout.addWidget(scroll_area) self.setLayout(layout)
def __init__(self, title, file, *args, **kwargs): super(PDFContentPopup, self).__init__(*args, **kwargs) self.setAttribute(Qt.WA_DeleteOnClose) self.file = file self.file_name = title # auth doc type self.setWindowTitle(title) self.resize(925, 600) # self.download = QPushButton("下载PDF", self) # self.download.setIcon(QIcon('media/download-file.png')) self.setWindowIcon(QIcon("media/reader.png")) # scroll scroll_area = QScrollArea() scroll_area.setContentsMargins(QMargins(0, 0, 0, 0)) scroll_area.setParent(self) scroll_area.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded) scroll_area.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn) # content self.page_container = QWidget(self) container_layout = QVBoxLayout() # 页面布局 # 计算大小(设置了label范围890-895) container_layout.setContentsMargins(QMargins(10, 5, 10, 5)) # 右边 页面距离10 self.page_container.setLayout(container_layout) layout = QVBoxLayout() # 主布局 layout.setContentsMargins(QMargins(0, 0, 0, 0)) layout.setParent(self) # initial data self.add_pages() # add to show scroll_area.setWidget(self.page_container) scroll_area.setStyleSheet("border:none") scroll_area.horizontalScrollBar().setStyleSheet( "QScrollBar:horizontal{background:transparent;height:10px;margin:0px;}" "QScrollBar:horizontal:hover{background:rgba(0,0,0,30);border-radius:5px}" "QScrollBar::handle:horizontal{background:rgba(0,0,0,50);height:10px;border-radius:5px;border:none}" "QScrollBar::handle:horizontal:hover{background:rgba(0,0,0,100)}" "QScrollBar::add-page:horizontal{height:10px;background:transparent;}" "QScrollBar::sub-page:horizontal{height:10px;background:transparent;}" "QScrollBar::sub-line:horizontal{width:0px}" "QScrollBar::add-line:horizontal{width:0px}") scroll_area.verticalScrollBar().setStyleSheet( "QScrollBar:vertical{background: transparent; width:10px;margin: 0px;}" "QScrollBar:vertical:hover{background:rgba(0,0,0,30);border-radius:5px}" "QScrollBar::handle:vertical{background: rgba(0,0,0,50);width:10px;border-radius:5px;border:none}" "QScrollBar::handle:vertical:hover{background:rgba(0,0,0,100)}" "QScrollBar::add-page:vertical{width:10px;background:transparent;}" "QScrollBar::sub-page:vertical{width:10px;background:transparent;}" "QScrollBar::sub-line:vertical{height:0px}" "QScrollBar::add-line:vertical{height:0px}") # add layout # layout.addWidget(self.download, alignment=Qt.AlignLeft) layout.addWidget(scroll_area) self.setLayout(layout)
def __init__(self, user_id, *args): super(VarietyAuthDialog, self).__init__(*args) self.user_id = user_id self.setAttribute(Qt.WA_DeleteOnClose) self.setWindowTitle("用户品种权限") self.setWindowIcon(QIcon("media/logo.png")) self.setFixedSize(1000, 600) layout = QVBoxLayout() layout.setParent(self) self.user_info_label = QLabel(self) layout.addWidget(self.user_info_label) self.variety_table = QTableWidget(self) self.variety_table.verticalHeader().hide() self.variety_table.cellClicked.connect(self.clickedCell_variety_table) layout.addWidget(self.variety_table) self.setLayout(layout)
def __init__(self): super(EditFinanceCalendarWidget, self).__init__() layout = QVBoxLayout(margin=0) layout.setParent(self) date_layout = QHBoxLayout() date_layout.addWidget(QLabel("日期:", self)) self.date_edit = QDateEdit(QDate.currentDate(), self) self.date_edit.setDisplayFormat("yyyy-MM-dd") date_layout.addWidget(self.date_edit) date_layout.addStretch() layout.addLayout(date_layout) time_layout = QHBoxLayout() time_layout.addWidget(QLabel("时间:", self)) self.time_edit = QTimeEdit(QTime.currentTime(), self) self.time_edit.setDisplayFormat('hh:mm:ss') time_layout.addWidget(self.time_edit) time_layout.addStretch() layout.addLayout(time_layout) area_layout = QHBoxLayout() area_layout.addWidget(QLabel('地区:', self)) self.area_edit = QLineEdit(self) area_layout.addWidget(self.area_edit) layout.addLayout(area_layout) event_layout = QHBoxLayout() event_layout.addWidget(QLabel('事件:', self), alignment=Qt.AlignTop) self.event_edit = QTextEdit(self) self.event_edit.setFixedHeight(100) event_layout.addWidget(self.event_edit) layout.addLayout(event_layout) expected_layout = QHBoxLayout() expected_layout.addWidget(QLabel('预期值:', self)) self.expected_edit = QLineEdit(self) expected_layout.addWidget(self.expected_edit) layout.addLayout(expected_layout) self.commit_button = QPushButton("提交", self) self.commit_button.clicked.connect(self.commit_financial_calendar) layout.addWidget(self.commit_button, alignment=Qt.AlignRight) self.setLayout(layout)
class LiveWidget(QWidget): """ """ def __init__(self): """ """ super(LiveWidget, self).__init__() self.pot_btn = QPushButton('PotPlayer播放') self.vlc_btn = QPushButton('VLC播放') self.vlc_widget = VLCWidget() self.player_widget = QWidget() self.player_layout = QVBoxLayout() self._layout = QVBoxLayout() self.set_player_widget() self.init_ui() def init_ui(self): """ :return: """ # player_layout = QVBoxLayout() self.player_layout.setContentsMargins(0, 0, 0, 0) self.player_layout.setSpacing(0) self.player_layout.addWidget(self.player_widget) main_layout = QVBoxLayout() main_layout.setContentsMargins(0, 0, 0, 0) main_layout.setSpacing(0) main_layout.addLayout(self.player_layout) self.setLayout(main_layout) self.setStyleSheet( "background-image:url(./resources/img/live_null.png); ") def clear_layout(self): """ :return: """ for i in range(self._layout.count()): print("i {0}".format(i)) self._layout.removeItem(self._layout.itemAt(i)) self._layout.setParent(None) self.player_layout.removeItem(self._layout) def set_widget_visible(self, visible): """ :return: """ if visible: # self.vlc_widget.setVisible(True) self.vlc_widget.show() else: # self.vlc_widget.setVisible(False) self.vlc_widget.hide() def set_player_widget(self, widget=False): """ :param widget: :return: """ # self.clear_layout() self._layout.setContentsMargins(0, 0, 0, 0) self._layout.setSpacing(0) self._layout.addWidget(self.vlc_widget) self.set_widget_visible(widget) self.player_widget.setLayout(self._layout)