~jrjohansson/qutip/master

« back to all changes in this revision

Viewing changes to qutip/about.py

  • Committer: Paul Nation
  • Date: 2011-04-21 04:46:56 UTC
  • Revision ID: git-v1:dd4c966b490aa468dfbd28cef66694df4bf235c8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#This file is part of QuTIP.
 
2
#
 
3
#    QuTIP is free software: you can redistribute it and/or modify
 
4
#    it under the terms of the GNU General Public License as published by
 
5
#    the Free Software Foundation, either version 3 of the License, or
 
6
#   (at your option) any later version.
 
7
#
 
8
#    QuTIP is distributed in the hope that it will be useful,
 
9
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
#    GNU General Public License for more details.
 
12
#
 
13
#    You should have received a copy of the GNU General Public License
 
14
#    along with QuTIP.  If not, see <http://www.gnu.org/licenses/>.
 
15
#
 
16
# Copyright (C) 2011, Paul D. Nation & Robert J. Johansson
 
17
#
 
18
###########################################################################
 
19
import sys,os
 
20
from Tkinter import *
 
21
import numpy
 
22
import scipy
 
23
CD_BASE = os.path.dirname(__file__) # get directory of about.py file
 
24
execfile(os.path.join(CD_BASE, "_version.py")) #execute _version.py file in CD_BASE directory
 
25
def about():
 
26
    if sys.platform=='darwin':
 
27
        from mac import MsgBox
 
28
        import matplotlib
 
29
        Mversion = "Matplotlib Ver: "+matplotlib.__version__
 
30
        title='About'
 
31
        message='QuTIP: The Quantum Optics Toolbox in Python'
 
32
        info='Copyright (c) 2011\nPaul D. Nation & Robert J. Johansson \n\n'+'QuTIP Ver:        '+__version__+"\nNumpy Ver:      "+numpy.__version__+'\n'+"Scipy Ver:         "+scipy.__version__+'\n'+Mversion+"\n\nQuTiP is released under the GPL3.\nSee the enclosed COPYING.txt\nfile for more information."
 
33
        MsgBox(title,message,info)
 
34
    elif sys.platform=='linux2' and os.environ['QUTIP_GRAPHICS']=='YES':
 
35
        from linux import AboutBox
 
36
        AboutBox(__version__)
 
37
    elif os.environ['QUTIP_GRAPHICS']=='YES':
 
38
        root = Tk()
 
39
        root.title('      About')
 
40
        root.wm_attributes("-topmost", 1)
 
41
        root.focus()
 
42
        def center(window):
 
43
            sw = window.winfo_screenwidth()
 
44
            sh = window.winfo_screenheight()
 
45
            rw = window.winfo_reqwidth()
 
46
            rh = window.winfo_reqheight()
 
47
            xc = (sw - rw) / 2
 
48
            yc = (sh -rh) / 2
 
49
            window.geometry("+%d+%d" % (xc, yc))
 
50
            window.deiconify()         # Harmless if window is already visible
 
51
            
 
52
        content = Frame(root)
 
53
        namelbl = Label(content, text="QuTIP: The Quantum Optics Toolbox in Python")
 
54
        auth1 = Label(content,text="Paul D. Nation")
 
55
        auth2 = Label(content,text="Robert J. Johansson")
 
56
        by = Label(content,text="By: ")
 
57
        spacer1 = Label(content,text="")
 
58
        Qversion = Label(content,text="QuTIP Version:  "+__version__)
 
59
        Nversion = Label(content, text="Numpy Version:  "+numpy.__version__)
 
60
        Sversion = Label(content, text="Scipy Version:  "+scipy.__version__)
 
61
        try:
 
62
            import matplotlib
 
63
        except:
 
64
            Mversion = Label(content, text="Matplotlib Version: None")
 
65
        else:
 
66
            Mversion = Label(content, text="Matplotlib Version:  "+matplotlib.__version__)
 
67
        content.grid(column=0, row=0)
 
68
        namelbl.grid(column=6, row=0, columnspan=2)
 
69
        by.grid(column=6,row=1,columnspan=3)
 
70
        auth1.grid(column=6, row=4, columnspan=2)
 
71
        auth2.grid(column=6, row=5, columnspan=2)
 
72
        spacer1.grid(column=6,row=6,columnspan=2)
 
73
        Qversion.grid(column=6,row=7,columnspan=2)
 
74
        Nversion.grid(column=6,row=8,columnspan=2)
 
75
        Sversion.grid(column=6,row=9,columnspan=2)
 
76
        Mversion.grid(column=6,row=10,columnspan=2)
 
77
 
 
78
        root.after(0,center,root)    # Zero delay doesn't seem to bother it
 
79
        root.mainloop()
 
80
    else:
 
81
        print "QuTIP: The Quantum Optics Toolbox in Python"
 
82
        print "Copyright (c) 2011"
 
83
        print "Paul D. Nation & Robert J. Johansson"
 
84
        print "QuTIP Version:  "+__version__
 
85
        print "Numpy Version:  "+numpy.__version__
 
86
        try:
 
87
            import matplotlib
 
88
        except:
 
89
            print "Matplotlib Version: None"
 
90
        else:
 
91
            print "Matplotlib Version:  "+matplotlib.__version__
 
92
 
 
93
if __name__ == "__main__":
 
94
    os.environ['QUTIP_GRAPHICS']='YES'
 
95
    about()