xelapond
March 15th, 2008, 01:39 AM
Hello,
I have been following the guide here (http://zetcode.com/tutorials/pyqt4/menusandtoolbars/) for useing PyQt to write GUI apps in python. I have been running into several prblems with icons not showing up, but essentially this is what happens. I am making a toolbar with a quit button, that should have the exit icon. The icon is not there, but I can still click where is would be.
How can I get my icons back?
#!/usr/bin/python
# toolbar.py
import sys
from PyQt4 import QtGui, QtCore
class MainWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.resize(250, 150)
self.setWindowTitle('toolbar')
self.exit = QtGui.QAction(QtGui.QIcon('exit.png'), 'Exit', self)
self.exit.setShortcut('Ctrl+Q')
self.connect(self.exit, QtCore.SIGNAL('triggered()'), QtCore.SLOT('close()'))
self.toolbar = self.addToolBar('Exit')
self.toolbar.addAction(self.exit)
app = QtGui.QApplication(sys.argv)
main = MainWindow()
main.show()
sys.exit(app.exec_())
Thanks,
Alex
I have been following the guide here (http://zetcode.com/tutorials/pyqt4/menusandtoolbars/) for useing PyQt to write GUI apps in python. I have been running into several prblems with icons not showing up, but essentially this is what happens. I am making a toolbar with a quit button, that should have the exit icon. The icon is not there, but I can still click where is would be.
How can I get my icons back?
#!/usr/bin/python
# toolbar.py
import sys
from PyQt4 import QtGui, QtCore
class MainWindow(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.resize(250, 150)
self.setWindowTitle('toolbar')
self.exit = QtGui.QAction(QtGui.QIcon('exit.png'), 'Exit', self)
self.exit.setShortcut('Ctrl+Q')
self.connect(self.exit, QtCore.SIGNAL('triggered()'), QtCore.SLOT('close()'))
self.toolbar = self.addToolBar('Exit')
self.toolbar.addAction(self.exit)
app = QtGui.QApplication(sys.argv)
main = MainWindow()
main.show()
sys.exit(app.exec_())
Thanks,
Alex