0
I am making a program using as GUI the framework PyQt5, using UI files. I’m having trouble accessing the module inside the file .py that I create so that I put the functions inside them and thus better organize my program.
The function I want to call is char_1 that’s inside characters.py.
In the main program main.py I care for you this way from util.images.characters import checar, but in this way it returns me this error:
AttributeError: partially initialized module 'util.images.characters' has no attribute 'checar' (most likely due to a circular import)
Somehow, it can only access the function when it is inside the file __init__.py of the briefcase images.
I wanted to know, in order to organize my program, how I can access this function inside the file characters.py.
Below follows the codes "summarized" of the program.
OBS: actionAlbedo is the name of the QAction of QMenu of the archive ui/tela.ui.
main.py
from PyQt5 import uic, QtWidgets, QtGui
from util.images.characters import checar
app = QtWidgets.QApplication([])
tela = uic.loadUi('ui/tela.ui')
tela.actionAlbedo.triggered.connect(checar)
tela.show()
app.exec_()
characters.py
import main
from PyQt5 import QtGui
def checar():
main.tela.lb_background.setPixmap(QtGui.QPixmap('img/background/char_1.png'))
Grateful!


Alan, this way didn’t work. I tried another way. I deleted directory
imagesand created another python directory calledcharacters. In it, I put it in the file__init__.pythe code.main.pyplacedfrom util import characters. In charge I puttela.actionAlbedo.triggered.connect(characters.checar). But it still makes this mistake:AttributeError: partially initialized module 'util.characters' has no attribute 'mudar' (most likely due to a circular import). If you want to see the original is https://github.com/LucasRibeiroRJBR/genshin_app in the folderpyqt5. Thank you.– Lucas Ribeiro