8498269367e97b2bc0a429a158b8e232e8f1ff53
[hooke.git] / hooke / ui / gui / statusbar.py
1 # Copyright (C) 2010-2012 W. Trevor King <wking@drexel.edu>
2 #
3 # This file is part of Hooke.
4 #
5 # Hooke is free software: you can redistribute it and/or modify it under the
6 # terms of the GNU Lesser General Public License as published by the Free
7 # Software Foundation, either version 3 of the License, or (at your option) any
8 # later version.
9 #
10 # Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
11 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12 # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
13 # details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with Hooke.  If not, see <http://www.gnu.org/licenses/>.
17
18 """Status bar for Hooke.
19 """
20
21 import wx
22
23 from ... import version
24
25
26 class StatusBar (wx.StatusBar):
27     def __init__(self, *args, **kwargs):
28         super(StatusBar, self).__init__(*args, **kwargs)
29         self.SetFieldsCount(2)
30         self.SetStatusWidths([-2, -3])
31         self.SetStatusText('Ready', 0)
32         self.SetStatusText(u'Welcome to Hooke (version %s)' % version(), 1)
33
34     def set_playlist(self, playlist):
35         self.SetStatusText(self._playlist_status(playlist), 0)
36
37     def set_curve(self, curve):
38         pass
39
40     def set_plot_text(self, text):
41         self.SetStatusText(text, 1)
42
43     def _playlist_status(self, playlist):
44         fields = [
45             playlist.name,
46             '(%d/%d)' % (playlist.index(), len(playlist)),
47             ]
48         curve = playlist.current()
49         if curve != None:
50             fields.append(curve.name)
51         return ' '.join(fields)