Problem with QPushButton icons appearing PySide6

29 Views Asked by At

I am experiencing a problem with displaying button icons in the QDialog window. This problem occurs when trying to run the window from the main file, knowing that the QDialog window file is not in the same path as the main file.

This is the code to import the design from the __init__.py file inside WindowAdd

from PySide6.QtUiTools import QUiLoader
from PySide6.QtCore import QFile, QDate, Qt, QRect, QPropertyAnimation, QEasingCurve ,QTimer
from PySide6.QtWidgets import QApplication, QWidget, QTableWidgetItem, QPushButton, QDialog, QListWidgetItem, QCompleter
from PySide6 import QtGui, QtWidgets, QtCore
from .ui_Add_Item import Ui_Form
from Lib import database3
from datetime import datetime
from functools import partial
import random
import time
import os
import sys

class CustomListWidgetItem(QListWidgetItem):
    def __init__(self, text, hidden_data):
        super().__init__(text)
        self.hidden_data = hidden_data

class Widgets(QDialog, Ui_Form):
    def __init__(self, parent=None, page=""):
        super(Widgets, self).__init__(parent)
        self.setupUi(self)

if __name__ == "__main__":
    app = QApplication([])
    window = Widgets()
    window.show()
    app.exec()

I tried to execute a local code inside WindowAdd and the icons appeared very normally without the slightest problem, but when I exit to the main file the problem returns again.

These are the libraries and the most important codes used inside the main.py

from PySide6.QtUiTools import QUiLoader
from PySide6.QtCore import QFile, Qt
from PySide6.QtWidgets import QApplication, QWidget, QTableWidgetItem, QMenu, QGraphicsBlurEffect
from PySide6 import QtGui, QtWidgets, QtCore
from PySide6.QtGui import QBrush, QColor, QAction, QTextOption, QIcon
from ui_Style3 import Ui_Form
from WindowAdd import Widgets as WindowAdd2
from Lib import database3
from datetime import datetime
import random
import sys

class Widgets(QWidget,Ui_Form):
    def __init__(self):
        super(Widgets, self).__init__()
        self.setupUi(self)

        #Title window name and icon
        self.setWindowTitle("Business record")  #Name title
        self.setWindowIcon(QtGui.QIcon("path30.png")) #Icon title

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = Widgets()
    window.show()
    sys.exit(app.exec())

Just for your information, I use the design files from the Qt Designer program to download the ready-made design files. The main.py file and the __init__.py file are files to control the design files and execute instructions.

0

There are 0 best solutions below