2 #Copyright 2011 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/>
23 class VFrameset(LabelFrame, Flic):
25 Visual frameset widget
27 This widget represents a set of frames and provides controls for manipulating
31 schedule (string) - commands to the owning object, values can be
32 mv left : move this chunk left
33 mv right: move this chunk right
34 copy : double this chunk
35 apply : realize new video properties
36 delete : remove this chunk
38 subgets - dictionary of widgets forming this
40 played (Tk.Boolean) - indicates status of the play checkbox (use ...play.get())
41 marked (Tk.Boolean) - indicates status of the mark checkbox (use ...mark.get())
44 def __init__(self, master = None, vurl = '', play = True):
48 master - the holding widget
54 self.played = BooleanVar(value = True)
55 self.marked = BooleanVar(value = True)
57 tooltips = Pmw.Balloon()
60 LabelFrame.__init__(self, master = master, text = vurl.split('/')[-1])
61 self.subgets['video'] = Frame(self, height=90, width=120, bg = '#000000')
62 self.subgets['video'].grid(column=0, row=0, rowspan=4, sticky=W)
64 self.subgets['b_edit'] = Button(self, text = 'Edit', command = self.edit)
65 self.subgets['b_edit'].grid(column = 1, row=1, columnspan = 4, rowspan = 2)
66 tooltips.bind(self.subgets['b_edit'], 'Select and remove single frames from frameset.')
68 self.subgets['b_mvbw'] = Button(self, text = '<-', command=self.mvbw)
69 self.subgets['b_mvbw'].grid(column = 1, row = 3, rowspan = 1, columnspan = 2, sticky=E)
70 tooltips.bind(self.subgets['b_mvbw'],
71 'Swap this chunk with its left neighbour (move it left).')
73 self.subgets['b_copy'] = Button(self, text = 'Copy', command=self.copy)
74 self.subgets['b_copy'].grid(column = 3, columnspan = 2, row = 3, rowspan = 1)
75 tooltips.bind(self.subgets['b_copy'],
76 'Create another chunk with the same properties as this one.')
78 self.subgets['b_mvfw'] = Button(self, text = '->', command=self.mvfw)
79 self.subgets['b_mvfw'].grid(column = 5, row = 3, rowspan = 1, sticky=W)
80 tooltips.bind(self.subgets['b_mvfw'],
81 'Swap this chunk with its right neighbour (move it right).')
83 self.subgets['c_play'] = Checkbutton(self, text='Play', offvalue=False,
84 onvalue=True, variable = self.played)
85 # self.subgets['c_play'].select()
86 self.subgets['c_play'].grid(column=1, columnspan = 2, row=0)
87 tooltips.bind(self.subgets['c_play'],
88 'Mark this chunk for playback in main window.')
90 self.subgets['c_mark'] = Checkbutton(self, text='Mark', offvalue=False,
91 onvalue=True, variable = self.marked)
92 # self.subgets['c_mark'].select()
93 self.subgets['c_mark'].grid(column=3, columnspan = 2, row=0)
94 tooltips.bind(self.subgets['c_mark'],
95 'Mark this chunk for application of choosen filters and effects.')
97 self.subgets['b_del'] = Button(self, text='Del', command = self.delete)
98 self.subgets['b_del'].grid(column=5, row=0, sticky=NE)
99 tooltips.bind(self.subgets['b_del'],
100 'Remove this chunk from the project.')
101 self.schedule = 'apply'
103 def load_filters(self, dbcur, num):
105 Load filter list from database
107 db - sqlite database cursor
108 num - database primary key id of this chunk
111 dbcur.execute('SELECT iorder FROM filters ' +
112 'WHERE chunk = ' + str(num) + ' ORDER BY iorder')
113 for filter in dbcur.fetchall():
114 dbcur.execute('SELECT line FROM filter_lines WHERE filter = ' +
115 str(filter[0]) + ' ORDER BY iorder')
117 for item in dbcur.fetchall():
119 self.add_filter(line)
123 Scheduler for internal use
125 self.schedule = 'delete'
129 Scheduler for internal use
131 self.schedule = 'mv left'
135 Scheduler for internal use
137 self.schedule = 'mv right'
141 Scheduler for internal use
143 self.schedule = 'copy'
145 def store(self, dbcur):
147 Store chunk to database
149 The tables "chunks", "filters" and "filter_lines"
150 must be prepared in database.
152 dbcur - sqlite database cursor
154 if self.played.get(): played = '1'
156 if self.marked.get(): marked = '1'
158 dbcur.execute('INSERT INTO chunks (filename, start, frames, played, marked) ' +
159 'VALUES ("' + self.vurl + '", 0, 0, ' + played + ', ' + marked + ');')
161 dbcur.execute('SELECT last_insert_rowid();')
162 chunk_id = str(dbcur.fetchone()[0])
164 for filter in self.filters:
165 dbcur.execute('INSERT INTO filters (chunk) VALUES (' + chunk_id + ');')
166 dbcur.execute('SELECT last_insert_rowid();')
167 filter_id = str(dbcur.fetchone()[0])
169 dbcur.execute('INSERT INTO filter_lines (line, filter) ' +
170 'VALUES ("' + line + '", ' + filter_id + ')')
171 def slave_video(self):
175 self.schedule = 'apply'
178 Flic.play(self, self.subgets['video'].winfo_id(), width=120, height=90)