diff options
Diffstat (limited to 'examples3/qdir.py')
-rwxr-xr-x | examples3/qdir.py | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/examples3/qdir.py b/examples3/qdir.py index 62d452e..358c796 100755 --- a/examples3/qdir.py +++ b/examples3/qdir.py @@ -2,6 +2,7 @@ # # 2005-02-12 initial version hp +from __future__ import print_function import os import pickle from python_tqt.qt import * @@ -97,7 +98,7 @@ class Preview(TQWidgetStack): err = False try: text = open(path.latin1(), "r").read() - except IOError, msg: + except IOError as msg: text = TQString(str(msg)) err = True if not err and fi.extension().lower().contains("htm"): @@ -159,8 +160,8 @@ class CustomFileDialog(TQFileDialog): if os.path.exists(self.bookmarkFile): try: self.bookmarkList = pickle.loads(open(self.bookmarkFile, "rb").read()) - except IOError, msg: - print msg + except IOError as msg: + print(msg) self.setDir("/") self.dirView = DirectoryView(self, None, True) self.dirView.addColumn("") @@ -209,8 +210,8 @@ class CustomFileDialog(TQFileDialog): if self.bookmarkList: try: open(self.bookmarkFile, "wb").write(pickle.dumps(self.bookmarkList)) - except IOError, msg: - print msg + except IOError as msg: + print(msg) return TQFileDialog.done(self, r) def showEvent(self, e): @@ -245,8 +246,8 @@ if __name__ == '__main__': def usage(msg = None): if msg: - print >> sys.stderr, msg - print >> sys.stderr, """\ + print(msg, file=sys.stderr) + print("""\ usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [caption ...] --any Get any filename, need not exist. --dir Return a directory rather than a file. @@ -256,7 +257,7 @@ usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [c --default f Start from directory/file f. --filter f eg. '*.gif' '*.bmp' caption ... Caption for dialog. -""" +""", file=sys.stderr) sys.exit(1) def main(): @@ -270,7 +271,7 @@ usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [c try: optlist, args = getopt.getopt(sys.argv[1:], "h", options) - except getopt.error, msg: + except getopt.error as msg: usage(msg) for opt, par in optlist: @@ -311,7 +312,7 @@ usage: qdir [--any | --dir | --custom] [--preview] [--default f] {--filter f} [c fd.setCaption(caption) fd.setSelection(start) if fd.exec_loop() == TQDialog.Accepted: - print "%s\n" % fd.selectedFile().latin1() + print("%s\n" % fd.selectedFile().latin1()) return 0 else: return 1 |