1
#This file is part of QuTIP.
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.
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.
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
###########################################################################
18
###-platform dependent imports-###
19
if sys.platform=='darwin':
20
from qutip.mac import ProgressBar
22
from qutip.linux import Tk_ProgressBar,center
24
#---------------------------------
27
def __init__(self,max,step_size=1):
32
if sys.platform=='darwin':
33
self.bar = ProgressBar(title="Running Monte-Carlo Trajectories:")
35
self.root = Tkinter.Tk(className=' Running Monte-Carlo Trajectories:')
38
self.root.after(0,center,self.root)
39
self.bar=Tk_ProgressBar(self.root, relief='ridge', bd=3)
40
self.bar.pack(fill='x')
41
self.bar.set(self.percent, str(self.percent*100)+' %')
43
def update(self):#update the counter
45
self.percent=self.count/(1.0*self.max)
46
if sys.platform=='darwin':
47
self.bar.update(self.percent*100.0, "Trajectories completed: "+str(self.count)+"/"+str(self.max))
49
self.bar.set(self.percent,"Trajectories completed: "+str(self.count)+"/"+str(self.max))
51
def finish(self):#pause and close and finish
53
if sys.platform=='darwin':
59
######---Demo---######
60
if __name__ == "__main__":
70
if sys.platform!='darwin':
71
x.bar.after(0,lambda: func(x))
b'\\ No newline at end of file'