I am unable to set Icon to my push button in my pyqt application when using with fbs. It doesn't give error no matter what path i give to QIcon function, due to which i am unable to figure out where i am going wrong
My Code
appctxt = ApplicationContext()
version = appctxt.build_settings["version"]
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Hellow World v" + version)
w = QWidget()
layout = QVBoxLayout()
btn = QPushButton("press")
btn.setIconSize(QSize(20, 20))
btn.setIcon(QIcon("../resources/256.png"))
layout.addWidget(btn)
w.setLayout(layout)
self.setCentralWidget(w)
if __name__ == '__main__':
window = MainWindow()
window.show()
exit_code = appctxt.app.exec_()
sys.exit(exit_code)
My File Structure
FBS already has a predefined structure that allows to obtain the resources either when the script is executed or after converting it to binary. This structure indicates that "resources" must have a "base" folder where the common files for all distributions are (similar to the "icons" folder), so in your case you must restructure your application and use
ApplicationContext.get_resource()
:And then just use: