diff --git a/cnvdb.py b/cnvdb.py
index cf8b899f9..f33b5dc03 100644
--- a/cnvdb.py
+++ b/cnvdb.py
@@ -21,27 +21,35 @@ Place, Suite 330, Boston, MA 02111-1307 USA
import codecs
import sys
+def convert_file(self, inname, outname):
+ """
+ Convert a file from another encoding into UTF-8.
-class Convert():
- def __init__(self):
- pass
+ ``inname``
+ The name of the file to be opened and converted.
- def process(self, inname, outname):
- infile = codecs.open(inname, 'r', encoding='iso-8859-1')
- writefile = codecs.open(outname, 'w', encoding='utf-8')
- for line in infile:
- #replace the quotes with quotes
- line = line.replace(u'\'\'', u'\'')
- writefile.write(line)
- infile.close()
- writefile.close()
+ ``outname``
+ The output file name.
+ """
+ infile = codecs.open(inname, 'r', encoding='iso-8859-1')
+ writefile = codecs.open(outname, 'w', encoding='utf-8')
+ for line in infile:
+ #replace the quotes with quotes
+ line = line.replace(u'\'\'', u'\'')
+ writefile.write(line)
+ infile.close()
+ writefile.close()
if __name__ == '__main__':
+ """
+ Run the conversion script.
+ """
if len(sys.argv) < 2:
print 'No action specified.'
sys.exit()
- print u'Uncode conversion '
- print u'Input file = ', sys.argv[1:]
- print u'Output file = ', sys.argv[2:]
- mig = Convert()
- mig.process(sys.argv[1:],sys.argv[2:])
+ print 'Uncode conversion:'
+ print 'Input file = ', sys.argv[1]
+ print 'Output file = ', sys.argv[2]
+ print 'Converting...'
+ convert_file(sys.argv[1], sys.argv[2])
+ print 'Done.'
diff --git a/demo.py b/demo.py
index c06bbd26a..c6b1cf571 100644
--- a/demo.py
+++ b/demo.py
@@ -16,12 +16,14 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
"""
-from openlp.core import Renderer
-from openlp.theme import Theme
import sys
import time
from PyQt4 import QtGui, QtCore
+
+from openlp.core import Renderer
+from openlp.theme import Theme
+
words="""How sweet the name of Jesus sounds
In a believer's ear!
It soothes his sorrows, heals his wounds,
@@ -29,53 +31,74 @@ And drives away his fear.
"""
class TstFrame(QtGui.QMainWindow):
- """ We simply derive a new class of QMainWindow"""
-
- # {{{ init
+ """
+ We simply derive a new class of QMainWindow
+ """
def __init__(self, *args, **kwargs):
- """Create the DemoPanel."""
+ """
+ Create the DemoPanel.
+ """
QtGui.QMainWindow.__init__(self)
- self.resize(1024,768)
- self.size=(1024,768)
-
- self.v=0
- self._font=QtGui.QFont(u'Decorative', 32)
- self.framecount=0
+ self.resize(1024, 768)
+ self.size = (1024, 768)
+ self.v = 0
+ self._font = QtGui.QFont(u'Decorative', 32)
+ self.framecount = 0
self.totaltime = 0
- self.dir=1
- self.y=1
-# self.startTimer(10)
- self.frame=QtGui.QFrame()
+ self.dir = 1
+ self.y = 1
+ self.frame = QtGui.QFrame()
self.setCentralWidget(self.frame)
- self.r=Renderer()
+ self.r = Renderer()
self.r.set_theme(Theme(u'demo_theme.xml'))
-
self.r.set_text_rectangle(self.frame.frameRect())
self.r.set_paint_dest(self)
self.r.set_words_openlp(words)
+
def timerEvent(self, event):
+ """
+ Update the form on a timer event.
+
+ ``event``
+ The event which triggered this update.
+ """
self.update()
+
def paintEvent(self, event):
+ """
+ Repaint the canvas.
+
+ ``event``
+ The event which triggered this repaint.
+ """
self.r.set_text_rectangle(self.frame.frameRect())
self.r.scale_bg_image()
- t1=time.clock()
+ t1 = time.clock()
self.r.render_screen(0)
t2 = time.clock()
- deltat=t2-t1
+ deltat = t2 - t1
self.totaltime += deltat
- self.framecount+=1
+ self.framecount += 1
print "Timing result: %5.3ffps" %(self.framecount/float(self.totaltime))
- # }}}
-class Demo:
+class Demo(object):
+ """
+ The demo application itself.
+ """
def __init__(self):
+ """
+ Construct the application.
+ """
app = QtGui.QApplication(sys.argv)
- main=TstFrame()
+ main = TstFrame()
main.show()
sys.exit(app.exec_())
if __name__=="__main__":
- t=Demo()
+ """
+ Run the demo.
+ """
+ t = Demo()
diff --git a/openlp.pyw b/openlp.pyw
index 33ae56f16..d7e43ede0 100755
--- a/openlp.pyw
+++ b/openlp.pyw
@@ -23,22 +23,29 @@ import sys
import logging
from PyQt4 import QtCore, QtGui
+
from openlp.core.lib import Receiver
+from openlp.core.resources import *
+from openlp.core.ui import MainWindow, SplashScreen
logging.basicConfig(level=logging.DEBUG,
format=u'%(asctime)s:%(msecs)3d %(name)-15s %(levelname)-8s %(message)s',
datefmt=u'%m-%d %H:%M:%S', filename=u'openlp.log', filemode=u'w')
-from openlp.core.resources import *
-from openlp.core.ui import MainWindow, SplashScreen
-
class OpenLP(QtGui.QApplication):
+ """
+ The core application class. This class inherits from Qt's QApplication
+ class in order to provide the core of the application.
+ """
global log
log = logging.getLogger(u'OpenLP Application')
log.info(u'Application Loaded')
def run(self):
- #set the default string encoding
+ """
+ Run the OpenLP application.
+ """
+ #set the default string encoding
try:
sys.setappdefaultencoding(u'utf-8')
except:
@@ -68,5 +75,8 @@ class OpenLP(QtGui.QApplication):
sys.exit(app.exec_())
if __name__ == u'__main__':
+ """
+ Instantiate and run the application.
+ """
app = OpenLP(sys.argv)
app.run()
diff --git a/openlp/controls/__init__.py b/openlp/controls/__init__.py
deleted file mode 100644
index b16ed4f5a..000000000
--- a/openlp/controls/__init__.py
+++ /dev/null
@@ -1,17 +0,0 @@
-"""
-OpenLP - Open Source Lyrics Projection
-Copyright (c) 2008 Raoul Snyman
-Portions copyright (c) 2008 Martin Thompson, Tim Bentley
-
-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
-"""
diff --git a/openlp/core/__init__.py b/openlp/core/__init__.py
index ca1042fac..e3518b436 100644
--- a/openlp/core/__init__.py
+++ b/openlp/core/__init__.py
@@ -17,6 +17,7 @@ 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
"""
+
#from settingsmanager import SettingsManager
#from openlp.core.lib.pluginmanager import PluginManager
#
diff --git a/openlp/core/lib/settingsmanager.py b/openlp/core/lib/settingsmanager.py
index 9272c3035..bc66c2375 100644
--- a/openlp/core/lib/settingsmanager.py
+++ b/openlp/core/lib/settingsmanager.py
@@ -3,7 +3,7 @@
"""
OpenLP - Open Source Lyrics Projection
Copyright (c) 2008 Raoul Snyman
-Portions copyright (c) 2008 Martin Thompson, Tim Bentley
+Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley
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
@@ -24,4 +24,10 @@ class SettingsManager(object):
This class is created by the main window and then calculates the size of individual components
"""
def __init__(self, screen):
- pass
+ self.screen = screen[0]
+ self.width = self.screen[u'size'].width()
+ self.height = self.screen[u'size'].height()
+ self.mainwindow_width = self.width * 0.8
+ self.mainwindow_height = self.height * 0.8
+ self.mainwindow_docbars = self.width / 3
+ self.mainwindow_slidecontroller = self.width / 6
diff --git a/openlp/core/lib/themexmlhandler.py b/openlp/core/lib/themexmlhandler.py
index 12880bfa6..4c6789193 100644
--- a/openlp/core/lib/themexmlhandler.py
+++ b/openlp/core/lib/themexmlhandler.py
@@ -19,11 +19,13 @@ Place, Suite 330, Boston, MA 02111-1307 USA
For XML Schema see wiki.openlp.org
"""
-import os, os.path
-from openlp.core.lib import str_to_bool
-from xml.dom.minidom import Document
+import os
+
+from xml.dom.minidom import Document
from xml.etree.ElementTree import ElementTree, XML, dump
+from openlp.core.lib import str_to_bool
+
blankthemexml=\
'''
@@ -62,26 +64,38 @@ blankthemexml=\
'''
-class ThemeXML():
+class ThemeXML(object):
+ """
+ A class to encapsulate the Theme XML.
+ """
def __init__(self):
+ """
+ Initialise the theme object.
+ """
# Create the minidom document
self.theme_xml = Document()
def extend_image_filename(self, path):
"""
Add the path name to the image name so the background can be rendered.
+
+ ``path``
+ The path name to be added.
"""
- if self.background_filename is not None:
- self.background_filename = os.path.join(path, self.theme_name, self.background_filename)
+ if self.background_filename is not None and path is not None:
+ self.background_filename = os.path.join(path, self.theme_name,
+ self.background_filename)
def new_document(self, name):
+ """
+ Create a new theme XML document.
+ """
self.theme = self.theme_xml.createElement(u'theme')
self.theme_xml.appendChild(self.theme)
self.theme.setAttribute(u'version', u'1.0')
-
self.name = self.theme_xml.createElement(u'name')
- ctn = self.theme_xml.createTextNode(name)
- self.name.appendChild(ctn)
+ text_node = self.theme_xml.createTextNode(name)
+ self.name.appendChild(text_node)
self.theme.appendChild(self.name)
def add_background_transparent(self):
@@ -95,23 +109,33 @@ class ThemeXML():
def add_background_solid(self, bkcolor):
"""
Add a Solid background.
+
+ ``bkcolor``
+ The color of the background.
"""
background = self.theme_xml.createElement(u'background')
background.setAttribute(u'mode', u'opaque')
background.setAttribute(u'type', u'solid')
self.theme.appendChild(background)
-
self.child_element(background, u'color', bkcolor)
def add_background_gradient(self, startcolor, endcolor, direction):
"""
Add a gradient background.
+
+ ``startcolor``
+ The gradient's starting colour.
+
+ ``endcolor``
+ The gradient's ending colour.
+
+ ``direction``
+ The direction of the gradient.
"""
background = self.theme_xml.createElement(u'background')
background.setAttribute(u'mode', u'opaque')
background.setAttribute(u'type', u'gradient')
self.theme.appendChild(background)
-
# Create startColor element
self.child_element(background, u'startColor', startcolor)
# Create endColor element
@@ -122,39 +146,63 @@ class ThemeXML():
def add_background_image(self, filename):
"""
Add a image background.
+
+ ``filename``
+ The file name of the image.
"""
background = self.theme_xml.createElement(u'background')
background.setAttribute(u'mode', u'opaque')
background.setAttribute(u'type', u'image')
self.theme.appendChild(background)
-
#Create Filename element
self.child_element(background, u'filename', filename)
- def add_font(self, name, color, proportion, override, fonttype=u'main', xpos=0, ypos=0 ,width=0, height=0):
+ def add_font(self, name, color, proportion, override, fonttype=u'main',
+ xpos=0, ypos=0, width=0, height=0):
"""
Add a Font.
+
+ ``name``
+ The name of the font.
+
+ ``color``
+ The colour of the font.
+
+ ``proportion``
+ The size of the font.
+
+ ``override``
+ Whether or not to override the default positioning of the theme.
+
+ ``fonttype``
+ The type of font, ``main`` or ``footer``. Defaults to ``main``.
+
+ ``xpos``
+ The X position of the text block.
+
+ ``ypos``
+ The Y position of the text block.
+
+ ``width``
+ The width of the text block.
+
+ ``height``
+ The height of the text block.
"""
background = self.theme_xml.createElement(u'font')
background.setAttribute(u'type',fonttype)
self.theme.appendChild(background)
-
#Create Font name element
self.child_element(background, u'name', name)
-
#Create Font color element
self.child_element(background, u'color', color)
-
#Create Proportion name element
self.child_element(background, u'proportion', proportion)
-
#Create Proportion name element
self.child_element(background, u'proportion', proportion)
-
#Create Location element
element = self.theme_xml.createElement(u'location')
element.setAttribute(u'override',override)
-
if override == u'True':
element.setAttribute(u'x', xpos)
element.setAttribute(u'y', ypos)
@@ -162,79 +210,120 @@ class ThemeXML():
element.setAttribute(u'height', height)
background.appendChild(element)
- def add_display(self, shadow, shadowColor, outline, outlineColor, horizontal, vertical, wrap):
+ def add_display(self, shadow, shadow_color, outline, outline_color,
+ horizontal, vertical, wrap):
"""
Add a Display options.
+
+ ``shadow``
+ Whether or not to show a shadow.
+
+ ``shadow_color``
+ The colour of the shadow.
+
+ ``outline``
+ Whether or not to show an outline.
+
+ ``outline_color``
+ The colour of the outline.
+
+ ``horizontal``
+ The horizontal alignment of the text.
+
+ ``vertical``
+ The vertical alignment of the text.
+
+ ``wrap``
+ Wrap style.
"""
background = self.theme_xml.createElement(u'display')
self.theme.appendChild(background)
-
- tagElement = self.theme_xml.createElement(u'shadow')
-
- tagElement.setAttribute(u'color',shadowColor)
- tagValue = self.theme_xml.createTextNode(shadow)
- tagElement.appendChild(tagValue)
- background.appendChild(tagElement)
-
- tagElement = self.theme_xml.createElement(u'outline')
- tagElement.setAttribute(u'color',outlineColor)
- tagValue = self.theme_xml.createTextNode(outline)
- tagElement.appendChild(tagValue)
- background.appendChild(tagElement)
-
- tagElement = self.theme_xml.createElement(u'horizontalAlign')
- tagValue = self.theme_xml.createTextNode(horizontal)
- tagElement.appendChild(tagValue)
- background.appendChild(tagElement)
-
- tagElement = self.theme_xml.createElement(u'verticalAlign')
- tagValue = self.theme_xml.createTextNode(vertical)
- tagElement.appendChild(tagValue)
- background.appendChild(tagElement)
-
- tagElement = self.theme_xml.createElement(u'wrapStyle')
- tagValue = self.theme_xml.createTextNode(wrap)
- tagElement.appendChild(tagValue)
- background.appendChild(tagElement)
+ # Shadow
+ element = self.theme_xml.createElement(u'shadow')
+ element.setAttribute(u'color', shadow_color)
+ value = self.theme_xml.createTextNode(shadow)
+ element.appendChild(value)
+ background.appendChild(element)
+ # Outline
+ element = self.theme_xml.createElement(u'outline')
+ element.setAttribute(u'color', outline_color)
+ value = self.theme_xml.createTextNode(outline)
+ element.appendChild(value)
+ background.appendChild(element)
+ # Horizontal alignment
+ element = self.theme_xml.createElement(u'horizontalAlign')
+ value = self.theme_xml.createTextNode(horizontal)
+ element.appendChild(value)
+ background.appendChild(element)
+ # Vertical alignment
+ element = self.theme_xml.createElement(u'verticalAlign')
+ value = self.theme_xml.createTextNode(vertical)
+ element.appendChild(value)
+ background.appendChild(element)
+ # Wrap style
+ element = self.theme_xml.createElement(u'wrapStyle')
+ value = self.theme_xml.createTextNode(wrap)
+ element.appendChild(value)
+ background.appendChild(element)
def child_element(self, element, tag, value):
+ """
+ Generic child element creator.
+ """
child = self.theme_xml.createElement(tag)
child.appendChild(self.theme_xml.createTextNode(value))
element.appendChild(child)
return child
def dump_xml(self):
+ """
+ Dump the XML to file.
+ """
# Debugging aid to see what we have
print self.theme_xml.toprettyxml(indent=u' ')
def extract_xml(self):
+ """
+ Pull out the XML string.
+ """
# Print our newly created XML
return self.theme_xml.toxml()
def parse(self, xml):
- self.baseParseXml()
+ """
+ Read in an XML string and parse it.
+
+ ``xml``
+ The XML string to parse.
+ """
+ self.base_parse_xml()
self.parse_xml(xml)
self.theme_filename_extended = False
- def baseParseXml(self):
+ def base_parse_xml(self):
+ """
+ Pull in the blank theme XML as a starting point.
+ """
self.parse_xml(blankthemexml)
def parse_xml(self, xml):
+ """
+ Parse an XML string.
+
+ ``xml``
+ The XML string to parse.
+ """
theme_xml = ElementTree(element=XML(xml))
iter = theme_xml.getiterator()
master = u''
for element in iter:
- #print element.tag, element.text
if len(element.getchildren()) > 0:
master = element.tag + u'_'
if len(element.attrib) > 0:
- #print "D", element.tag , element.attrib
for e in element.attrib.iteritems():
- #print "A", master, e[0], e[1]
if master == u'font_' and e[0] == u'type':
master += e[1] + u'_'
elif master == u'display_' and (element.tag == u'shadow' or element.tag == u'outline'):
- #print "b", master, element.tag, element.text, e[0], e[1]
et = str_to_bool(element.text)
setattr(self, master + element.tag , et)
setattr(self, master + element.tag + u'_'+ e[0], e[1])
@@ -245,12 +334,14 @@ class ThemeXML():
e1 = str_to_bool(e[1])
setattr(self, field, e1)
else:
- #print "c", element.tag, element.text
if element.tag is not None:
field = master + element.tag
setattr(self, field, element.text)
def __str__(self):
+ """
+ Return a string representation of this object.
+ """
s = u''
for k in dir(self):
if k[0:1] != u'_':
diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py
index 9bd124aa2..0f89abed4 100644
--- a/openlp/core/lib/toolbar.py
+++ b/openlp/core/lib/toolbar.py
@@ -1,4 +1,3 @@
-
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
"""
@@ -19,15 +18,19 @@ this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place, Suite 330, Boston, MA 02111-1307 USA
"""
import types
+import logging
from PyQt4 import QtCore, QtGui
-import logging
class OpenLPToolbar(QtGui.QToolBar):
"""
- Lots of toolbars around the place, so it makes sense to have a common way to manage them
+ Lots of toolbars around the place, so it makes sense to have a common way
+ to manage them. This is the base toolbar class.
"""
def __init__(self, parent):
+ """
+ Initialise the toolbar.
+ """
QtGui.QToolBar.__init__(self, None)
# useful to be able to reuse button icons...
self.icons = {}
@@ -37,6 +40,23 @@ class OpenLPToolbar(QtGui.QToolBar):
def addToolbarButton(self, title, icon, tooltip=None, slot=None, objectname=None):
"""
A method to help developers easily add a button to the toolbar.
+
+ ``title``
+ The title of the button.
+
+ ``icon``
+ The icon of the button. This can be an instance of QIcon, or a
+ string cotaining either the absolute path to the image, or an
+ internal resource path starting with ':/'.
+
+ ``tooltip``
+ A hint or tooltip for this button.
+
+ ``slot``
+ The method to run when this button is clicked.
+
+ ``objectname``
+ The name of the object, as used in `