2009-09-08 19:58:05 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
2008-10-23 19:50:52 +00:00
|
|
|
|
2009-09-08 19:58:05 +00:00
|
|
|
###############################################################################
|
|
|
|
# OpenLP - Open Source Lyrics Projection #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# Copyright (c) 2008-2009 Raoul Snyman #
|
|
|
|
# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten #
|
|
|
|
# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri #
|
|
|
|
# --------------------------------------------------------------------------- #
|
|
|
|
# This program is free software; you can redistribute it and/or modify it #
|
|
|
|
# under the terms of the GNU General Public License as published by the Free #
|
|
|
|
# Software Foundation; version 2 of the License. #
|
|
|
|
# #
|
|
|
|
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
|
|
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
|
|
|
# more details. #
|
|
|
|
# #
|
|
|
|
# You should have received a copy of the GNU General Public License along #
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
|
|
|
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
|
|
|
###############################################################################
|
2008-10-23 19:50:52 +00:00
|
|
|
|
2008-10-07 19:12:32 +00:00
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
|
|
|
|
from PyQt4 import QtGui, QtCore
|
2009-07-08 06:55:08 +00:00
|
|
|
|
|
|
|
from openlp.core import Renderer
|
|
|
|
from openlp.theme import Theme
|
|
|
|
|
2008-10-07 19:12:32 +00:00
|
|
|
words="""How sweet the name of Jesus sounds
|
|
|
|
In a believer's ear!
|
|
|
|
It soothes his sorrows, heals his wounds,
|
|
|
|
And drives away his fear.
|
|
|
|
"""
|
|
|
|
|
|
|
|
class TstFrame(QtGui.QMainWindow):
|
2009-07-08 06:55:08 +00:00
|
|
|
"""
|
|
|
|
We simply derive a new class of QMainWindow
|
|
|
|
"""
|
2008-10-07 19:12:32 +00:00
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
2009-07-08 06:55:08 +00:00
|
|
|
"""
|
|
|
|
Create the DemoPanel.
|
|
|
|
"""
|
2008-10-07 19:12:32 +00:00
|
|
|
QtGui.QMainWindow.__init__(self)
|
2009-07-08 06:55:08 +00:00
|
|
|
self.resize(1024, 768)
|
|
|
|
self.size = (1024, 768)
|
|
|
|
self.v = 0
|
|
|
|
self._font = QtGui.QFont(u'Decorative', 32)
|
|
|
|
self.framecount = 0
|
2008-10-07 19:12:32 +00:00
|
|
|
self.totaltime = 0
|
2009-07-08 06:55:08 +00:00
|
|
|
self.dir = 1
|
|
|
|
self.y = 1
|
|
|
|
self.frame = QtGui.QFrame()
|
2008-10-07 19:12:32 +00:00
|
|
|
self.setCentralWidget(self.frame)
|
2009-07-08 06:55:08 +00:00
|
|
|
self.r = Renderer()
|
2009-06-16 18:21:24 +00:00
|
|
|
self.r.set_theme(Theme(u'demo_theme.xml'))
|
2008-10-07 19:12:32 +00:00
|
|
|
self.r.set_text_rectangle(self.frame.frameRect())
|
|
|
|
self.r.set_paint_dest(self)
|
|
|
|
self.r.set_words_openlp(words)
|
2009-07-08 06:55:08 +00:00
|
|
|
|
2008-10-07 19:12:32 +00:00
|
|
|
def timerEvent(self, event):
|
2009-07-08 06:55:08 +00:00
|
|
|
"""
|
|
|
|
Update the form on a timer event.
|
|
|
|
|
|
|
|
``event``
|
|
|
|
The event which triggered this update.
|
|
|
|
"""
|
2008-10-07 19:12:32 +00:00
|
|
|
self.update()
|
2009-07-08 06:55:08 +00:00
|
|
|
|
2008-10-07 19:12:32 +00:00
|
|
|
def paintEvent(self, event):
|
2009-07-08 06:55:08 +00:00
|
|
|
"""
|
|
|
|
Repaint the canvas.
|
|
|
|
|
|
|
|
``event``
|
|
|
|
The event which triggered this repaint.
|
|
|
|
"""
|
2008-10-07 19:12:32 +00:00
|
|
|
self.r.set_text_rectangle(self.frame.frameRect())
|
|
|
|
self.r.scale_bg_image()
|
2009-07-08 06:55:08 +00:00
|
|
|
t1 = time.clock()
|
2008-10-07 19:12:32 +00:00
|
|
|
self.r.render_screen(0)
|
|
|
|
t2 = time.clock()
|
2009-07-08 06:55:08 +00:00
|
|
|
deltat = t2 - t1
|
2008-10-07 19:12:32 +00:00
|
|
|
self.totaltime += deltat
|
2009-07-08 06:55:08 +00:00
|
|
|
self.framecount += 1
|
2008-10-07 19:12:32 +00:00
|
|
|
print "Timing result: %5.3ffps" %(self.framecount/float(self.totaltime))
|
2008-10-23 19:50:52 +00:00
|
|
|
|
2008-10-07 19:12:32 +00:00
|
|
|
|
2009-07-08 06:55:08 +00:00
|
|
|
class Demo(object):
|
|
|
|
"""
|
|
|
|
The demo application itself.
|
|
|
|
"""
|
2008-10-07 19:12:32 +00:00
|
|
|
def __init__(self):
|
2009-07-08 06:55:08 +00:00
|
|
|
"""
|
|
|
|
Construct the application.
|
|
|
|
"""
|
2008-10-07 19:12:32 +00:00
|
|
|
app = QtGui.QApplication(sys.argv)
|
2009-07-08 06:55:08 +00:00
|
|
|
main = TstFrame()
|
2008-10-07 19:12:32 +00:00
|
|
|
main.show()
|
|
|
|
sys.exit(app.exec_())
|
|
|
|
|
|
|
|
|
|
|
|
if __name__=="__main__":
|
2009-07-08 06:55:08 +00:00
|
|
|
"""
|
|
|
|
Run the demo.
|
|
|
|
"""
|
|
|
|
t = Demo()
|