RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-619327

dynamic.aerospace.inc's questions

Martin Hope
dynamic.aerospace.inc
Asked: 2025-04-16 06:34:19 +0000 UTC

将数据导入 Ninja Trader 8 时出错

  • 5

我使用它Python从莫斯科交易所导入数据并将其转换为这种格式,但是当我尝试将其加载到程序中时,出现了错误。我该如何修复它?

示例数据:

Date,Time,Last,Volume
20240415,095000,2825.29,27826
20240415,095100,2824.16,24813
20240415,095200,2824.65,15432

错误: 在此处输入图片描述

csv
  • 1 个回答
  • 14 Views
Martin Hope
dynamic.aerospace.inc
Asked: 2025-04-06 08:41:31 +0000 UTC

通过公式处理json数据并输入数据到QTabWidget表中时出错

  • 5

我编写了一个代码来与币安上的硬币价格数据进行交互,该程序接收一个包含所有硬币价值的.json
文件作为输入。 之后它将这些数据加载到第二个表中。

用户必须输入公式,lineEdit并且公式及其结果应该出现在第二个表中,但由于某种原因,即使对于正确的公式,代码也会返回错误。
如何修复这个问题?

BinanceTracker.py:

from PyQt6 import QtCore, QtGui, QtWidgets
from PyQt6.QtWidgets import QTableWidgetItem, QMessageBox
from data_loader import load_data_to_table  # Import the data loader


class Ui_BinanceTracker(object):
    def setupUi(self, BinanceTracker):
        BinanceTracker.setObjectName("BinanceTracker")
        BinanceTracker.resize(640, 480)
        BinanceTracker.setStyleSheet("QPushButton {\n"
                                      "    height: 50px; \n"
                                      "    width: 120px;\n"
                                      "    font: 9pt \"Segoe UI\";\n"
                                      "}\n"
                                      "QLineEdit {\n"
                                      "    height: 50px; \n"
                                      "    width: 120px; \n"
                                      "    font: 9pt \"Segoe UI\";\n"
                                      "}\n"
                                      "")
        self.centralwidget = QtWidgets.QWidget(parent=BinanceTracker)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.tabWidget = QtWidgets.QTabWidget(parent=self.centralwidget)
        self.tabWidget.setObjectName("tabWidget")
        self.tab = QtWidgets.QWidget()
        self.tab.setObjectName("tab")
        self.gridLayout_2 = QtWidgets.QGridLayout(self.tab)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.tableWidget = QtWidgets.QTableWidget(parent=self.tab)
        self.tableWidget.setObjectName("tableWidget")
        self.tableWidget.setColumnCount(2)
        self.tableWidget.setHorizontalHeaderLabels(["Формула", "Результат"])
        self.tableWidget.setRowCount(0)
        self.gridLayout_2.addWidget(self.tableWidget, 0, 0, 1, 2)
        self.groupBox = QtWidgets.QGroupBox(parent=self.tab)
        self.groupBox.setObjectName("groupBox")
        self.gridLayout_4 = QtWidgets.QGridLayout(self.groupBox)
        self.gridLayout_4.setObjectName("gridLayout_4")
        self.lineEdit = QtWidgets.QLineEdit(parent=self.groupBox)
        self.lineEdit.setObjectName("lineEdit")
        self.gridLayout_4.addWidget(self.lineEdit, 0, 0, 1, 1)
        self.pushButton = QtWidgets.QPushButton(parent=self.groupBox)
        self.pushButton.setObjectName("pushButton")
        self.gridLayout_4.addWidget(self.pushButton, 0, 1, 1, 1)
        self.pushButton_3 = QtWidgets.QPushButton(parent=self.groupBox)
        self.pushButton_3.setObjectName("pushButton_3")
        self.gridLayout_4.addWidget(self.pushButton_3, 0, 2, 1, 1)
        self.gridLayout_2.addWidget(self.groupBox, 1, 0, 1, 2)
        self.groupBox_2 = QtWidgets.QGroupBox(parent=self.tab)
        self.groupBox_2.setObjectName("groupBox_2")
        self.gridLayout_5 = QtWidgets.QGridLayout(self.groupBox_2)
        self.gridLayout_5.setObjectName("gridLayout_5")
        self.lineEdit_2 = QtWidgets.QLineEdit(parent=self.groupBox_2)
        self.lineEdit_2.setObjectName("lineEdit_2")
        self.gridLayout_5.addWidget(self.lineEdit_2, 0, 0, 1, 1)
        self.lineEdit_3 = QtWidgets.QLineEdit(parent=self.groupBox_2)
        self.lineEdit_3.setObjectName("lineEdit_3")
        self.gridLayout_5.addWidget(self.lineEdit_3, 0, 1, 1, 1)
        self.pushButton_2 = QtWidgets.QPushButton(parent=self.groupBox_2)
        self.pushButton_2.setObjectName("pushButton_2")
        self.gridLayout_5.addWidget(self.pushButton_2, 0, 2, 1, 1)
        self.gridLayout_2.addWidget(self.groupBox_2, 2, 0, 1, 2)
        self.tabWidget.addTab(self.tab, "")
        self.tab_2 = QtWidgets.QWidget()
        self.tab_2.setObjectName("tab_2")
        self.gridLayout_3 = QtWidgets.QGridLayout(self.tab_2)
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.tableWidget_2 = QtWidgets.QTableWidget(parent=self.tab_2)
        self.tableWidget_2.setObjectName("tableWidget_2")
        self.tableWidget_2.setColumnCount(2)
        self.tableWidget_2.setHorizontalHeaderLabels(["Пара", "Цена"])
        self.tableWidget_2.setRowCount(0)
        self.gridLayout_3.addWidget(self.tableWidget_2, 0, 0, 1, 1)
        self.tabWidget.addTab(self.tab_2, "")
        self.gridLayout.addWidget(self.tabWidget, 0, 0, 1, 1)
        BinanceTracker.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(parent=BinanceTracker)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 640, 22))
        self.menubar.setObjectName("menubar")
        BinanceTracker.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(parent=BinanceTracker)
        self.statusbar.setObjectName("statusbar")
        BinanceTracker.setStatusBar(self.statusbar)

        self.retranslateUi(BinanceTracker)
        self.tabWidget.setCurrentIndex(0)
        QtCore.QMetaObject.connectSlotsByName(BinanceTracker)

        # Load data into tableWidget_2
        num_pairs_per_row = 6  # Change this to the desired number of pairs per row
        load_data_to_table(self.tableWidget_2, 'price.json', num_pairs_per_row)

        # Connect the pushButton to a function that will handle the formula
        self.pushButton.clicked.connect(self.calculate_formula)

    def calculate_formula(self):
        # Получаем формулу из lineEdit
        formula = self.lineEdit.text().strip()

        # Разделяем формулу на части (например, ETHBTC*BNBBTC -> ['ETHBTC', 'BNBBTC'])
        parts = formula.replace(' ', '').split('+')  # Сначала разбиваем по '+'

        # Инициализируем результат
        result = 0.0
        valid_formula = True

        # Вычисляем результат
        for part in parts:
            sub_parts = part.split('-')  # Разбиваем по '-'
            sub_result = 0.0
            for sub_part in sub_parts:
                if '*' in sub_part or '/' in sub_part:  # Если есть умножение или деление
                    # Разбиваем по '*' и '/'
                    factors = []
                    for factor in sub_part.replace('-', ' -').replace('+', ' +').split():
                        if factor:  # Проверяем, что не пустая строка
                            factors.append(factor)
                    # Вычисляем результат для текущей подчасти
                    try:
                        sub_result = eval('*'.join(factors))  # Используем eval для вычисления
                    except Exception as e:
                        valid_formula = False
                        break
                else:
                    # Если это просто монета, ищем ее цену
                    found = False
                    for row_index in range(self.tableWidget_2.rowCount()):
                        for col_index in range(0, self.tableWidget_2.columnCount(), 2):
                            if self.tableWidget_2.item(row_index, col_index) and self.tableWidget_2.item(row_index,
                                                                                                         col_index).text() == sub_part:
                                price_item = self.tableWidget_2.item(row_index, col_index + 1)
                                if price_item:
                                    sub_result += float(price_item.text())
                                    found = True
                                break
                    if not found:
                        valid_formula = False
                        break

            result += sub_result

        # Если формула корректна, добавляем результат в tableWidget
        if valid_formula:
            current_row_count = self.tableWidget.rowCount()
            self.tableWidget.setRowCount(current_row_count + 1)  # Увеличиваем количество строк

            # Заполняем строку формулой и результатом
            self.tableWidget.setItem(current_row_count, 0, QTableWidgetItem(formula))  # Добавляем формулу
            self.tableWidget.setItem(current_row_count, 1, QTableWidgetItem(str(result)))  # Добавляем результат
        else:
            # Показываем сообщение об ошибке, если формула некорректна
            QMessageBox.warning(self.centralwidget, "Ошибка", "Некорректная формула или монета не найдена.")

    def retranslateUi(self, BinanceTracker):
        _translate = QtCore.QCoreApplication.translate
        BinanceTracker.setWindowTitle(_translate("BinanceTracker", "BinanceTracker V1"))
        self.groupBox.setTitle(_translate("BinanceTracker", "Операции"))
        self.pushButton.setText(_translate("BinanceTracker", "Добавить операцию"))
        self.lineEdit.setPlaceholderText(_translate("BinanceTracker", "Добавьте отслеживаемую функцию, например: ETHBTC*BNBBTC"))
        self.pushButton_3.setText(_translate("BinanceTracker", "Удалить операцию"))
        self.groupBox_2.setTitle(_translate("BinanceTracker", "Настройки трекера"))
        self.lineEdit_2.setPlaceholderText(_translate("BinanceTracker", "Минимальное значение:"))
        self.lineEdit_3.setPlaceholderText(_translate("BinanceTracker", "Максимальное значение:"))
        self.pushButton_2.setText(_translate("BinanceTracker", "Сохранить значения"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("BinanceTracker", "Отслеживаемые монеты"))
        self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("BinanceTracker", "Полный список монет"))


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    BinanceTracker = QtWidgets.QMainWindow()
    ui = Ui_BinanceTracker()
    ui.setupUi(BinanceTracker)
    BinanceTracker.show()
    sys.exit(app.exec())

数据加载器.py:

import json
from PyQt6.QtWidgets import QTableWidgetItem


def load_data_to_table(table_widget, json_file_path, num_pairs_per_row):
    with open(json_file_path, 'r') as file:
        data = json.load(file)


    num_columns = num_pairs_per_row * 2
    table_widget.setColumnCount(num_columns)

    # Set horizontal header labels
    headers = []
    for i in range(num_pairs_per_row):
        headers.append(f"Монета {i + 1}")
        headers.append(f"Цена {i + 1}")
    table_widget.setHorizontalHeaderLabels(headers)

    num_rows = -(-len(data) // num_pairs_per_row)

    table_widget.setRowCount(num_rows)

    for index, item in enumerate(data):
        row_index = index // num_pairs_per_row
        col_index = (index % num_pairs_per_row) * 2
        table_widget.setItem(row_index, col_index, QTableWidgetItem(item['symbol']))  # Symbol
        table_widget.setItem(row_index, col_index + 1, QTableWidgetItem(item['price']))  # Price

包含测试数据的文件: https://drive.google.com/file/d/15Jb82HgrRUalP-YyVQpx_x2TRO_fsbZA/view?usp =sharing

python
  • 1 个回答
  • 44 Views
Martin Hope
dynamic.aerospace.inc
Asked: 2025-01-29 02:19:50 +0000 UTC

如何让 QToolButton 消失?

  • 6

我有一个用Qt Designer制作的表单。我希望当您单击lineEdit或 时textEdit,它们会出现toolButton,
但直到用户单击它们时,它们才可见。

如何做到这一点?


main.py:

from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 480)
        MainWindow.setStyleSheet("QLineEdit{\n"
"    min-width: 100px;\n"
"    min-height: 35px;\n"
"    background-color: white;\n"
"    border: 1px solid gray;\n"
"    border-radius: 10px;\n"
"    \n"
"    font: 14pt \"Segoe UI Variable\";\n"
"}\n"
"\n"
"QTextEdit{\n"
"    max-width: 800px;\n"
"    max-height: 100px;\n"
"    background-color: white;\n"
"    border: 1px solid gray;\n"
"    border-radius: 10px;\n"
"\n"
"    \n"
"    font: 12pt \"Segoe UI Variable\";\n"
"}\n"
"\n"
"QToolButton{\n"
"    background-color: white;\n"
"    border: 1px solid gray;\n"
"    border-radius: 10px;\n"
"}\n"
"\n"
"QGroupBox{\n"
"    background-color: white;\n"
"    border: 1px solid gray;\n"
"    border-radius: 10px;\n"
"}")
        self.centralwidget = QtWidgets.QWidget(parent=MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.groupBox = QtWidgets.QGroupBox(parent=self.centralwidget)
        self.groupBox.setTitle("")
        self.groupBox.setObjectName("groupBox")
        self.gridLayout_2 = QtWidgets.QGridLayout(self.groupBox)
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.lineEdit = QtWidgets.QLineEdit(parent=self.groupBox)
        self.lineEdit.setObjectName("lineEdit")
        self.gridLayout_2.addWidget(self.lineEdit, 0, 0, 1, 1)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.toolButton_2 = QtWidgets.QToolButton(parent=self.groupBox)
        self.toolButton_2.setMinimumSize(QtCore.QSize(30, 0))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("../../icon/format_bold_30dp_999999_FILL0_wght400_GRAD0_opsz24.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
        self.toolButton_2.setIcon(icon)
        self.toolButton_2.setIconSize(QtCore.QSize(30, 30))
        self.toolButton_2.setObjectName("toolButton_2")
        self.horizontalLayout.addWidget(self.toolButton_2)
        self.toolButton_4 = QtWidgets.QToolButton(parent=self.groupBox)
        icon1 = QtGui.QIcon()
        icon1.addPixmap(QtGui.QPixmap("../../icon/format_italic_30dp_999999_FILL0_wght400_GRAD0_opsz24.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
        self.toolButton_4.setIcon(icon1)
        self.toolButton_4.setIconSize(QtCore.QSize(30, 30))
        self.toolButton_4.setObjectName("toolButton_4")
        self.horizontalLayout.addWidget(self.toolButton_4)
        self.toolButton_3 = QtWidgets.QToolButton(parent=self.groupBox)
        icon2 = QtGui.QIcon()
        icon2.addPixmap(QtGui.QPixmap("../../icon/format_underlined_30dp_999999_FILL0_wght400_GRAD0_opsz24.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
        self.toolButton_3.setIcon(icon2)
        self.toolButton_3.setIconSize(QtCore.QSize(30, 30))
        self.toolButton_3.setObjectName("toolButton_3")
        self.horizontalLayout.addWidget(self.toolButton_3)
        self.toolButton_5 = QtWidgets.QToolButton(parent=self.groupBox)
        icon3 = QtGui.QIcon()
        icon3.addPixmap(QtGui.QPixmap("../../icon/link_30dp_999999_FILL0_wght400_GRAD0_opsz24.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
        self.toolButton_5.setIcon(icon3)
        self.toolButton_5.setIconSize(QtCore.QSize(30, 30))
        self.toolButton_5.setObjectName("toolButton_5")
        self.horizontalLayout.addWidget(self.toolButton_5)
        self.toolButton = QtWidgets.QToolButton(parent=self.groupBox)
        icon4 = QtGui.QIcon()
        icon4.addPixmap(QtGui.QPixmap("../../icon/format_clear_30dp_999999_FILL0_wght400_GRAD0_opsz24.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
        self.toolButton.setIcon(icon4)
        self.toolButton.setIconSize(QtCore.QSize(30, 30))
        self.toolButton.setObjectName("toolButton")
        self.horizontalLayout.addWidget(self.toolButton)
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.gridLayout_2.addLayout(self.horizontalLayout, 1, 0, 1, 1)
        self.textEdit = QtWidgets.QTextEdit(parent=self.groupBox)
        self.textEdit.setObjectName("textEdit")
        self.gridLayout_2.addWidget(self.textEdit, 2, 0, 1, 1)
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.toolButton_12 = QtWidgets.QToolButton(parent=self.groupBox)
        self.toolButton_12.setIcon(icon)
        self.toolButton_12.setIconSize(QtCore.QSize(30, 30))
        self.toolButton_12.setObjectName("toolButton_12")
        self.horizontalLayout_2.addWidget(self.toolButton_12)
        self.toolButton_11 = QtWidgets.QToolButton(parent=self.groupBox)
        self.toolButton_11.setIcon(icon1)
        self.toolButton_11.setIconSize(QtCore.QSize(30, 30))
        self.toolButton_11.setObjectName("toolButton_11")
        self.horizontalLayout_2.addWidget(self.toolButton_11)
        self.toolButton_10 = QtWidgets.QToolButton(parent=self.groupBox)
        self.toolButton_10.setIcon(icon2)
        self.toolButton_10.setIconSize(QtCore.QSize(30, 30))
        self.toolButton_10.setObjectName("toolButton_10")
        self.horizontalLayout_2.addWidget(self.toolButton_10)
        self.toolButton_9 = QtWidgets.QToolButton(parent=self.groupBox)
        self.toolButton_9.setIcon(icon3)
        self.toolButton_9.setIconSize(QtCore.QSize(30, 30))
        self.toolButton_9.setObjectName("toolButton_9")
        self.horizontalLayout_2.addWidget(self.toolButton_9)
        self.toolButton_8 = QtWidgets.QToolButton(parent=self.groupBox)
        icon5 = QtGui.QIcon()
        icon5.addPixmap(QtGui.QPixmap("../../icon/format_list_numbered_30dp_999999_FILL0_wght400_GRAD0_opsz24.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
        self.toolButton_8.setIcon(icon5)
        self.toolButton_8.setIconSize(QtCore.QSize(30, 30))
        self.toolButton_8.setObjectName("toolButton_8")
        self.horizontalLayout_2.addWidget(self.toolButton_8)
        self.toolButton_7 = QtWidgets.QToolButton(parent=self.groupBox)
        icon6 = QtGui.QIcon()
        icon6.addPixmap(QtGui.QPixmap("../../icon/format_list_bulleted_30dp_999999_FILL0_wght400_GRAD0_opsz24.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
        self.toolButton_7.setIcon(icon6)
        self.toolButton_7.setIconSize(QtCore.QSize(30, 30))
        self.toolButton_7.setObjectName("toolButton_7")
        self.horizontalLayout_2.addWidget(self.toolButton_7)
        self.toolButton_6 = QtWidgets.QToolButton(parent=self.groupBox)
        self.toolButton_6.setIcon(icon4)
        self.toolButton_6.setIconSize(QtCore.QSize(30, 30))
        self.toolButton_6.setObjectName("toolButton_6")
        self.horizontalLayout_2.addWidget(self.toolButton_6)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Policy.Expanding, QtWidgets.QSizePolicy.Policy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem1)
        self.gridLayout_2.addLayout(self.horizontalLayout_2, 3, 0, 1, 1)
        self.gridLayout.addWidget(self.groupBox, 0, 0, 1, 1)
        spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Policy.Minimum, QtWidgets.QSizePolicy.Policy.Expanding)
        self.gridLayout.addItem(spacerItem2, 1, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(parent=MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 22))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(parent=MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.lineEdit.setPlaceholderText(_translate("MainWindow", "Новая форма"))
        self.toolButton_2.setText(_translate("MainWindow", "..."))
        self.toolButton_4.setText(_translate("MainWindow", "..."))
        self.toolButton_3.setText(_translate("MainWindow", "..."))
        self.toolButton_5.setText(_translate("MainWindow", "..."))
        self.toolButton.setText(_translate("MainWindow", "..."))
        self.textEdit.setPlaceholderText(_translate("MainWindow", "Описание"))
        self.toolButton_12.setText(_translate("MainWindow", "..."))
        self.toolButton_11.setText(_translate("MainWindow", "..."))
        self.toolButton_10.setText(_translate("MainWindow", "..."))
        self.toolButton_9.setText(_translate("MainWindow", "..."))
        self.toolButton_8.setText(_translate("MainWindow", "..."))
        self.toolButton_7.setText(_translate("MainWindow", "..."))
        self.toolButton_6.setText(_translate("MainWindow", "..."))
python
  • 1 个回答
  • 46 Views
Martin Hope
dynamic.aerospace.inc
Asked: 2024-10-26 02:47:42 +0000 UTC

编译 NASM 汇编代码时出错

  • 6

我用 NASM 汇编器编写了一个简单的程序:

global _start       ; делаем метку метку _start видимой извне
 
section .text       ; объявление секции кода
_start:             ; метка _start - точка входа в программу
    mov rax, 40     ; произвольный код возврата - 40
    ret             ; выход из программы

接下来,我通过编写命令创建了一个目标文件:

nasm -f win64 hello.asm -o hello.o

然后,在应用程序下打开Native Tools Command Prompt for VS 2022,我写下以下命令来创建可执行文件:

link hello.o /entry:_start /subsystem:console /out:hello2.exe

我收到错误:

Microsoft (R) Incremental Linker Version 14.42.34321.1
Copyright (C) Microsoft Corporation.  All rights reserved.

LINK : error LNK2001: неразрешенный внешний символ _start.
hello2.exe : fatal error LNK1120: неразрешенных внешних элементов: 1

如何修复它?

windows
  • 1 个回答
  • 18 Views
Martin Hope
dynamic.aerospace.inc
Asked: 2024-10-19 18:47:10 +0000 UTC

如何在 Python 中创建公式生成器?

  • 5

在开发下一个项目时,需要将大量公式引入到Python.事实证明,在程序的实现过程中,非常不方便且难以阅读。因此,我决定创建一个构造函数来引入和使用与标准工具包中类似的公式Word,但这样在编写这样一个可视化公式后,程序会将其转换为代码Python。

这项任务非常广泛,我不知道如何处理它,您能否推荐可以帮助编写这样的程序的库、模块、文章或其他材料。 在此输入图像描述

python
  • 1 个回答
  • 62 Views
Martin Hope
dynamic.aerospace.inc
Asked: 2024-10-12 16:30:41 +0000 UTC

C++中计算exp的代码中的错误

  • 3

我编写了代码来计算该函数exp,但该代码无法正常工作。程序的结果正好是一半大,我该如何解决这个问题?

#include <iostream>

int factorial(int number);
float exp();

void main() {
    std::cout << exp() << std::endl;
}

float exp() {
    int x;
    float result = 1.0;
    std::cout << "Enter x: ";
    std::cin >> x;

    for (int i = 1; i <= x; ++i) {
        result += std::pow(x, i) / factorial(i);
    }
    return result;
}

int factorial(int number) {
    int result = 1;
    for (int i = 1; i <= number; ++i) {
        result *= i;
    }
    return result;
}
c++
  • 1 个回答
  • 43 Views
Martin Hope
dynamic.aerospace.inc
Asked: 2024-10-06 06:56:30 +0000 UTC

Python 函数中的私有变量

  • 6

我使用Vernam 的代码编写了加密和解密字符串的代码。该代码工作正常,并将字符串转换为加密字符串,反之亦然。但是有一个小问题,由于主要变量被设为私有,我无法将它们添加为函数中的标准参数,我该怎么做? (下面的例子)

程序代码:

import string
import random


class Cipher:
    __encryption_key = ""
    __user_data = ""

    @staticmethod
    def add_string(user_data) -> None:
        Cipher.__user_data = user_data

    @staticmethod
    def clear_user_data():
        del Cipher.__user_data

    @staticmethod
    def generate_encryption_key(length_key=32) -> str:
        Cipher.__encryption_key = "".join("".join(random.choices(string.ascii_letters, k=length_key)))
        return Cipher.__encryption_key

    @staticmethod
    def clear_encryption_key():
        del Cipher.__encryption_key

    @staticmethod
    def encrypt_user_string() -> str:
        encrypt_user_string = "".join(chr(ord(p) ^ ord(k)) for p, k in zip(Cipher.__user_data,
                                                                           Cipher.__encryption_key))
        return encrypt_user_string

    @staticmethod
    def decrypt_user_string(encryption_data: str, encryption_key: str) -> str:
        decrypt_user_string = "".join(chr(ord(c) ^ ord(k)) for c, k in zip(encryption_data, encryption_key))
        return decrypt_user_string

现在是这样的:

@staticmethod
    def decrypt_user_string(encryption_data: str, encryption_key: str) -> str:
        decrypt_user_string = "".join(chr(ord(c) ^ ord(k)) for c, k in zip(encryption_data, encryption_key))
        return decrypt_user_string

你需要这样的东西:

 @staticmethod
    def decrypt_user_string(encryption_data=encrypt_user_string(), encryption_key: Cipher.__encryption_key) -> str:
        decrypt_user_string = "".join(chr(ord(c) ^ ord(k)) for c, k in zip(encryption_data, encryption_key))

如何做到这一点?检查程序运行情况的代码:

from vernam_cipher import Cipher


if __name__ == "__main__":
    user_data = "Привет, мир!"

    cipher = Cipher()
    encryption_key = cipher.generate_encryption_key()
    print(f"Ключ шифрования данных: {encryption_key}")

    cipher.add_string(user_data)

    print(f"Данные: {cipher._Cipher__user_data}")

    encrypt_user_string = cipher.encrypt_user_string()
    print(f"Зашифрованные данные: {encrypt_user_string}")
    decrypt_user_string = cipher.decrypt_user_string(encrypt_user_string, encryption_key)
    print(f"Расшифрованные данные: {decrypt_user_string}")

        return decrypt_user_string
python
  • 1 个回答
  • 43 Views
Martin Hope
dynamic.aerospace.inc
Asked: 2024-09-28 05:37:49 +0000 UTC

从Python中的列表获取值时出错

  • 5

我正在编写代码将数据加载到YAML文件中,我编写了一个将加载数据的类。但我遇到了这个错误:

Traceback (most recent call last):
  File "D:\Projects\ProjectsProgramming\PyCharmCommunity\OST\src\quiz\task_settings.py", line 36, in save_task_settings
    self.quiz_activated()
  File "D:\Projects\ProjectsProgramming\PyCharmCommunity\OST\src\quiz\task_settings.py", line 30, in quiz_activated
    self.result.save_exam_result()
  File "D:\Projects\ProjectsProgramming\PyCharmCommunity\OST\src\quiz\exam_result.py", line 18, in save_exam_result
    name_settings_file = self.exam_result[0]["Series"] + self.exam_result[0]["Number"]
                         ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
KeyError: 'Series'

代码:

from pathlib import Path
import yaml


class Result:
    def __init__(self):
        super().__init__()
        self.exam_result = []

    def add_data(self, data):
        self.exam_result.append(data)

    @staticmethod
    def get_root_dir():
        return Path(__file__).absolute().parent

    def save_exam_result(self) -> None:
        name_settings_file = self.exam_result[0]["Series"] + self.exam_result[0]["Number"]
        print(name_settings_file)
        with open((self.get_root_dir() / "exam").joinpath(name_settings_file + ".yaml"), "w") as outfile:
            new_dump = yaml.dump(self.exam_result)
            outfile.write(new_dump)
        return None

作为输入提供的列表的示例:

[{'CodeEducationalOrganization': 'gfdgd', 'PPECode': 'gdfg', 'NumberPC': 'dgd', 'NumberOption': 'gdgd', 'SettingsOption': '[Без дополнений]', 'CodeActivation': 'gdg'}]

如何修复这个错误?

python
  • 1 个回答
  • 34 Views
Martin Hope
dynamic.aerospace.inc
Asked: 2024-09-22 04:50:16 +0000 UTC

如何实现窗口之间的转换,保存前两个窗口中输入的数据以便在第三个主窗口中进一步使用?

  • 6

我想在一个文件__init__.py中创建一个列表,该列表需要接受来自其他两个文件的数据。

该文件首先__init__.py启动第一个文件,用户在其中输入一些数据。
然后他单击“继续”,第一个窗口关闭,然后打开一个新窗口,他在其中执行相同的操作,但是单击“开始”按钮后,第二个窗口关闭,并且在文件中__init__.py有一个列表由先前输入到这两个窗口的数据组成。

我已经将数据收集实现为LineEdit数组,但我不知道如何将它们组合起来并将它们传输到初始文件?

如何实施?

授权.py:

import sys

from PyQt6.QtWidgets import QApplication, QMainWindow

from src.ui.py.OST_authorization import Ui_OST_authorization


class Authorization(QMainWindow):
    def __init__(self):
        super().__init__()

        self.ui = Ui_OST_authorization()
        self.ui.setupUi(self)

        self.ui.Continue.clicked.connect(self.student_data)
        self.show()

    def student_data(self) -> dict:
        return {"Имя": self.ui.Name.text(), "Фамилия": self.ui.Surname.text(), "Отчество": self.ui.Patronymic.text(),
                "Номер и буква класса": self.ui.Class.text(), "Серия": self.ui.Series.text(),
                "Номер": self.ui.Number.text()}


if __name__ == "__main__":
    app = QApplication(sys.argv)
    authorization_window = Authorization()
    sys.exit(app.exec())

OST_authorization.py:

from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_OST_authorization(object):
    def setupUi(self, OST_authorization):
        OST_authorization.setObjectName("OST_authorization")
        OST_authorization.resize(330, 381)
        OST_authorization.setMinimumSize(QtCore.QSize(330, 381))
        OST_authorization.setMaximumSize(QtCore.QSize(330, 395))
        OST_authorization.setStyleSheet("QLineEdit#Name{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#Surname{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#Patronymic{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#Class{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#Series{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#Number{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QPushButton#Continue{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"")
        OST_authorization.setDocumentMode(True)
        self.centralwidget = QtWidgets.QWidget(parent=OST_authorization)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.Name = QtWidgets.QLineEdit(parent=self.centralwidget)
        self.Name.setEnabled(True)
        self.Name.setMinimumSize(QtCore.QSize(312, 35))
        self.Name.setMaximumSize(QtCore.QSize(312, 35))
        self.Name.setStyleSheet("")
        self.Name.setObjectName("Name")
        self.gridLayout.addWidget(self.Name, 5, 0, 1, 2)
        self.AuthorizationLable = QtWidgets.QLabel(parent=self.centralwidget)
        self.AuthorizationLable.setObjectName("AuthorizationLable")
        self.gridLayout.addWidget(self.AuthorizationLable, 4, 0, 1, 2)
        self.line = QtWidgets.QFrame(parent=self.centralwidget)
        self.line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
        self.line.setObjectName("line")
        self.gridLayout.addWidget(self.line, 8, 0, 1, 2)
        self.Class = QtWidgets.QLineEdit(parent=self.centralwidget)
        self.Class.setMinimumSize(QtCore.QSize(312, 35))
        self.Class.setMaximumSize(QtCore.QSize(312, 35))
        self.Class.setObjectName("Class")
        self.gridLayout.addWidget(self.Class, 9, 0, 1, 2)
        self.line_2 = QtWidgets.QFrame(parent=self.centralwidget)
        self.line_2.setFrameShape(QtWidgets.QFrame.Shape.HLine)
        self.line_2.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
        self.line_2.setObjectName("line_2")
        self.gridLayout.addWidget(self.line_2, 10, 0, 1, 2)
        self.Series = QtWidgets.QLineEdit(parent=self.centralwidget)
        self.Series.setMinimumSize(QtCore.QSize(312, 35))
        self.Series.setMaximumSize(QtCore.QSize(312, 35))
        self.Series.setObjectName("Series")
        self.gridLayout.addWidget(self.Series, 11, 0, 1, 2)
        self.Continue = QtWidgets.QPushButton(parent=self.centralwidget)
        self.Continue.setMinimumSize(QtCore.QSize(312, 35))
        self.Continue.setMaximumSize(QtCore.QSize(312, 35))
        self.Continue.setObjectName("Continue")
        self.gridLayout.addWidget(self.Continue, 14, 0, 1, 2)
        self.line_3 = QtWidgets.QFrame(parent=self.centralwidget)
        self.line_3.setFrameShape(QtWidgets.QFrame.Shape.HLine)
        self.line_3.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
        self.line_3.setObjectName("line_3")
        self.gridLayout.addWidget(self.line_3, 13, 0, 1, 2)
        self.Patronymic = QtWidgets.QLineEdit(parent=self.centralwidget)
        self.Patronymic.setMinimumSize(QtCore.QSize(312, 35))
        self.Patronymic.setMaximumSize(QtCore.QSize(312, 35))
        self.Patronymic.setObjectName("Patronymic")
        self.gridLayout.addWidget(self.Patronymic, 7, 0, 1, 2)
        self.Surname = QtWidgets.QLineEdit(parent=self.centralwidget)
        self.Surname.setMinimumSize(QtCore.QSize(312, 35))
        self.Surname.setMaximumSize(QtCore.QSize(312, 35))
        self.Surname.setObjectName("Surname")
        self.gridLayout.addWidget(self.Surname, 6, 0, 1, 2)
        self.Number = QtWidgets.QLineEdit(parent=self.centralwidget)
        self.Number.setMinimumSize(QtCore.QSize(312, 35))
        self.Number.setMaximumSize(QtCore.QSize(312, 35))
        self.Number.setObjectName("Number")
        self.gridLayout.addWidget(self.Number, 12, 0, 1, 2)
        OST_authorization.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(parent=OST_authorization)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 330, 22))
        self.menubar.setObjectName("menubar")
        OST_authorization.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(parent=OST_authorization)
        self.statusbar.setObjectName("statusbar")
        OST_authorization.setStatusBar(self.statusbar)

        self.retranslateUi(OST_authorization)
        QtCore.QMetaObject.connectSlotsByName(OST_authorization)

    def retranslateUi(self, OST_authorization):
        _translate = QtCore.QCoreApplication.translate
        OST_authorization.setWindowTitle(_translate("OST_authorization", "OST - (демо версия)"))
        self.Name.setPlaceholderText(_translate("OST_authorization", "Имя"))
        self.AuthorizationLable.setText(_translate("OST_authorization", "<html><head/><body><p><span style=\" font-size:12pt;\">Авторизация</span></p></body></html>"))
        self.Class.setPlaceholderText(_translate("OST_authorization", "Номер и буква класса"))
        self.Series.setPlaceholderText(_translate("OST_authorization", "Серия"))
        self.Continue.setText(_translate("OST_authorization", "Продолжить"))
        self.Patronymic.setPlaceholderText(_translate("OST_authorization", "Отчество (при наличии)"))
        self.Surname.setPlaceholderText(_translate("OST_authorization", "Фамилия"))
        self.Number.setPlaceholderText(_translate("OST_authorization", "Номер"))

任务设置.py:

import sys

from PyQt6.QtWidgets import QApplication, QMainWindow

from src.ui.py.OST_task_settings import Ui_OST_task_settings


class TaskSettings(QMainWindow):
    def __init__(self):
        super().__init__()

        self.ui = Ui_OST_task_settings()
        self.ui.setupUi(self)

        self.ui.Start.clicked.connect(self.settings_data)

        self.show()

    def settings_data(self) -> dict:
        return {"Код образовательной организации": self.ui.CodeEducationalOrganization.text(),
                "Код ППЭ": self.ui.PPECode.text(), "Номер компьютера": self.ui.NumberPC.text(),
                "Номер варианта": self.ui.NumberPC.text(), "Код активации": self.ui.CodeActivation.text()}


if __name__ == "__main__":
    app = QApplication(sys.argv)
    task_settings_window = TaskSettings()
    sys.exit(app.exec())

OST_task_settings.py:

from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_OST_task_settings(object):
    def setupUi(self, OST_task_settings):
        OST_task_settings.setObjectName("OST_task_settings")
        OST_task_settings.resize(330, 381)
        OST_task_settings.setMinimumSize(QtCore.QSize(330, 381))
        OST_task_settings.setMaximumSize(QtCore.QSize(330, 395))
        OST_task_settings.setStyleSheet("QLineEdit#NumberOption{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QComboBox#SettingsOption{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#CodeActivation{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#CodeEducationalOrganization{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#NumberPC{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#PPECode{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QPushButton#Start{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}")
        OST_task_settings.setDocumentMode(True)
        self.centralwidget = QtWidgets.QWidget(parent=OST_task_settings)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.Start = QtWidgets.QPushButton(parent=self.centralwidget)
        self.Start.setMinimumSize(QtCore.QSize(312, 35))
        self.Start.setMaximumSize(QtCore.QSize(312, 35))
        self.Start.setObjectName("Start")
        self.gridLayout.addWidget(self.Start, 10, 0, 1, 1)
        self.line_2 = QtWidgets.QFrame(parent=self.centralwidget)
        self.line_2.setFrameShape(QtWidgets.QFrame.Shape.HLine)
        self.line_2.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
        self.line_2.setObjectName("line_2")
        self.gridLayout.addWidget(self.line_2, 9, 0, 1, 1)
        self.line = QtWidgets.QFrame(parent=self.centralwidget)
        self.line.setFrameShape(QtWidgets.QFrame.Shape.HLine)
        self.line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
        self.line.setObjectName("line")
        self.gridLayout.addWidget(self.line, 7, 0, 1, 1)
        self.NumberOption = QtWidgets.QLineEdit(parent=self.centralwidget)
        self.NumberOption.setMinimumSize(QtCore.QSize(312, 35))
        self.NumberOption.setMaximumSize(QtCore.QSize(312, 35))
        self.NumberOption.setObjectName("NumberOption")
        self.gridLayout.addWidget(self.NumberOption, 5, 0, 1, 1)
        self.line_3 = QtWidgets.QFrame(parent=self.centralwidget)
        self.line_3.setFrameShape(QtWidgets.QFrame.Shape.HLine)
        self.line_3.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken)
        self.line_3.setObjectName("line_3")
        self.gridLayout.addWidget(self.line_3, 4, 0, 1, 1)
        self.CodeActivation = QtWidgets.QLineEdit(parent=self.centralwidget)
        self.CodeActivation.setMinimumSize(QtCore.QSize(312, 35))
        self.CodeActivation.setMaximumSize(QtCore.QSize(312, 35))
        self.CodeActivation.setObjectName("CodeActivation")
        self.gridLayout.addWidget(self.CodeActivation, 8, 0, 1, 1)
        self.SettingsOption = QtWidgets.QComboBox(parent=self.centralwidget)
        self.SettingsOption.setMinimumSize(QtCore.QSize(312, 35))
        self.SettingsOption.setMaximumSize(QtCore.QSize(312, 35))
        self.SettingsOption.setObjectName("SettingsOption")
        self.SettingsOption.addItem("")
        self.SettingsOption.addItem("")
        self.SettingsOption.addItem("")
        self.gridLayout.addWidget(self.SettingsOption, 6, 0, 1, 1)
        self.PPECode = QtWidgets.QLineEdit(parent=self.centralwidget)
        self.PPECode.setMinimumSize(QtCore.QSize(312, 35))
        self.PPECode.setMaximumSize(QtCore.QSize(312, 35))
        self.PPECode.setObjectName("PPECode")
        self.gridLayout.addWidget(self.PPECode, 2, 0, 1, 1)
        self.label = QtWidgets.QLabel(parent=self.centralwidget)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 0, 0, 1, 1)
        self.NumberPC = QtWidgets.QLineEdit(parent=self.centralwidget)
        self.NumberPC.setMinimumSize(QtCore.QSize(312, 35))
        self.NumberPC.setMaximumSize(QtCore.QSize(312, 35))
        self.NumberPC.setObjectName("NumberPC")
        self.gridLayout.addWidget(self.NumberPC, 3, 0, 1, 1)
        self.CodeEducationalOrganization = QtWidgets.QLineEdit(parent=self.centralwidget)
        self.CodeEducationalOrganization.setMinimumSize(QtCore.QSize(312, 35))
        self.CodeEducationalOrganization.setMaximumSize(QtCore.QSize(312, 35))
        self.CodeEducationalOrganization.setObjectName("CodeEducationalOrganization")
        self.gridLayout.addWidget(self.CodeEducationalOrganization, 1, 0, 1, 1)
        OST_task_settings.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(parent=OST_task_settings)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 330, 22))
        self.menubar.setObjectName("menubar")
        OST_task_settings.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(parent=OST_task_settings)
        self.statusbar.setObjectName("statusbar")
        OST_task_settings.setStatusBar(self.statusbar)

        self.retranslateUi(OST_task_settings)
        QtCore.QMetaObject.connectSlotsByName(OST_task_settings)

    def retranslateUi(self, OST_task_settings):
        _translate = QtCore.QCoreApplication.translate
        OST_task_settings.setWindowTitle(_translate("OST_task_settings", "OST - (демо версия)"))
        self.Start.setText(_translate("OST_task_settings", "Начать"))
        self.NumberOption.setPlaceholderText(_translate("OST_task_settings", "Номер варианта"))
        self.CodeActivation.setPlaceholderText(_translate("OST_task_settings", "Код активации"))
        self.SettingsOption.setItemText(0, _translate("OST_task_settings", "[Без дополнений]"))
        self.SettingsOption.setItemText(1, _translate("OST_task_settings", "Случайный вариант"))
        self.SettingsOption.setItemText(2, _translate("OST_task_settings", "Составить вариант"))
        self.PPECode.setPlaceholderText(_translate("OST_task_settings", "Код ППЭ"))
        self.label.setText(_translate("OST_task_settings", "<html><head/><body><p><span style=\" font-size:12pt;\">Дополнительные данные</span></p></body></html>"))
        self.NumberPC.setPlaceholderText(_translate("OST_task_settings", "Номер компьютера"))
        self.CodeEducationalOrganization.setPlaceholderText(_translate("OST_task_settings", "Код образовательной организации"))
python
  • 1 个回答
  • 29 Views
Martin Hope
dynamic.aerospace.inc
Asked: 2024-09-21 16:46:06 +0000 UTC

启动在 Qt Designer 中编译的窗口时出错

  • 6

我在 中创建了应用程序布局Qt Designer,配置了所有参数并Python使用以下命令将其转换为代码:

from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
    QMetaObject, QObject, QPoint, QRect,
    QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
    QFont, QFontDatabase, QGradient, QIcon,
    QImage, QKeySequence, QLinearGradient, QPainter,
    QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QFrame, QGridLayout, QLabel,
    QLineEdit, QMainWindow, QMenuBar, QPushButton,
    QSizePolicy, QStatusBar, QWidget)

class Ui_OST_authorization(object):
    def setupUi(self, OST_authorization):
        if not OST_authorization.objectName():
            OST_authorization.setObjectName(u"OST_authorization")
        OST_authorization.resize(330, 381)
        OST_authorization.setMinimumSize(QSize(330, 381))
        OST_authorization.setMaximumSize(QSize(330, 395))
        OST_authorization.setStyleSheet(u"QLineEdit#Name{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#Surname{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#Patronymic{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#Class{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#Series{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QLineEdit#Number{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"QPushButton#Continue{\n"
"    min-width:  310px;\n"
"    min-height: 33px;\n"
"    max-width:  310px;\n"
"    max-height: 33px;\n"
"}\n"
"")
        OST_authorization.setDocumentMode(True)
        self.centralwidget = QWidget(OST_authorization)
        self.centralwidget.setObjectName(u"centralwidget")
        self.gridLayout = QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName(u"gridLayout")
        self.Name = QLineEdit(self.centralwidget)
        self.Name.setObjectName(u"Name")
        self.Name.setEnabled(True)
        self.Name.setMinimumSize(QSize(312, 35))
        self.Name.setMaximumSize(QSize(312, 35))
        self.Name.setStyleSheet(u"")

        self.gridLayout.addWidget(self.Name, 5, 0, 1, 2)

        self.AuthorizationLable = QLabel(self.centralwidget)
        self.AuthorizationLable.setObjectName(u"AuthorizationLable")

        self.gridLayout.addWidget(self.AuthorizationLable, 4, 0, 1, 2)

        self.line = QFrame(self.centralwidget)
        self.line.setObjectName(u"line")
        self.line.setFrameShape(QFrame.Shape.HLine)
        self.line.setFrameShadow(QFrame.Shadow.Sunken)

        self.gridLayout.addWidget(self.line, 8, 0, 1, 2)

        self.Class = QLineEdit(self.centralwidget)
        self.Class.setObjectName(u"Class")
        self.Class.setMinimumSize(QSize(312, 35))
        self.Class.setMaximumSize(QSize(312, 35))

        self.gridLayout.addWidget(self.Class, 9, 0, 1, 2)

        self.line_2 = QFrame(self.centralwidget)
        self.line_2.setObjectName(u"line_2")
        self.line_2.setFrameShape(QFrame.Shape.HLine)
        self.line_2.setFrameShadow(QFrame.Shadow.Sunken)

        self.gridLayout.addWidget(self.line_2, 10, 0, 1, 2)

        self.Series = QLineEdit(self.centralwidget)
        self.Series.setObjectName(u"Series")
        self.Series.setMinimumSize(QSize(312, 35))
        self.Series.setMaximumSize(QSize(312, 35))

        self.gridLayout.addWidget(self.Series, 11, 0, 1, 2)

        self.Continue = QPushButton(self.centralwidget)
        self.Continue.setObjectName(u"Continue")
        self.Continue.setMinimumSize(QSize(312, 35))
        self.Continue.setMaximumSize(QSize(312, 35))

        self.gridLayout.addWidget(self.Continue, 14, 0, 1, 2)

        self.line_3 = QFrame(self.centralwidget)
        self.line_3.setObjectName(u"line_3")
        self.line_3.setFrameShape(QFrame.Shape.HLine)
        self.line_3.setFrameShadow(QFrame.Shadow.Sunken)

        self.gridLayout.addWidget(self.line_3, 13, 0, 1, 2)

        self.Patronymic = QLineEdit(self.centralwidget)
        self.Patronymic.setObjectName(u"Patronymic")
        self.Patronymic.setMinimumSize(QSize(312, 35))
        self.Patronymic.setMaximumSize(QSize(312, 35))

        self.gridLayout.addWidget(self.Patronymic, 7, 0, 1, 2)

        self.Surname = QLineEdit(self.centralwidget)
        self.Surname.setObjectName(u"Surname")
        self.Surname.setMinimumSize(QSize(312, 35))
        self.Surname.setMaximumSize(QSize(312, 35))

        self.gridLayout.addWidget(self.Surname, 6, 0, 1, 2)

        self.Number = QLineEdit(self.centralwidget)
        self.Number.setObjectName(u"Number")
        self.Number.setMinimumSize(QSize(312, 35))
        self.Number.setMaximumSize(QSize(312, 35))

        self.gridLayout.addWidget(self.Number, 12, 0, 1, 2)

        OST_authorization.setCentralWidget(self.centralwidget)
        self.menubar = QMenuBar(OST_authorization)
        self.menubar.setObjectName(u"menubar")
        self.menubar.setGeometry(QRect(0, 0, 330, 22))
        OST_authorization.setMenuBar(self.menubar)
        self.statusbar = QStatusBar(OST_authorization)
        self.statusbar.setObjectName(u"statusbar")
        OST_authorization.setStatusBar(self.statusbar)

        self.retranslateUi(OST_authorization)

        QMetaObject.connectSlotsByName(OST_authorization)
    # setupUi

    def retranslateUi(self, OST_authorization):
        OST_authorization.setWindowTitle(QCoreApplication.translate("OST_authorization", u"OST - (\u0434\u0435\u043c\u043e \u0432\u0435\u0440\u0441\u0438\u044f)", None))
        self.Name.setPlaceholderText(QCoreApplication.translate("OST_authorization", u"\u0418\u043c\u044f", None))
        self.AuthorizationLable.setText(QCoreApplication.translate("OST_authorization", u"<html><head/><body><p><span style=\" font-size:12pt;\">\u0410\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f</span></p></body></html>", None))
        self.Class.setPlaceholderText(QCoreApplication.translate("OST_authorization", u"\u041d\u043e\u043c\u0435\u0440 \u0438 \u0431\u0443\u043a\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430", None))
        self.Series.setPlaceholderText(QCoreApplication.translate("OST_authorization", u"\u0421\u0435\u0440\u0438\u044f", None))
        self.Continue.setText(QCoreApplication.translate("OST_authorization", u"\u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c", None))
        self.Patronymic.setPlaceholderText(QCoreApplication.translate("OST_authorization", u"\u041e\u0442\u0447\u0435\u0441\u0442\u0432\u043e (\u043f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438)", None))
        self.Surname.setPlaceholderText(QCoreApplication.translate("OST_authorization", u"\u0424\u0430\u043c\u0438\u043b\u0438\u044f", None))
        self.Number.setPlaceholderText(QCoreApplication.translate("OST_authorization", u"\u041d\u043e\u043c\u0435\u0440", None))
    # retranslateUi

我创建了一个文件来运行该程序,但遇到了错误:

Traceback (most recent call last):
  File "D:\Projects\ProjectsProgramming\PyCharmCommunity\OST\src\quiz\authorization.py", line 20, in <module>
    authorization_window = Authorization()
                           ^^^^^^^^^^^^^^^
  File "D:\Projects\ProjectsProgramming\PyCharmCommunity\OST\src\quiz\authorization.py", line 13, in __init__
    self.ui.setupUi(self)
  File "D:\Projects\ProjectsProgramming\PyCharmCommunity\OST\src\ui\py\OST_authorization.py", line 27, in setupUi
    OST_authorization.setMinimumSize(QSize(330, 381))
TypeError: arguments did not match any overloaded call:
  setMinimumSize(self, minw: int, minh: int): argument 1 has unexpected type 'PySide6.QtCore.QSize'
  setMinimumSize(self, s: QSize): argument 1 has unexpected type 'PySide6.QtCore.QSize'

Process finished with exit code 1

要运行的文件代码:

import sys

from PyQt6.QtWidgets import QApplication, QWidget

from src.ui.py.OST_authorization import Ui_OST_authorization


class Authorization(QWidget):
    def __init__(self):
        super().__init__()

        self.ui = Ui_OST_authorization()
        self.ui.setupUi(self)

        self.show()


if __name__ == "__main__":
    app = QApplication(sys.argv)
    authorization_window = Authorization()
    sys.exit(app.exec())

我假设您需要添加一些模块,但是哪些模块以及如何修复代码?

python
  • 1 个回答
  • 20 Views
Martin Hope
dynamic.aerospace.inc
Asked: 2024-09-19 04:09:02 +0000 UTC

如何确定哪个浏览器正在运行以及哪些选项卡打开?

  • 5

我想制作一个将启动的代码,当打开常用的浏览器(Yandex、Chrome、Age)时,它会通知这一点。我还想知道哪些选项卡被打开和关闭。是否可以做到这一点以及我应该朝什么方向挖掘?

python
  • 1 个回答
  • 55 Views
Martin Hope
dynamic.aerospace.inc
Asked: 2024-09-07 04:13:52 +0000 UTC

如何按特定顺序运行Python类中的所有函数?

  • 5

有一段写好的代码Python,由一个类和一些函数组成,你需要一一运行这个类的所有函数,但是怎么做呢?

class Foo:
    def one(self):
        print("one")
    
    def two(self):
        print("two")
    
    ...
python
  • 1 个回答
  • 22 Views
Martin Hope
dynamic.aerospace.inc
Asked: 2024-08-30 23:27:32 +0000 UTC

在 Qt-Designer 中创建活动文件面板

  • 5

不久前,我在编写程序时开始学习PyQt,并面临一个问题:
如何制作活动文件或项目的列表?

当您打开PyCharm、Sublime Text甚至Notepad时,您可以在顶部看到当前打开工作的文件列表。
是否可以使用PyQt来实现这一点?如果可以,如何实现?

小部件示例

这样的小部件应该打开、关闭和显示其内部的任何程序元素


更新:

我们目前拥有的:

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <author>Dynamic Software, Dynamic Aerospace</author>
 <class>IIC</class>
 <widget class="QMainWindow" name="IIC">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>640</width>
    <height>480</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>IIC - (демо версия)</string>
  </property>
  <widget class="QWidget" name="centralwidget"/>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>640</width>
     <height>22</height>
    </rect>
   </property>
   <widget class="QMenu" name="File">
    <property name="title">
     <string>Файл</string>
    </property>
    <addaction name="New"/>
    <addaction name="Open"/>
    <addaction name="RecentFile"/>
    <addaction name="separator"/>
    <addaction name="Close"/>
    <addaction name="CloseAll"/>
    <addaction name="separator"/>
    <addaction name="Save"/>
    <addaction name="SaveAs"/>
    <addaction name="Export"/>
    <addaction name="separator"/>
    <addaction name="Preview"/>
    <addaction name="Print"/>
    <addaction name="separator"/>
    <addaction name="Send"/>
    <addaction name="separator"/>
    <addaction name="InformationDocument"/>
    <addaction name="separator"/>
    <addaction name="Exit"/>
   </widget>
   <widget class="QMenu" name="Edit">
    <property name="title">
     <string>Правка</string>
    </property>
    <addaction name="Undo"/>
    <addaction name="Redo"/>
    <addaction name="separator"/>
    <addaction name="RepeatLastCommand"/>
    <addaction name="separator"/>
    <addaction name="Cut"/>
    <addaction name="Copy"/>
    <addaction name="Paste"/>
    <addaction name="Delete"/>
    <addaction name="separator"/>
    <addaction name="Scale"/>
   </widget>
   <widget class="QMenu" name="Settings">
    <property name="title">
     <string>Настройки</string>
    </property>
    <addaction name="RestoreLicenses"/>
    <addaction name="ReceiveLicensesIIC"/>
    <addaction name="separator"/>
    <addaction name="Parameters"/>
    <addaction name="LoadParameters"/>
    <addaction name="SaveParameters"/>
   </widget>
   <widget class="QMenu" name="Apps">
    <property name="title">
     <string>Приложения</string>
    </property>
    <addaction name="AddApps"/>
    <addaction name="Configurator"/>
   </widget>
   <widget class="QMenu" name="Window">
    <property name="title">
     <string>Окно</string>
    </property>
    <addaction name="CloseCurrentWindow"/>
   </widget>
   <widget class="QMenu" name="Help">
    <property name="title">
     <string>Справка</string>
    </property>
    <addaction name="Content"/>
    <addaction name="separator"/>
    <addaction name="TrainingMaterials"/>
    <addaction name="separator"/>
    <addaction name="IICOnInternet"/>
    <addaction name="separator"/>
    <addaction name="LicenseAgreement"/>
    <addaction name="AboutProgram"/>
   </widget>
   <widget class="QMenu" name="Decoration">
    <property name="title">
     <string>Оформление</string>
    </property>
    <addaction name="StyleLibrary"/>
    <addaction name="separator"/>
    <addaction name="CreateReport"/>
    <addaction name="EditTemplateReport"/>
    <addaction name="CreateTemplateReport"/>
   </widget>
   <widget class="QMenu" name="Analysis">
    <property name="title">
     <string>Анализ</string>
    </property>
    <addaction name="AnalysisInjector"/>
    <addaction name="OptimizationInjector"/>
    <addaction name="separator"/>
    <addaction name="CustomExpressions"/>
   </widget>
   <addaction name="File"/>
   <addaction name="Edit"/>
   <addaction name="Analysis"/>
   <addaction name="Decoration"/>
   <addaction name="Settings"/>
   <addaction name="Apps"/>
   <addaction name="Window"/>
   <addaction name="Help"/>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
  <action name="New">
   <property name="text">
    <string>Новый</string>
   </property>
  </action>
  <action name="Open">
   <property name="text">
    <string>Открыть</string>
   </property>
  </action>
  <action name="RecentFile">
   <property name="text">
    <string>Последние файлы</string>
   </property>
  </action>
  <action name="Save">
   <property name="text">
    <string>Сохранить</string>
   </property>
  </action>
  <action name="SaveAs">
   <property name="text">
    <string>Сохранить как</string>
   </property>
  </action>
  <action name="action_PDF">
   <property name="text">
    <string>.PDF</string>
   </property>
  </action>
  <action name="action_TXT">
   <property name="text">
    <string>.TXT</string>
   </property>
  </action>
  <action name="Export">
   <property name="text">
    <string>Экспортировать</string>
   </property>
  </action>
  <action name="Print">
   <property name="text">
    <string>Печать</string>
   </property>
  </action>
  <action name="Exit">
   <property name="text">
    <string>Выход</string>
   </property>
  </action>
  <action name="Undo">
   <property name="text">
    <string>Отменить</string>
   </property>
  </action>
  <action name="Redo">
   <property name="text">
    <string>Повторить</string>
   </property>
  </action>
  <action name="Cut">
   <property name="text">
    <string>Вырезать</string>
   </property>
  </action>
  <action name="Copy">
   <property name="text">
    <string>Копировать</string>
   </property>
  </action>
  <action name="Paste">
   <property name="text">
    <string>Вставить</string>
   </property>
  </action>
  <action name="action_6">
   <property name="text">
    <string>Дублировать</string>
   </property>
  </action>
  <action name="Delete">
   <property name="text">
    <string>Удалить</string>
   </property>
  </action>
  <action name="Scale">
   <property name="text">
    <string>Масштабировать</string>
   </property>
  </action>
  <action name="RestoreLicenses">
   <property name="text">
    <string>Восстановить лицензии</string>
   </property>
  </action>
  <action name="ReceiveLicensesIIC">
   <property name="text">
    <string>Получить лицензию на IIC</string>
   </property>
  </action>
  <action name="Parameters">
   <property name="text">
    <string>Параметры</string>
   </property>
  </action>
  <action name="LoadParameters">
   <property name="text">
    <string>Загрузить параметры</string>
   </property>
  </action>
  <action name="SaveParameters">
   <property name="text">
    <string>Сохранить параметры</string>
   </property>
  </action>
  <action name="AddApps">
   <property name="text">
    <string>Добавить приложение</string>
   </property>
  </action>
  <action name="Configurator">
   <property name="text">
    <string>Конфигуратор</string>
   </property>
  </action>
  <action name="CloseCurrentWindow">
   <property name="text">
    <string>Закрыть текущую вкладку</string>
   </property>
  </action>
  <action name="Content">
   <property name="text">
    <string>Содержание</string>
   </property>
  </action>
  <action name="TrainingMaterials">
   <property name="text">
    <string>Обучающие материалы</string>
   </property>
  </action>
  <action name="IICOnInternet">
   <property name="text">
    <string>IIC в интернете</string>
   </property>
  </action>
  <action name="LicenseAgreement">
   <property name="text">
    <string>Лицензионное соглашение</string>
   </property>
  </action>
  <action name="AboutProgram">
   <property name="text">
    <string>О программе</string>
   </property>
  </action>
  <action name="InformationDocument">
   <property name="text">
    <string>Информация о документе</string>
   </property>
  </action>
  <action name="Send">
   <property name="text">
    <string>Отправить</string>
   </property>
  </action>
  <action name="Close">
   <property name="text">
    <string>Закрыть</string>
   </property>
  </action>
  <action name="CloseAll">
   <property name="text">
    <string>Закрыть все документы</string>
   </property>
  </action>
  <action name="Preview">
   <property name="text">
    <string>Предварительный просмотр</string>
   </property>
  </action>
  <action name="RepeatLastCommand">
   <property name="text">
    <string>Повторить последнюю команду</string>
   </property>
  </action>
  <action name="StyleLibrary">
   <property name="text">
    <string>Библиотека стилей</string>
   </property>
  </action>
  <action name="CreateReport">
   <property name="text">
    <string>Создать отчет</string>
   </property>
  </action>
  <action name="EditTemplateReport">
   <property name="text">
    <string>Редактировать шаблон отчета</string>
   </property>
  </action>
  <action name="CreateTemplateReport">
   <property name="text">
    <string>Создать шаблон отчета</string>
   </property>
  </action>
  <action name="AnalysisInjector">
   <property name="text">
    <string>Анализ форсунки</string>
   </property>
  </action>
  <action name="OptimizationInjector">
   <property name="text">
    <string>Оптимизация форсунки</string>
   </property>
  </action>
  <action name="CustomExpressions">
   <property name="text">
    <string>Пользовательские выражения</string>
   </property>
  </action>
 </widget>
 <resources/>
 <connections/>
</ui>

为了清晰起见,截图:

在此输入图像描述

python
  • 1 个回答
  • 41 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5