class CentralWidget(QWidget): def __init__(self, parent): super(CentralWidget, self).__init__(parent) self.layout = QVBoxLayout(self) self.down_field = QHBoxLayout() self.separator = QFrame() self.separator.setFrameShape(QFrame.HLine) self.separator.setLineWidth(1) self.frames = QLabel('Frame: 0/0') self.frames.setMinimumSize(100, 20) self.down_field.addWidget(self.frames) self.down_field.addStretch(1) self.fps = QLabel('FPS: 0') self.fps.setMinimumSize(50, 20) self.down_field.addWidget(self.fps) self.down_field.addStretch(1) self.isPaused = QLabel('Pause') self.isPaused.setMinimumSize(50, 20) self.down_field.addWidget(self.isPaused) self.gif_layout = QHBoxLayout() self.gif_layout.addStretch(1) self.gif_layout.addWidget(parent.img) self.gif_layout.addWidget(parent.pbar) self.gif_layout.addStretch(1) self.layout.addStretch(1) self.layout.addLayout(self.gif_layout) self.layout.addStretch(1) self.layout.addWidget(self.separator) self.layout.addLayout(self.down_field)
def create_calculator(self): title_frame = QFrame() title_layout = QVBoxLayout() #calculator_label = QLabel("Calculate your body fat", self) #calculator_label.setFont(QFont("Ariel", 15)) #calculator_label.setFixedHeight(70) #title_layout.addWidget(calculator_label) #title_frame.setLayout(title_layout) calculator_frame = QFrame() calculator_frame.setObjectName("frameObj") calculator_frame.setFrameStyle(QFrame.Box) calculator_frame.setLineWidth(3) calculator_frame.setStyleSheet("""#frameObj {color: #322d2d;}""") calculator_frame.setMaximumWidth(600) calculator_frame.setMaximumHeight(350) form_layout = self.create_form_metric( ) if self.units == "metric" else self.create_form_imperial() calculator_frame.setLayout(form_layout) wrapper_layout = QVBoxLayout() #wrapper_layout.addWidget(title_frame) wrapper_layout.addWidget(calculator_frame) return wrapper_layout
def init_window(self): self.setWindowIcon(QtGui.QIcon(self.iconName)) self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) self.setStyleSheet("background-color:green") hbox = QVBoxLayout() button = QPushButton("Push Button") button.setStyleSheet("color:white") button.setStyleSheet("background-color:blue") frame = QFrame() frame.setFrameShape(QFrame.StyledPanel) frame.setStyleSheet("background-color:red") frame.setLineWidth(0.6) hbox.addWidget(button) hbox.addWidget(frame) self.setLayout(hbox) self.show()
def __init__(self): super().__init__() vbox = QVBoxLayout(self) self.setTitle("Python Project") frame = QFrame() frame.setLineWidth(2) vbox.addStretch(1) frame.setFrameShape(QFrame.StyledPanel) vbox.addWidget(frame) box = QGridLayout(frame) box.addWidget(QLabel("Project Name:"), 0, 0) self._line_project_name = QLineEdit() self.registerField("name*", self._line_project_name) box.addWidget(self._line_project_name, 0, 1) box.addWidget(QLabel("Create in:"), 1, 0) self.line = QLineEdit() self.registerField("path", self.line) choose_dir_action = self.line.addAction( QIcon(self.style().standardPixmap( self.style().SP_DirIcon)), QLineEdit.TrailingPosition) box.addWidget(self.line, 1, 1) box.addWidget(QLabel("Interpreter:"), 2, 0) line_interpreter = QComboBox() line_interpreter.setEditable(True) line_interpreter.addItems(utils.get_python()) box.addWidget(line_interpreter, 2, 1) # from ninja_ide.utils import utils choose_dir_action.triggered.connect(self._choose_dir) self.line.setText(utils.get_home_dir())
class Page(QWidget): Hiding = QtCore.pyqtSignal(int) Showing = QtCore.pyqtSignal(int) def __init__(self, index: int, page_name: str, parent: QWidget = None): super(Page, self).__init__(parent) self.myIndex: int = index self.setObjectName(page_name) self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.MinimumExpanding) self.setContentsMargins(0, 0, 0, 0) self.hboxlayout = QHBoxLayout(self) self.hboxlayout.setContentsMargins(0, 0, 0, 0) self.hboxlayout.setSpacing(0) self.setLayout(self.hboxlayout) scroll_area = QScrollArea(self) scroll_area.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) scroll_area.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) scroll_area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.MinimumExpanding) scroll_area.setFrameShape(QFrame.NoFrame) scroll_area.setFrameShadow(QFrame.Plain) scroll_area.setLineWidth(0) scroll_area.setWidgetResizable(True) scroll_area.installEventFilter(TTScroller(scroll_area)) self.inner_area = QFrame() self.inner_area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Ignored) self.inner_area.setProperty("TTPage", QtCore.QVariant(True)) self.inner_area.setContentsMargins(0, 0, 0, 0) self.inner_area.setFrameShape(QFrame.Box) self.inner_area.setLineWidth(0) self.innerLayout = QHBoxLayout(self.inner_area) self.innerLayout.setContentsMargins(0, 0, 0, 0) self.innerLayout.setSpacing(2) self.inner_area.setLayout(self.innerLayout) spacer = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) self.innerLayout.addItem(spacer) scroll_area.setWidget(self.inner_area) self.hboxlayout.addWidget(scroll_area) def add_group(self, name: str): grp = group.Group(name, self.inner_area) self.innerLayout.insertWidget(self.innerLayout.count() - 1, grp) parent_toolbar = tabtoolbar.find_tabtoolbar(self) # type: ignore[attr-defined] if not parent_toolbar: raise Exception("Could not find Parent Tabtoolbar") parent_toolbar.adjust_verticalsize(grp.height()) return grp def hide(self): self.Hiding.emit(self.myIndex) def show(self): self.Showing.emit(self.myIndex)
def __init__(self): super().__init__() self.title = "PyQt5 QButton Group" self.top = 200 self.left = 500 self.width = 400 self.height = 300 self.setWindowTitle(self.title) self.setWindowIcon(QtGui.QIcon("pyqt.png")) self.setGeometry(self.left, self.top, self.width, self.height) self.setStyleSheet("background-color:yellow") hbox = QHBoxLayout() frame = QFrame() frame.setFrameShape(QFrame.StyledPanel) frame.setStyleSheet("background-color:green") frame.setLineWidth(0.4) button = QPushButton("click Me") button.setStyleSheet("background-color:red") hbox.addWidget(frame) hbox.addWidget(button) self.setLayout(hbox) self.show()
def create_time_graph(self): self.graph_layout = QVBoxLayout() graph = OneRMGraphCanvas("Horizontal Press", self.rm_history, self.current_year, self) combobox_layout = QHBoxLayout() self.lifts_combobox = QComboBox(self) self.lifts_combobox.addItems(list(self.preferred_lifts.values())) self.lifts_combobox.currentTextChanged.connect( lambda lift: self.change_exercise_graph(lift)) self.change_year_combobox = QComboBox(self) self.change_year_combobox.addItems(list(self.rm_history.keys())) self.change_year_combobox.setCurrentText(self.current_year) self.change_year_combobox.currentTextChanged.connect( lambda year: self.change_graph_year(year)) combobox_layout.addWidget(self.change_year_combobox) combobox_layout.addWidget(self.lifts_combobox) toolbar = NavigationToolbar(graph, self) toolbar.setStyleSheet("background-color: white;") self.graph_layout.addWidget(toolbar) self.graph_layout.addWidget(graph) self.graph_layout.addLayout(combobox_layout) framed_graph = QFrame(self) framed_graph.setFrameStyle(QFrame.Box) framed_graph.setLineWidth(3) framed_graph.setLayout(self.graph_layout) return framed_graph
def __init__(self, dataset, neural_network): """ Initiate the GUI Window and create all the relevant Widgets """ super(MainWindow, self).__init__() self.current_dataset_image = 0 self.average_error = 0 self.image_indices = [0] self.image_full_indices = [0] self.image_incorrect_indices = [] self.filterAllowAllImages() self.dataset = dataset self.neural_network = neural_network # Setup Window properties self.setWindowTitle('Hand-written Digit (MNIST) Recognition through Machine Learning') self.setFixedSize(825, 590) self.setStyleSheet("background-color: #181818; color: white") self.main_layout = QHBoxLayout() self.setupLeftPanel() # Line separator between Left and Right Panel separator_line = QFrame() separator_line.setFrameShape(QFrame.VLine) separator_line.setStyleSheet("QFrame { color : #535353; }") separator_line.setLineWidth(3) self.main_layout.addWidget(separator_line) self.setupRightPanel() self.setLayout(self.main_layout)
def __init__(self): super().__init__() self.title = 'Frame' self.top = 200 self.left = 400 self.width = 400 self.height = 200 self.setWindowIcon(QtGui.QIcon('avatar.png')) self.setWindowTitle(self.title) self.setGeometry(self.left, self.top, self.width, self.height) self.setStyleSheet('background-color:yellow') hbox = QHBoxLayout() btn1 = QPushButton('Click Me') btn1.setStyleSheet('color:white') btn1.setStyleSheet('background-color:green') btn1.setFont(QtGui.QFont('Sanserif', 15)) frame = QFrame(self) frame.setFrameShape(QFrame.StyledPanel) frame.setLineWidth(1.0) hbox.addWidget(frame) hbox.addWidget(btn1) self.setLayout(hbox) self.show()
def get_horizontal_line(): line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) line.setLineWidth(1) return line
class Example(QWidget): def __init__(self): super(Example, self).__init__() self.initUI() self.generate_image() def initUI(self): # 从屏幕上(0,0)位置开始(即为最左上角的点),显示一个1000*900的界面(宽30,高35)。 self.setGeometry(0, 0, 1000, 800) self.setWindowTitle("实时刷新正余弦波形图") self.gridLayout = QGridLayout(self) self.frame = QFrame(self) self.frame.setFrameShape(QFrame.Panel) self.frame.setFrameShadow(QFrame.Plain) self.frame.setLineWidth(2) self.frame.setStyleSheet("background-color:rgb(0,255,255);") self.label = QLabel(self) self.label.setText("正弦函数&余弦函数") self.label.setAlignment(Qt.AlignCenter) self.button = QPushButton(self) self.button.setText("生成波形图") self.button.clicked.connect(self.btnClick) self.gridLayout.addWidget(self.frame, 0, 0, 1, 2) self.gridLayout.addWidget(self.label, 1, 0, 1, 1) self.gridLayout.addWidget(self.button, 1, 1, 1, 1) self.setLayout(self.gridLayout) def generate_image(self): verticalLayout = QVBoxLayout(self.frame) win = pg.GraphicsLayoutWidget(self.frame) verticalLayout.addWidget(win) p = win.addPlot(title="动态波形图") p.showGrid(x=True, y=True) p.setLabel(axis="left", text="Amplitude / V") p.setLabel(axis="bottom", text="t / s") p.setTitle("y1 = sin(x) y2 = cos(x)") p.addLegend() self.curve1 = p.plot(pen="r", name="y1") self.curve2 = p.plot(pen="g", name="y2") self.Fs = 1024.0 #采样频率 self.N = 1024 #采样点数 self.f0 = 4.0 #信号频率 self.pha = 0 #初始相位 self.t = np.arange(self.N) / self.Fs #时间向量 1*1024的矩阵 def plotData(self): self.pha += 10 self.curve1.setData( self.t, np.sin(8 * np.pi * self.t + self.pha * np.pi / 180.0)) self.curve2.setData( self.t, np.cos(8 * np.pi * self.t + self.pha * np.pi / 180.0)) def btnClick(self): self.button.setText("再次点击加速!") timer = QTimer(self) timer.timeout.connect(self.plotData) timer.start(100)
def _create_pixel(self, color): """ [description] **Arguments:** :``color``: `[type]` [description] **Keword Arguments:** None **Returns:** :``[type]``: [description] **Author:** Chris Bruce, [email protected], 12/3/2018 """ pixel = QFrame() pixel.setFixedSize(QSize(self.pixel_size, self.pixel_size)) pixel.setFrameShape(QFrame.Box) pixel.setFrameShadow(QFrame.Raised) pixel.setLineWidth(0) pixel.setMidLineWidth(self.pixel_size / 8) pixel.setStyleSheet("background-color: rgb{}".format(color)) return pixel
class Groom(QWidget): def __init__ (self): super().__init__() # self.qt = QWidget() # self.qt = screenWindow self.init_ui() def init_ui(self): # self.qt.showFullScreen() # self.qt.resize(800, 800) # Set background black # self.darkPalette = QPalette() # self.darkPalette.setColor(QPalette.Background, Qt.black) # self.qt.setPalette(self.darkPalette) effect = QGraphicsDropShadowEffect() effect.setOffset(0, 0) effect.setBlurRadius(300) effect.setColor(QColor(255,255,255)) self.frame = QFrame() self.frame.setFrameShape(QFrame.Box) self.frame.setLineWidth(15) self.frame.setMidLineWidth(5) self.frame.setFrameShadow(QFrame.Raised) self.frame.setGraphicsEffect(effect)
def __init__(self): super().__init__() self.title = "PyQt5 - Frames" self.left = 500 self.top = 200 self.width = 200 self.height = 200 self.iconName = "_imagens/mouse.ico" self.setWindowTitle(self.title) self.setWindowIcon(QtGui.QIcon(self.iconName)) self.setGeometry(self.left, self.top, self.width, self.height) self.setStyleSheet('background-color:lightgray') hbox = QHBoxLayout() btn = QPushButton("click me") btn.setStyleSheet('color:white') btn.setStyleSheet('background-color:green') frame = QFrame() frame.setFrameShape(QFrame.StyledPanel) frame.setStyleSheet("background-color:lightblue") frame.setLineWidth(0.6) hbox.addWidget(frame) hbox.addWidget(btn) self.setLayout(hbox) self.show()
def __init__(self, ticker: str, date, title, summary): super().__init__() vbox = QVBoxLayout() hbox = QHBoxLayout() symbol = QLabel('{}'.format(ticker)) date = QLabel('{}'.format(date)) title = QLabel('{}'.format(title)) summary = QLabel('{}'.format(summary)) symbol.setObjectName("symbol") date.setObjectName("date") title.setObjectName("title") summary.setObjectName("summary") symbol.setAlignment(Qt.AlignLeft | Qt.AlignVCenter) date.setAlignment(Qt.AlignRight | Qt.AlignVCenter) hbox.addWidget(symbol) hbox.addWidget(date) vbox.addLayout(hbox) line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) line.setLineWidth(1) vbox.addWidget(line) vbox.addWidget(title) vbox.addWidget(summary) self.setObjectName("news") self.setLayout(vbox)
def __init__(self, x,y,w,h): super(Box, self).__init__() self.x = x self.y = y self.w = w self.h = h self.title = Box.title start_position = (self.x, self.y, self.w, self.h) # self.toolbar = self.addToolBar('Exit') self.setGeometry(*start_position) width = self.w - self.x height = self.h - self.y self.resize(width, height) tb = QtWidgets.QToolBar self.setWindowFlags(Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint) layout = QtWidgets.QHBoxLayout(self) self.setAttribute(Qt.WA_TranslucentBackground) frame =QFrame(self) frame.setFrameShape(QFrame.StyledPanel) frame.setLineWidth(0.6) layout.addWidget(frame) self.show()
def __init__(self): super().__init__() self.title="Frame Window" self.top=100 self.left=100 self.width=400 self.height=120 self.iconName = "logo.png" self.setWindowTitle(self.title) self.setWindowIcon(QtGui.QIcon(self.iconName)) self.setGeometry(self.left, self.top, self.width, self.height) self.setStyleSheet('background-color:yellow') hbox = QHBoxLayout() btn = QPushButton("Click Ok") btn.setStyleSheet("color:white; background-color:black") frame = QFrame() frame.setFrameShape(QFrame.StyledPanel) frame.setLineWidth(0.6) frame.setStyleSheet("background-color:red") hbox.addWidget(frame) hbox.addWidget(btn) self.setLayout(hbox) self.show()
def on_new_data(self, data: Dict): """ Replace existing data views with updated ones drawn from provided dictionary. """ self.clear() show = self.get_keys() for ii, (_, keys) in enumerate(show.items()): current_widget = QWidget() current_layout = FlowLayout() for key in keys: current_layout.addWidget( CellFeatureView(key, get_feature(data, *["cell_record", key]))) current_widget.setLayout(current_layout) self.central_layout.addWidget(current_widget) if ii < len(show) - 1: divider = QFrame() divider.setFrameStyle(QFrame.HLine) divider.setLineWidth(3) self.central_layout.addWidget(divider)
def add_tx_stats(self, vbox): hbox_stats = QHBoxLayout() # left column vbox_left = QVBoxLayout() self.tx_desc = TxDetailLabel(word_wrap=True) vbox_left.addWidget(self.tx_desc) self.status_label = TxDetailLabel() vbox_left.addWidget(self.status_label) self.date_label = TxDetailLabel() vbox_left.addWidget(self.date_label) self.amount_label = TxDetailLabel() vbox_left.addWidget(self.amount_label) fee_hbox = QHBoxLayout() self.fee_label = TxDetailLabel() fee_hbox.addWidget(self.fee_label) self.fee_warning_icon = QLabel() pixmap = QPixmap(icon_path("warning")) pixmap_size = round(2 * char_width_in_lineedit()) pixmap = pixmap.scaled(pixmap_size, pixmap_size, Qt.KeepAspectRatio, Qt.SmoothTransformation) self.fee_warning_icon.setPixmap(pixmap) self.fee_warning_icon.setToolTip( _("Warning") + ": " + _("The fee could not be verified. Signing non-segwit inputs is risky:\n" "if this transaction was maliciously modified before you sign,\n" "you might end up paying a higher mining fee than displayed.")) self.fee_warning_icon.setVisible(False) fee_hbox.addWidget(self.fee_warning_icon) fee_hbox.addStretch(1) vbox_left.addLayout(fee_hbox) vbox_left.addStretch(1) hbox_stats.addLayout(vbox_left, 50) # vertical line separator line_separator = QFrame() line_separator.setFrameShape(QFrame.VLine) line_separator.setFrameShadow(QFrame.Sunken) line_separator.setLineWidth(1) hbox_stats.addWidget(line_separator) # right column vbox_right = QVBoxLayout() self.size_label = TxDetailLabel() vbox_right.addWidget(self.size_label) self.rbf_label = TxDetailLabel() vbox_right.addWidget(self.rbf_label) self.locktime_label = TxDetailLabel() vbox_right.addWidget(self.locktime_label) self.block_hash_label = TxDetailLabel(word_wrap=True) vbox_right.addWidget(self.block_hash_label) self.block_height_label = TxDetailLabel() vbox_right.addWidget(self.block_height_label) vbox_right.addStretch(1) hbox_stats.addLayout(vbox_right, 50) vbox.addLayout(hbox_stats)
def lineSeparator() -> QFrame: line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) line.setLineWidth(1) line.setMidLineWidth(0) line.setMinimumSize(0, 2) return line
def _create_separator(widget): """ Init and create base separator QFrame """ separator = QFrame(widget) separator.setLineWidth(2) separator.setMidLineWidth(1) separator.setFrameShadow(QFrame.Sunken) return separator
def __init__(self, inputDict): super(OtherDialog, self).__init__() self.setWindowTitle('Other configurations') mltpl = inputDict['multiple'] thrshld = inputDict['threshold'] msk = inputDict['mask'] vbox = QVBoxLayout() self.setLayout(vbox) label = QLabel("(*) Only meant for image inserted by template") vbox.addWidget(label) hline = QFrame() hline.setFrameStyle(hline.HLine) hline.setLineWidth(1) vbox.addWidget(hline) formLayout = QFormLayout() vbox.addLayout(formLayout) self.multiple = QCheckBox() self.multiple.setChecked(mltpl) formLayout.addRow("Multiple Match (*):", self.multiple) self.threshold = QDoubleSpinBox() self.threshold.setDecimals(1) self.threshold.setRange(0, 1) self.threshold.setSingleStep(0.1) self.threshold.setValue(thrshld) formLayout.addRow("Threshold (*):", self.threshold) hbox = QHBoxLayout() colorBtn = QPushButton("Select") colorBtn.clicked.connect(self.colorBtn_clicked) hbox.addWidget(colorBtn) _, red, _, green, _, blue = msk.split(',') self.backgroundColor = ("background-color: rgb(" + red + "," + green + "," + blue + ")") self.borderColor = "border: 1px solid black" self.frame = QFrame() self.frame.setStyleSheet(self.borderColor + ";" + self.backgroundColor) hbox.addWidget(self.frame) formLayout.addRow("Image background color:", hbox) self.btns = QDialogButtonBox() self.btns.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) vbox.addWidget(self.btns) self.btns.accepted.connect(self.accept) self.btns.rejected.connect(self.reject)
def create_separator(self) -> QFrame: separator = QFrame(self) separator.setProperty("TTSeparator", QtCore.QVariant(True)) separator.setAutoFillBackground(False) separator.setFrameShadow(QFrame.Plain) separator.setLineWidth(1) separator.setMidLineWidth(0) separator.setFrameShape(QFrame.VLine) return separator
def draw_boarder(parent, width, height): frame = QFrame() frame.setFixedSize(int(width), int(height)) frame.setFrameShape(QFrame.StyledPanel) frame.setLineWidth(2) frame.setContentsMargins(5, 5, 5, 5) parent.addWidget(frame) return frame
def create_progression(self): frame = QFrame() progression_layout = QVBoxLayout() frame.setLayout(progression_layout) self.table = QTableWidget(7, 5) self.table.setEditTriggers(QTableWidget.NoEditTriggers) self.table.verticalHeader().setVisible(False) table_items = { "table_headers": ["Set", "%", "Weight", "Reps", "Rest"], "sets": ["1", "2", "3", "4", "5", "6", "7", "8"], "percentages": ["~30%-50%", "~60%", "~70%", "~80%", "~90%", "~100%", "~102%"], "weight": [""] * 7, "number_of_reps": ["8", "5", "3", "1", "1", "1", "1"], "rest": [ "~2 min", "~2 min", "~3 min", "~3 min", "~5 min", "~5-15 min", "~5-15 min" ] } for key, value in table_items.items(): for i, item in enumerate(value): if key == "table_headers": self.table.setHorizontalHeaderItem(i, QTableWidgetItem(item)) self.table.horizontalHeader().setSectionResizeMode( i, QHeaderView.Stretch) else: _item = QTableWidgetItem(item) _item.setTextAlignment(Qt.AlignCenter) _item.setFlags(Qt.ItemIsEnabled) if key == "sets": self.table.setItem(i, 0, _item) elif key == "percentages": self.table.setItem(i, 1, _item) elif key == "weight": self.table.setItem(i, 2, _item) elif key == "number_of_reps": self.table.setItem(i, 3, _item) elif key == "rest": self.table.setItem(i, 4, _item) for i in range(7): self.table.verticalHeader().setSectionResizeMode( i, QHeaderView.Stretch) grid = QGridLayout() grid_frame = QFrame() grid_frame.setObjectName("graphObj") grid_frame.setFrameStyle(QFrame.Box) grid_frame.setLineWidth(3) grid_frame.setStyleSheet("""#graphObj {color: #322d2d;}""") grid.addWidget(self.table, 1, 0, 1, 1) grid_frame.setLayout(grid) return grid_frame
def add_agent(self): # 获取干员信息 agent_name_id = self.comboBox_3.currentIndex() agent_name = self.comboBox_3.itemText(agent_name_id) if agent_name in self.level_combo_group.keys(): self.messageDialog("干员已添加!") else: star_value = comb_box_data.agents_dict[agent_name]['star'] agent_class_value = comb_box_data.agents_dict[agent_name]['class'] file_path = comb_box_data.agents_dict[agent_name]['profile'] star = comb_box_data.star[star_value] agent_class = comb_box_data.agent_class[agent_class_value] # 窗口设置 wight = QWidget() row_layout = QHBoxLayout() # 等级调整comb comb = QComboBox() comb.setObjectName(agent_name) for k, v in comb_box_data.level.items(): comb.addItem(v, k) self.level_combo_group[agent_name] = comb comb.currentIndexChanged.connect( lambda: self.change_agent_level(agent_name)) # 加入图片 profile = QLabel() profile.setFixedSize(50, 50) png = QtGui.QPixmap(file_path) profile.setPixmap(png) profile.setAlignment(QtCore.Qt.AlignVCenter) profile.setScaledContents(True) # 设置文本 row_layout.addWidget(profile) row_layout.addWidget(QLabel(agent_name)) line = QFrame(self.layoutWidget) line.setLineWidth(1) line.setFrameShape(QFrame.VLine) line.setFrameShadow(QFrame.Sunken) row_layout.addWidget(line) row_layout.addWidget(QLabel('星级:' + star)) row_layout.addWidget(QLabel('职业:' + agent_class)) row_layout.addWidget(comb) # row_layout.addWidget(delete_button) wight.setLayout(row_layout) # 添加项目 item = QListWidgetItem() item.setSizeHint(QtCore.QSize(200, 70)) self.listWidget_2.addItem(item) self.listWidget_2.setItemWidget(item, wight) dic = {'name': agent_name, 'level': 0} self.agent_box.append(dic)
def createConfigBottomRightGroupBox(self, num_HWFactors): self.bottomRightGroupBox = QGroupBox("Hardware Acceleration Factors") self.bottomRightGroupBox.setCheckable(True) self.bottomRightGroupBox.setChecked(True) layout = QGridLayout() # List of labels and value boxes generated dynamically based on num_HWFactors # # hwValueBoxList is a list that hold all the acceleration factor values self.hwLabelList = [ QLabel('HW Rank ' + str(i)) for i in range(num_HWFactors) ] self.hwValueBoxList = [ QDoubleSpinBox(self.bottomRightGroupBox) for i in range(num_HWFactors) ] # Iterates through the list of GUI elements and adds them to the sub-gridlayout # # counter i is used to indicate which "row" of the grid layout the GUI element will be added to i = 0 y = 0 for hwLabels, hwValueBoxes in zip(self.hwLabelList, self.hwValueBoxList): # Add label to top position of row "i" in the grid layout.addWidget(hwLabels, i, 0, QtCore.Qt.AlignTop) # Set max and initial values for value box hwValueBoxes.setMaximum(1000000) hwValueBoxes.setValue(self.hardware_nodes[y]) # Add value box directly below its label in row "i + 1" in the grid layout.addWidget(hwValueBoxes, i + 1, 0, QtCore.Qt.AlignTop) # RowStretch workaround to align the value box directly under the label layout.setRowStretch(i + 1, 1) separator = QFrame() separator.setFrameShape(QFrame.HLine) separator.setLineWidth(1) layout.addWidget(separator, i + 2, 0, QtCore.Qt.AlignTop) layout.setRowStretch(i + 2, 10) i += 3 y += 1 self.bottomRightGroupBox.setLayout(layout) self.scrollhwWindow = QScrollArea() self.scrollhwWindow.setWidget(self.bottomRightGroupBox) self.scrollhwWindow.setWidgetResizable(True) self.scrollhwWindow.setFixedHeight(400) self.scrollhwWindow.setFixedWidth(300)
def __init__(self, name: str, parent: QWidget): super(Group, self).__init__(parent) # self.setFrameShape(QFrame.NoFrame) # self.setLineWidth(0) self.setContentsMargins(0, 0, 0, 0) self.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) seperator_layout = QHBoxLayout(self) seperator_layout.setContentsMargins(0, 0, 0, 0) seperator_layout.setSpacing(0) seperator_layout.setDirection(QBoxLayout.LeftToRight) self.setLayout(seperator_layout) outer_layout = QVBoxLayout() outer_layout.setContentsMargins(0, 0, 0, 0) outer_layout.setSpacing(0) outer_layout.setDirection(QBoxLayout.TopToBottom) seperator_layout.addLayout(outer_layout) seperator_layout.addWidget(self.create_separator()) inner_frame = QFrame(self) inner_frame.setFrameShape(QFrame.NoFrame) inner_frame.setLineWidth(0) inner_frame.setContentsMargins(0, 0, 0, 0) inner_frame.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum) self.inner_layout = QHBoxLayout(inner_frame) self.inner_layout.setContentsMargins(2, 4, 2, 0) self.inner_layout.setSpacing(4) self.inner_layout.setDirection(QBoxLayout.LeftToRight) inner_frame.setLayout(self.inner_layout) outer_layout.addWidget(inner_frame) self.group_name = QLabel(name, self) self.group_name.setProperty("TTGroupName", QtCore.QVariant(True)) self.group_name.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum) self.group_name.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter # type: ignore ) self.group_name.adjustSize() outer_layout.addWidget(self.group_name) parent_tabtoolbar = tabtoolbar.find_tabtoolbar(self) if not parent_tabtoolbar: raise Exception("Could not find Parent Tabtoolbar") group_maxheight = parent_tabtoolbar.group_maxheight rowcount = parent_tabtoolbar.rowcount() height = group_maxheight + self.group_name.height() + rowcount - 1 self.setMinimumHeight(height) self.setMaximumHeight(height)
def _setup_ui(self): base_layout = QVBoxLayout(self) frame = QFrame(self) frame.setFrameShadow(QFrame.Raised) frame.setFrameShape(QFrame.Box) frame.setLineWidth(5) frame.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) base_layout.addWidget(frame) sub_layout = QVBoxLayout(frame) sub_layout.setContentsMargins(0, 0, 0, 0) view = QGraphicsView(frame) view.setScene(self._scene) sub_layout.addWidget(view)
def create_graph(self): self.graph_layout = QVBoxLayout() graph = WeightLossGraphCanvas( self.db_wrapper.months[datetime.today().month - 1], self.current_year, self) toolbar = NavigationToolbar(graph, self) toolbar.setStyleSheet("background-color: white;") combobox_layout = QHBoxLayout() self.months_combobox = QComboBox() months = [] for entry in self.weight_history: month = entry.split("/")[1] for month_name, code in self.db_wrapper.months_mappings.items(): if code == month: month = month_name if not month in months: months.append(month) if len(months) == 0: months.append(self.db_wrapper.months[datetime.today().month - 1]) self.months_combobox.addItems(months) self.months_combobox.setCurrentText( self.db_wrapper.months[datetime.today().month - 1]) self.months_combobox.currentTextChanged.connect( lambda month: self.change_month_graph(month)) self.change_year_combobox = QComboBox() years = [] for entry in self.weight_history: if not entry.split("/")[-1] in years: years.append(entry.split("/")[-1]) if len(years) == 0: years.append(str(self.current_year)) self.change_year_combobox.addItems(list(reversed(years))) self.change_year_combobox.currentTextChanged.connect( lambda year: self.change_year_graph(year)) combobox_layout.addWidget(self.months_combobox) combobox_layout.addWidget(self.change_year_combobox) self.graph_layout.addWidget(toolbar) self.graph_layout.addWidget(graph) self.graph_layout.addLayout(combobox_layout) framed_graph = QFrame(self) framed_graph.setFrameStyle(QFrame.Box) framed_graph.setLineWidth(3) framed_graph.setLayout(self.graph_layout) return framed_graph
def _widgets(self): ''' Create widgets into tab. ''' style = ''' QLabel { font-weight: bold; } ''' # io io_l = QLabel('I/O Interface', self) io_l.setStyleSheet(style) self.layout.addWidget(io_l, 0, 0, 1, 2, Qt.AlignTop | Qt.AlignCenter) self.io_cb = QComboBox(self) self.io_cb.addItems(('read', 'mmap')) self.io_cb.setEnabled(False) self.layout.addWidget(self.io_cb, 1, 0, 1, 2, Qt.AlignTop) # separator sep = QFrame(self) sep.setFrameShape(QFrame.HLine) sep.setFrameShadow(QFrame.Sunken) sep.setLineWidth(1) sep.setMidLineWidth(0) self.layout.addWidget(sep, 2, 0, 1, 2, Qt.AlignTop) # fps fps_l = QLabel('Frames per second', self) fps_l.setStyleSheet(style) self.layout.addWidget(fps_l, 3, 0, 1, 2, Qt.AlignTop | Qt.AlignCenter) self.fps_cb = QComboBox(self) self.layout.addWidget(self.fps_cb, 4, 0, 1, 2, Qt.AlignTop | Qt.AlignCenter) # crop crop_l = QLabel('Cropping', self) crop_l.setStyleSheet(style) self.layout.addWidget(crop_l, 5, 0, 1, 2, Qt.AlignTop | Qt.AlignCenter) ## top top_l = QLabel('Top', self) top_l.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred) self.layout.addWidget(top_l, 6, 0, 1, 1, Qt.AlignTop) self.crop_t_sb = QSpinBox(self) self.layout.addWidget(self.crop_t_sb, 6, 1, 1, 1, Qt.AlignTop) ## left left_l = QLabel('Left', self) left_l.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred) self.layout.addWidget(left_l, 7, 0, 1, 1, Qt.AlignTop) self.crop_l_sb = QSpinBox(self) self.layout.addWidget(self.crop_l_sb, 7, 1, 1, 1, Qt.AlignTop) ## width width_l = QLabel('Width', self) width_l.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred) self.layout.addWidget(width_l, 8, 0, 1, 1, Qt.AlignTop) self.crop_w_sb = QSpinBox(self) self.layout.addWidget(self.crop_w_sb, 8, 1, 1, 1, Qt.AlignTop) ## height height_l = QLabel('Height', self) height_l.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred) self.layout.addWidget(height_l, 9, 0, 1, 1, Qt.AlignTop) self.crop_h_sb = QSpinBox(self) self.layout.addWidget(self.crop_h_sb, 9, 1, 1, 1, Qt.AlignTop) # format format_l = QLabel('Window size', self) format_l.setStyleSheet(style) self.layout.addWidget(format_l, 10, 0, 1, 2, Qt.AlignTop | Qt.AlignCenter) ## width fwidth_l = QLabel('Width', self) fwidth_l.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred) self.layout.addWidget(fwidth_l, 11, 0, 1, 1, Qt.AlignTop) self.format_w_sb = QSpinBox(self) self.layout.addWidget(self.format_w_sb, 11, 1, 1, 1, Qt.AlignTop) ## height fheight_l = QLabel('Height', self) fheight_l.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred) self.layout.addWidget(fheight_l, 12, 0, 1, 1, Qt.AlignTop) self.format_h_sb = QSpinBox(self) self.layout.addWidget(self.format_h_sb, 12, 1, 1, 1, Qt.AlignTop)
def _widgets(self): ''' Create widgets into tab. ''' style = ''' QLabel { font-weight: bold; } ''' # filename filename_l = QLabel('Streaming address', self) filename_l.setStyleSheet(style) self.layout.addWidget(filename_l, 0, 0, 1, 7, Qt.AlignTop | Qt.AlignCenter) ## ip ip_l = QLabel('udp://', self) ip_l.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred) self.layout.addWidget(ip_l, 1, 0, 1, 1, Qt.AlignTop) self.ip_1_sb = QSpinBox(self) self.ip_1_sb.setRange(239, 239) self.layout.addWidget(self.ip_1_sb, 1, 1, 1, 1, Qt.AlignTop) self.ip_2_sb = QSpinBox(self) self.ip_2_sb.setRange(0, 254) self.layout.addWidget(self.ip_2_sb, 1, 2, 1, 1, Qt.AlignTop) self.ip_3_sb = QSpinBox(self) self.ip_3_sb.setRange(0, 254) self.layout.addWidget(self.ip_3_sb, 1, 3, 1, 1, Qt.AlignTop) self.ip_4_sb = QSpinBox(self) self.ip_4_sb.setRange(1, 254) self.layout.addWidget(self.ip_4_sb, 1, 4, 1, 1, Qt.AlignTop) ## port port_l = QLabel(':', self) port_l.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred) self.layout.addWidget(port_l, 1, 5, 1, 1, Qt.AlignTop) self.port_sb = QSpinBox(self) self.port_sb.setRange(1025, 65535) self.layout.addWidget(self.port_sb, 1, 6, 1, 1, Qt.AlignTop) # separator sep = QFrame(self) sep.setFrameShape(QFrame.HLine) sep.setFrameShadow(QFrame.Sunken) sep.setLineWidth(1) sep.setMidLineWidth(0) self.layout.addWidget(sep, 2, 0, 1, 7) # streaming parameters str_l = QLabel('Streaming settings', self) str_l.setStyleSheet(style) self.layout.addWidget(str_l, 3, 0, 1, 7, Qt.AlignTop | Qt.AlignCenter) # crf crf_l = QLabel('Constant Rate Factor', self) self.layout.addWidget(crf_l, 4, 0, 1, 7, Qt.AlignCenter) crf_sl_l = QLabel(self) crf_sl_l.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Preferred) self.layout.addWidget(crf_sl_l, 5, 0, 1, 1, Qt.AlignTop) self.crf_sl = QSlider(Qt.Horizontal, self) self.crf_sl.setTickPosition(QSlider.TicksLeft) self.crf_sl.setInvertedAppearance(True) self.crf_sl.setRange(1, 51) self.crf_sl.valueChanged.connect( lambda e: crf_sl_l.setText(str(e)) ) self.layout.addWidget(self.crf_sl, 5, 1, 1, 6, Qt.AlignTop) # muxer mux_l = QLabel('Container', self) self.layout.addWidget(mux_l, 6, 0, 1, 7, Qt.AlignCenter) self.mux_cb = QComboBox(self) #self.mux_cb.setEnabled(False) self.mux_cb.addItems(( 'mpegts', #'matroska', #'ogg', #'mp4', 'avi', #'nut', )) self.layout.addWidget(self.mux_cb, 7, 0, 1, 7, Qt.AlignCenter) # preset pres_l = QLabel('H.264 Preset', self) self.layout.addWidget(pres_l, 8, 0, 1, 7, Qt.AlignCenter) self.pres_cb = QComboBox(self) self.pres_cb.addItems(( 'ultrafast', 'superfast', 'veryfast', 'faster', 'fast', 'medium', 'slow', 'slower', 'veryslow', 'placebo', )) self.layout.addWidget(self.pres_cb, 9, 0, 1, 7, Qt.AlignCenter) # tune tune_l = QLabel('H.264 Tune', self) self.layout.addWidget(tune_l, 10, 0, 1, 7, Qt.AlignCenter) self.tune_cb = QComboBox(self) self.tune_cb.addItems(( 'zerolatency', 'film', 'animation', 'grain', 'stillimage', 'psnr', 'ssim', 'fastdecode', )) self.layout.addWidget(self.tune_cb, 11, 0, 1, 7, Qt.AlignCenter)
class ParameterContainer(QWidget, object): """Container to hold Parameter Widgets.""" def __init__( self, parameters=None, description_text='', extra_parameters=None, parent=None, vertical=True): """Constructor .. versionadded:: 2.2 :param parameters: List of Parameter Widget :type parameters: list :param description_text: Text for description of the parameter container. :type description_text: str """ super().__init__(parent) # attributes if not parameters: self.parameters = [] else: self.parameters = parameters self.description_text = description_text self.extra_parameters = extra_parameters self.parent = parent self.validators = [] self.validators_kwargs = [] # UI if vertical: self.vertical_layout = QVBoxLayout() else: self.vertical_layout = QHBoxLayout() self.widget = QWidget() self.description_label = QLabel() self.description_label.setWordWrap(True) self.scroll_area = QScrollArea() self.group_frame = QFrame() self.qt5_parameter_factory = Qt5ParameterFactory() self.main_layout = QGridLayout() # NOTES(IS) : These functions are commented since the architecture is not # ready yet. # def register_widget(self, parameter, parameter_widget): # """Register new custom widget. # # :param parameter: # :type parameter: GenericParameter # # :param parameter_widget: # :type parameter_widget: GenericParameterWidget # """ # self.qt5_parameter_factory.register_widget( # parameter, parameter_widget) # # def remove_widget(self, parameter): # """Register new custom widget. # # :param parameter: # :type parameter: GenericParameter # """ # if parameter.__name__ in self.dict_widget.keys(): # self.dict_widget.pop(parameter.__name__) def get_parameters(self, validate=True): """Return list of parameters from the current state of widget. :param validate: If true, run validator, else no. :type validate: bool :returns: List of parameter :rtype: list """ if validate: validation_result = self.validate() if not validation_result['valid']: raise InvalidValidationException(validation_result['message']) parameter_widgets = self.get_parameter_widgets() parameters = [] for widget_item in parameter_widgets: parameter_widget = widget_item.widget() parameter = parameter_widget.get_parameter() parameters.append(parameter) # returns based on the object type of self.parameters if isinstance(self.parameters, list): return parameters else: # just return single parameter return parameters[0] def get_parameter_widgets(self): """Return list of parameter widgets from the current state of widget. :returns: List of parameter widget :rtype: list """ parameter_widgets = [self.vertical_layout.itemAt(i) for i in range( self.vertical_layout.count())] return parameter_widgets def setup_ui(self, must_scroll=True): """Setup the UI of this parameter container. """ # Vertical layout to place the parameter widgets self.vertical_layout.setContentsMargins(0, 0, 0, 0) self.vertical_layout.setSpacing(0) # Widget to hold the vertical layout self.widget = QWidget() self.widget.setLayout(self.vertical_layout) # Label for description self.description_label.setText(self.description_text) self.group_frame.setLineWidth(0) self.group_frame.setFrameStyle(QFrame.NoFrame) vlayout = QVBoxLayout() vlayout.setContentsMargins(0, 0, 0, 0) vlayout.setSpacing(0) self.group_frame.setLayout(vlayout) if must_scroll: vlayout.addWidget(self.scroll_area) self.scroll_area.setWidgetResizable(True) self.scroll_area.setWidget(self.widget) else: vlayout.addWidget(self.widget) # Main layout of the container if self.description_text: self.main_layout.addWidget(self.description_label) self.main_layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.main_layout) self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.MinimumExpanding) if not isinstance(self.parameters, list): parameters = [self.parameters] else: parameters = self.parameters if len(parameters) == 0: self.set_empty_parameters() return self.main_layout.addWidget(self.group_frame) self.qt5_parameter_factory = Qt5ParameterFactory() if self.extra_parameters is not None: for extra_parameter in self.extra_parameters: if (type(extra_parameter) == tuple and len(extra_parameter) == 2): self.qt5_parameter_factory.register_widget( extra_parameter[0], extra_parameter[1]) for parameter in parameters: parameter_widget = self.qt5_parameter_factory.get_widget(parameter) parameter_widget.setAutoFillBackground(True) self.vertical_layout.addWidget(parameter_widget) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) def set_description(self, description): """Set description of the parameter container. :param description: A new description fot the parameter container. :type description: str """ self.description_text = description self.description_label.setText(self.description_text) def set_empty_parameters(self): """Update UI if there is no parameters in the container. """ new_description = self.description_text new_description += '\n' new_description += 'But, currently there is no parameters available.' self.description_label.setText(new_description) def add_validator(self, validator, **kwargs): """Add validator for this parameter container. :param validator: validator function for this parameter container. :type validator: function """ validator.parent = self self.validators.append(validator) if kwargs: self.validators_kwargs.append(kwargs) else: self.validators_kwargs.append({}) def validate(self): """Validate of all rule for all parameter in this container. :return: True if all valid, False :rtype: dict """ for i in range(len(self.validators)): validator = self.validators[i] validator_kwargs = self.validators_kwargs[i] validation_result = validator(self, **validator_kwargs) if not validation_result['valid']: return validation_result return { 'valid': True, 'message': '' } def get_parameter_by_guid(self, parameter_guid): """Return a parameter based on its uuid :param parameter_guid: The parameter uuid :type parameter_guid: str :returns: The parameter or None if not exist :rtype: GenericParameter, None """ parameters = self.get_parameters(validate=False) for parameter in parameters: if parameter.guid == parameter_guid: return parameter return None def get_parameter_widget_by_guid(self, parameter_guid): """Return a parameter widget based on its uuid :param parameter_guid: The parameter uuid :type parameter_guid: str :returns: The parameter widget or None if not exist :rtype: GenericParameterWidget, None """ parameter_widgets = self.get_parameter_widgets() for parameter_widget in parameter_widgets: if (parameter_widget.widget().get_parameter().guid == parameter_guid): return parameter_widget.widget() return None
def _uic(self): # First set up the properties of "self", a QWidget. self.setObjectName("EditViewWidget") sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(False) # don't care to bind height to width self.setSizePolicy(sizePolicy) self.setMinimumSize(QSize(250, 250)) self.setFocusPolicy(Qt.StrongFocus) self.setContextMenuPolicy(Qt.CustomContextMenu) self.setWindowTitle("") self.setToolTip("") self.setStatusTip("") self.setWhatsThis("") # Set up our primary widget, the editor self.Editor = PTEditor(self,self.my_book) self.Editor.setObjectName("Editor") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(2) # Edit deserves all available space sizePolicy.setVerticalStretch(2) sizePolicy.setHeightForWidth(False) self.Editor.setSizePolicy(sizePolicy) self.Editor.setFocusPolicy(Qt.StrongFocus) self.Editor.setContextMenuPolicy(Qt.NoContextMenu) self.Editor.setAcceptDrops(True) self.Editor.setLineWidth(2) self.Editor.setDocumentTitle("") self.Editor.setLineWrapMode(QPlainTextEdit.NoWrap) # Set up the frame that will contain the bottom row of widgets # It doesn't need a parent and doesn't need to be a class member # because it will be added to a layout, which parents it. bot_frame = QFrame() sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(False) bot_frame.setSizePolicy(sizePolicy) bot_frame.setMinimumSize(QSize(0, 24)) bot_frame.setContextMenuPolicy(Qt.NoContextMenu) bot_frame.setFrameShape(QFrame.Panel) bot_frame.setFrameShadow(QFrame.Sunken) bot_frame.setLineWidth(3) # Set up the horizontal layout that will contain the following # objects. Its parent is the frame, which gives it a look? HBL = QHBoxLayout(bot_frame) HBL.setContentsMargins(4,2,4,2) # Set up DocName, the document name widget. It is parented # to the bot_frame and positioned by the layout. self.DocName = QLabel(bot_frame) self.DocName.setText("") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(2) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(False) self.DocName.setSizePolicy(sizePolicy) self.DocName.setMinimumSize(QSize(60, 12)) self.DocName.setContextMenuPolicy(Qt.NoContextMenu) self.DocName.setFrameShape(QFrame.StyledPanel) self.DocName.setObjectName("DocName") self.DocName.setToolTip(_TR("EditViewWidget", "Document filename", "tool tip")) self.DocName.setWhatsThis(_TR("EditViewWidget", "The filename of the document being edited. It changes color when the document has been modified.")) HBL.addWidget(self.DocName) spacerItem = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) HBL.addItem(spacerItem) # Set up the label "Folio:" and the Folio display label FolioLabel = QLabel(bot_frame) FolioLabel.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) FolioLabel.setText(_TR("EditViewWidget", "Folio", "label of folio display")) HBL.addWidget(FolioLabel) self.Folio = QLabel(bot_frame) sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(False) self.Folio.setSizePolicy(sizePolicy) self.Folio.setMinimumSize(QSize(30, 12)) self.Folio.setContextMenuPolicy(Qt.NoContextMenu) self.Folio.setFrameShape(QFrame.StyledPanel) self.Folio.setAlignment( Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter ) self.Folio.setObjectName("Folio display") self.Folio.setToolTip(_TR("EditViewWidget", "Folio value for current page", "tooltip")) self.Folio.setStatusTip(_TR("EditViewWidget", "Folio value for the page under the edit cursor", "statustip")) self.Folio.setWhatsThis(_TR("EditViewWidget", "The Folio (page number) value for the page under the edit cursor. Use the Pages panel to adjust folios to agree with the printed book.","whats this")) HBL.addWidget(self.Folio) spacerItem = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) HBL.addItem(spacerItem) FolioLabel.setBuddy(self.Folio) # Set up the image filename lineedit and its buddy label. ImageFilenameLabel = QLabel(bot_frame) ImageFilenameLabel.setAlignment( Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter ) ImageFilenameLabel.setText(_TR("EditViewWidget", "Image", "Image field label")) HBL.addWidget(ImageFilenameLabel) self.ImageFilename = QLineEdit(bot_frame) sizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Fixed ) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(False) self.ImageFilename.setSizePolicy(sizePolicy) self.ImageFilename.setMinimumSize(QSize(30, 12)) self.ImageFilename.setMouseTracking(False) self.ImageFilename.setFocusPolicy(Qt.ClickFocus) self.ImageFilename.setContextMenuPolicy(Qt.NoContextMenu) self.ImageFilename.setAcceptDrops(True) self.ImageFilename.setInputMask("") self.ImageFilename.setAlignment( Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter ) self.ImageFilename.setObjectName("ImageFilename") self.ImageFilename.setToolTip(_TR("EditViewWidget", "Scan image filename", "Image tooltip")) self.ImageFilename.setStatusTip(_TR("EditViewWidget", "Filename of the scan image under the edit cursor", "Image status tip")) self.ImageFilename.setWhatsThis(_TR("EditViewWidget", "This is the name of the scanned image that produced the text under the edit cursor. This image file is displayed in the Image panel.","Image whats this")) HBL.addWidget(self.ImageFilename) spacerItem = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) HBL.addItem(spacerItem) ImageFilenameLabel.setBuddy(self.ImageFilename) # Set up the line number lineedit and its buddy label. LineNumberLabel = QLabel(bot_frame) LineNumberLabel.setText(_TR("EditViewWidget", "Line#", "Line number label")) LineNumberLabel.setAlignment( Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter ) HBL.addWidget(LineNumberLabel) self.LineNumber = QLineEdit(bot_frame) sizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(False) self.LineNumber.setSizePolicy(sizePolicy) self.LineNumber.setMinimumSize(QSize(0, 12)) self.LineNumber.setMouseTracking(False) self.LineNumber.setFocusPolicy(Qt.ClickFocus) self.LineNumber.setContextMenuPolicy(Qt.NoContextMenu) self.LineNumber.setAcceptDrops(True) self.LineNumber.setLayoutDirection(Qt.LeftToRight) self.LineNumber.setCursorPosition(0) self.LineNumber.setAlignment( Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter ) self.LineNumber.setPlaceholderText("") self.LineNumber.setCursorMoveStyle(Qt.LogicalMoveStyle) self.LineNumber.setObjectName("LineNumber") self.LineNumber.setToolTip(_TR("EditViewWidget", "Line number at cursor", "Line number tooltip")) self.LineNumber.setStatusTip(_TR("EditViewWidget", "Line number under cursor or top of current selection","Line number statustip")) self.LineNumber.setWhatsThis(_TR("EditViewWidget", "The line number in the document where the edit cursor is, or the top line of the selection. Enter a new number to jump to that line.","Line number whatsthis")) ImageFilenameLabel.setBuddy(self.ImageFilename) HBL.addWidget(self.LineNumber) spacerItem = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) HBL.addItem(spacerItem) # Set up the column number field and its buddy label. ColNumberLabel = QLabel(bot_frame) ColNumberLabel.setAlignment( Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter ) ColNumberLabel.setText(_TR("EditViewWidget", "Col#", "Col number label")) HBL.addWidget(ColNumberLabel) self.ColNumber = QLabel(bot_frame) sizePolicy = QSizePolicy( QSizePolicy.Expanding, QSizePolicy.Preferred ) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(False) self.ColNumber.setSizePolicy(sizePolicy) self.ColNumber.setMinimumSize(QSize(30, 12)) self.ColNumber.setContextMenuPolicy(Qt.NoContextMenu) self.ColNumber.setFrameShape(QFrame.StyledPanel) self.ColNumber.setFrameShadow(QFrame.Plain) self.ColNumber.setLineWidth(1) self.ColNumber.setAlignment( Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter ) self.ColNumber.setObjectName("ColNumber") self.ColNumber.setToolTip(_TR("EditViewWidget", "Cursor column number", "tool tip")) self.ColNumber.setStatusTip(_TR("EditViewWidget", "Cursor column number", "status tip")) self.ColNumber.setWhatsThis(_TR("EditViewWidget", "The column number position of the cursor in the current line.","whatsthis")) HBL.addWidget(self.ColNumber) # Set up a vertical layout and put two items in it, the editor and HBL VBL = QVBoxLayout() VBL.setContentsMargins(8, 8, 8, 8) VBL.addWidget(self.Editor) VBL.addWidget(bot_frame) self.setLayout(VBL) # end of _uic