#!/usr/bin/env python # -*- coding: utf-8 -*- """GUI for recursive calculation of the size of all files in a directory tree. """ import sys from PySide import QtGui from recursive_func import get_total_size class Form(QtGui.QDialog): """Main Window. """ def __init__(self, parent=None): super(Form, self).__init__(parent) self.setWindowTitle(u"Recurser") self.path = QtGui.QLineEdit(u"") self.button = QtGui.QPushButton(u"Calculate Size") self.res = QtGui.QLabel(u"Result") layout = QtGui.QVBoxLayout() layout.addWidget(self.path) layout.addWidget(self.button) layout.addWidget(self.res) self.setLayout(layout) self.button.clicked.connect(self.calculate) def calculate(self): """Display the calculated result. """ path = self.path.text() self.res.setText(u'Total: %d' % get_total_size(path)) def show_app(): """Display the window. """ app = QtGui.QApplication(sys.argv) form = Form() form.show() sys.exit(app.exec_()) if __name__ == '__main__': show_app()