2 #Copyright 2009 - 2010 Paul Hänsch
4 #This file is part of Viper.
6 #Viper is free software: you can redistribute it and/or modify
7 #it under the terms of the GNU General Public License as published by
8 #the Free Software Foundation, either version 3 of the License, or
9 #(at your option) any later version.
11 #Viper is distributed in the hope that it will be useful,
12 #but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 #GNU General Public License for more details.
16 #You should have received a copy of the GNU General Public License
17 #along with Viper. If not, see <http://www.gnu.org/licenses/>
22 class PlayerControl(Frame):
23 def __init__(self, parent, player, extrabuttons = []):
24 Frame.__init__(self, parent)
27 self.loop = BooleanVar(value = True)
29 tooltip = Pmw.Balloon()
32 self.subgets['s_pos'] = Scrollbar(self, orient=HORIZONTAL)
33 self.subgets['s_pos'].pack(side = TOP, anchor = W, fill = X)
34 self.subgets['b_stop'] = Button(self, text = 'Stop',
35 command = self.player.stop_video)
36 self.subgets['b_stop'].pack(side = LEFT, anchor = S)
37 tooltip.bind(self.subgets['b_stop'], 'Stop playback (time position to zero).')
38 self.subgets['b_play'] = Button(self, text='Play',
39 width=5, command=self.play)
40 self.subgets['b_play'].pack(side = LEFT, anchor = S)
41 tooltip.bind(self.subgets['b_play'], 'Play / Pause the video.')
42 self.subgets['b_step'] = Button(self, text = 'Step',
43 command = self.player.step_video)
44 self.subgets['b_step'].pack(side = LEFT, anchor = S)
45 tooltip.bind(self.subgets['b_step'], 'Step a single frame forward.')
46 self.subgets['c_loop'] = Checkbutton(self, text = 'Loop',
48 self.subgets['c_loop'].pack(side = LEFT, anchor = S)
50 for xbut in extrabuttons:
51 self.subgets['xb_' + xbut[0]] = Button(self, text = xbut[0],
53 self.subgets['xb_' + xbut[0]].pack(side = RIGHT, anchor = S)
54 try: tooltip.bind(self.subgets['xb_' + xbut[0]], xbut[2])
57 self.player.configure(callback = self.status, slider = self.subgets['s_pos'])
59 def configure(self, player):
61 self.player.configure(callback = self.status, slider = self.subgets['s_pos'])
64 self.player.play_video(loop = self.loop.get(),
67 def status(self, state):
68 if state == 'stopped':
69 self.subgets['b_play'].configure(text = 'Play', command = self.play)
70 elif state == 'paused':
71 self.subgets['b_play'].configure(text = 'Play', command = self.play)
72 elif state == 'playing':
73 self.subgets['b_play'].configure(text = 'Pause', command =
74 self.player.pause_video)