File: icon_example.py

package info (click to toggle)
taurus 3.0.0-2
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 87,664 kB
  • sloc: python: 56,016; sh: 16; makefile: 14
file content (22 lines) | stat: -rw-r--r-- 697 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from PyQt4 import Qt
from taurus.qt.qtgui.resource import getThemeIcon

class MyGUI(Qt.QMainWindow):
    
    def __init__(self, parent=None):
        Qt.QMainWindow.__init__(self, parent)
        toolbar = self.addToolBar("Tools")
        open_icon = getThemeIcon("document-open")
        toolbar.addAction(open_icon, "Open HDF5", self.open_file)
        
    def open_file(self):
        fileName = Qt.QFileDialog.getOpenFileName(self, "Open HDF5", "/home/homer",
                                                  "HDF5 Files (*.h5)")
        # do something

if __name__ == "__main__":
    import sys
    app = Qt.QApplication(sys.argv)
    gui = MyGUI()
    gui.show()
    sys.exit(app.exec_())