1

The issue is a combination of setting an icon on the action in the toolbar (or qpushbutton) and showing a qmessagebox when triggered. If I remove the icon, the message box displays. And if I remove the message box but keep the icon, the app stays open. The other odd thing is, if I add the icon to the push button but not the action, and click on the action, it still closes the app. The doubly odd thing is if I add main.qpush_button_clicked before qapplication.exec_(), the message box is displayed. However, the next time I click on either, it closes the app.

I have looked at multiple posts and some of the ideas were to use setQuitOnLastWindowClosed, but that did not fix the issue. I also implemented event to see what was happening. When I click on either of the items, it triggers a ChildAdded event, then closes.

Also, this only does not work when I use cx_Freeze on a Mac. I have not tried on Win. It works properly when run using Eclipse or from CLI.

Does anyone have any ideas on what might be causing this, or how to fix it besides not using icons.

The icon I used is from Android icon pack.

I can add the crash log if you need it.

class Main(QMainWindow):


def __init__(self):
    QMainWindow.__init__(self)

    self.qicon = QIcon('../ic_add_black_24dp_1x.png')

    self.tool_bar = self.addToolBar('main')

    qaction = QAction(self)
    self.tool_bar.addAction(qaction)
    qaction.setText('add')
    qaction.setIcon(self.qicon)
    qaction.triggered.connect(self.qpush_button_clicked)

    qpush_button = QPushButton('add')
    self.setCentralWidget(qpush_button)
    qpush_button.setIcon(self.qicon)
    qpush_button.clicked.connect(self.qpush_button_clicked)


def qpush_button_clicked(self, *args, **kwargs):
    QMessageBox.critical(self, 'test', 'testing')



if __name__ == '__main__':
    qapplication = QApplication(sys.argv)

    main = Main()
    main.show()
    main.raise_()

    qapplication.exec_()

And here is the setup file

name = 'dialog'
version = '0.1'
description = 'description'

packages = ('os',)
excludes = ('tkinter',)
include_files = ('ic_add_black_24dp_1x.png',)

build_exe = dict(packages=packages,
                 excludes=excludes,
                 include_files=include_files)
options = dict(build_exe=build_exe)

base = 'Win32GUI' if sys.platform == 'win32' else None
script = 'dialog.py'
executables = (Executable(script, base=base),)

setup(name=name,
      version=version,
      description=description,
      options=options,
      executables=executables)
  • PySide Version : 1.2.2
  • PySide Component: : (1, 2, 2, 'final', 0)
  • PySide Compiled Qt : 4.8.7
  • PySide Qt Component: (4, 8, 7)
  • Running Qt Version : 4.8.7
  • Does the Icon even show up at all? I think the issue could be in way that you are accessing the image (see my question + answer here: http://stackoverflow.com/questions/37278073/loading-qicons-using-pkgutil) (side note, can you fix the indentation in your code? thnx) – Tom Myddeltyn May 19 '16 at 15:50

0 Answers0