Updated to Qt from Wx

bzr-revno: 12
This commit is contained in:
Martin Thompson 2008-06-16 19:51:19 +00:00
parent a4181d65ff
commit ad88d7e215
2 changed files with 17 additions and 12 deletions

View File

@ -1,6 +1,6 @@
from theme import Theme
import wx
import os.path
from PyQt4 import QtGui
def test_read_theme():
dir=os.path.split(__file__)[0]
# test we can read a theme
@ -10,24 +10,24 @@ def test_read_theme():
assert(t.BackgroundParameter2 == None)
assert(t.BackgroundParameter3 == None)
assert(t.BackgroundType == 2)
assert(t.FontColor == wx.Colour(255,255,255))
assert(t.FontColor == QtGui.QColor(255,255,255))
assert(t.FontName == "Tahoma")
assert(t.FontProportion == 16)
assert(t.HorizontalAlign == 2)
assert(t.Name == "openlp.org Packaged Theme")
assert(t.Outline == -1)
assert(t.OutlineColor == wx.Colour(255,0,0))
assert(t.OutlineColor == QtGui.QColor(255,0,0))
assert(t.Shadow == -1)
assert(t.ShadowColor == wx.Colour(0,0,1))
assert(t.ShadowColor == QtGui.QColor(0,0,1))
assert(t.VerticalAlign == 0)
# test we create a "blank" theme correctly
t=Theme()
print t
assert(t.BackgroundParameter1 == wx.Colour(0,0,0))
assert(t.BackgroundParameter1 == QtGui.QColor(0,0,0))
assert(t.BackgroundParameter2 == None)
assert(t.BackgroundParameter3 == None)
assert(t.BackgroundType == 0)
assert(t.FontColor == wx.Colour(255,255,255))
assert(t.FontColor == QtGui.QColor(255,255,255))
assert(t.FontName == "Arial")
assert(t.FontProportion == 30)
assert(t.HorizontalAlign == 0)

View File

@ -1,5 +1,12 @@
from elementtree.ElementTree import ElementTree, XML
import wx
import platform
ver = platform.python_version()
if ver >= '2.5':
from xml.etree.ElementTree import ElementTree, XML
else:
from elementtree import ElementTree, XML
from PyQt4 import QtGui
DelphiColors={"clRed":0xFF0000,
"clBlack":0x000000,
"clWhite":0xFFFFFF}
@ -19,7 +26,7 @@ blankstylexml=\
<Outline>0</Outline>
<HorizontalAlign>0</HorizontalAlign>
<VerticalAlign>0</VerticalAlign>
<WrapStyle>0</WrapStyle>
</Theme>
'''
@ -108,7 +115,7 @@ class Theme:
if (element.tag.find("Color") > 0 or
(element.tag.find("BackgroundParameter") == 0 and type(val) == type(0))):
# convert to a wx.Colour
val= wx.Colour((val>>16) & 0xFF, (val>>8)&0xFF, val&0xFF)
val= QtGui.QColor((val>>16) & 0xFF, (val>>8)&0xFF, val&0xFF)
# print [val]
setattr(self,element.tag, val)
@ -120,5 +127,3 @@ class Theme:
s+= "%30s : %s\n" %(k,getattr(self,k))
return s
if __name__=="__main__":
test_theme.test_read_theme()