- Created basic GUI elements

- Deleted GUI elements superceded

bzr-revno: 7
This commit is contained in:
Timothy Ebenezer 2008-03-04 00:12:12 +00:00
parent ba0539cb11
commit 4390a73a67
10 changed files with 273 additions and 183 deletions

31
canvas.py Normal file
View File

@ -0,0 +1,31 @@
import wx
class Canvas(wx.Window):
def __init__(self, parent, *args, **kwargs):
wx.Window.__init__(self, parent, *args, **kwargs)
self.SetBackgroundColour(wx.Colour(150,150,150))
self.Bind(wx.EVT_PAINT, self.OnPaint)
def OnPaint(self, event):
DC = wx.PaintDC(self)
if (self.GetSize().GetWidth()*3/4) > self.GetSize().GetHeight():
Height = self.GetSize().GetHeight()-40
Width = (Height*4)/3
x = (self.GetSize().GetWidth()-Width)/2
Rectangle = wx.Rect(x, 20, Width, Height)
else:
Width = self.GetSize().GetWidth()-40
Height = (Width*3)/4
y = (self.GetSize().GetHeight()-Height)/2
Rectangle = wx.Rect(20, y, Width, Height)
DC.SetBrush(wx.Brush(wx.Colour(0,0,0)))
DC.SetPen(wx.Pen(wx.Colour(255,255,255)))
if self.IsExposedRect(Rectangle):
DC.DrawRectangleRect(Rectangle)

View File

@ -1,19 +0,0 @@
"""
wx.Notebook that contains controls from each module
"""
import wx
class Controller(wx.Notebook):
"wx.Notebook for modules"
def __init__(self, parent, *args, **kwargs):
"Notebook constructor"
wx.Notebook.__init__(self, parent, *args, **kwargs)
self.AddPage(wx.Panel(self), "foo module")
# vim: autoindent shiftwidth=4 expandtab textwidth=80

65
controlpanel.py Normal file
View File

@ -0,0 +1,65 @@
"""
The openlp.org Control Panel
"""
import wx
import slidepanel
class ControlPanel(wx.Window):
Title = ""
Heading1 = ""
Heading2 = ""
Loaded = False;
def __init__(self, parent, title, *args, **kwargs):
wx.Window.__init__(self, parent, *args, **kwargs)
MainSizer = wx.BoxSizer(wx.VERTICAL)
MainSizer.AddSpacer(60)
self.Title = title
self.SlidePanel = slidepanel.SlidePanel(self)
MainSizer.Add(self.SlidePanel, flag=wx.EXPAND)
self.Bind(wx.EVT_PAINT, self.OnPaint)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.SetSizer(MainSizer)
self.SetAutoLayout(True)
self.Layout()
def OnPaint(self, event):
DC = wx.PaintDC(self)
DC.SetFont(wx.Font(pointSize=16, family=wx.FONTFAMILY_MODERN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_BOLD,underline=False,face="Tahoma"))
DC.DrawText(text=self.Title,x=(self.GetSize().GetWidth()-DC.GetTextExtent(self.Title)[0])/2,y=0)
y = DC.GetTextExtent(self.Title)[1]
DC.SetFont(wx.Font(pointSize=12, family=wx.FONTFAMILY_MODERN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_BOLD,underline=False,face="Tahoma"))
DC.SetBrush(wx.Brush(wx.Colour(55,102,255)))
DC.SetPen(wx.Pen(wx.Colour(55,102,255)))
fontHeight = DC.GetTextExtent("by")[1]
DC.DrawRectangle(0,y,self.GetSize().GetWidth(),fontHeight);
DC.SetTextForeground(wx.Colour(255,255,255))
if self.Heading1 == "":
DC.DrawText("No media item loaded",5,y)
else:
DC.DrawText(self.Heading1,5,y)
DC.SetFont(wx.Font(pointSize=10, family=wx.FONTFAMILY_MODERN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL,underline=False,face="Tahoma"))
DC.DrawRectangle(0,fontHeight+y,self.GetSize().GetWidth(),fontHeight)
DC.DrawText(self.Heading2,5,fontHeight+y)
self.SlidePanel.Refresh()
def OnSize(self, event):
self.Layout()

View File

@ -1,37 +0,0 @@
"""
wx.Panel for operator interface
"""
import wx
import oos
class LeftPanel(wx.Panel):
"Left half of operator interface"
def __init__(self, parent, *args, **kwargs):
"Panel constructor"
wx.Panel.__init__(self, parent, *args, **kwargs)
oospanel = oos.OrderOfService(self)
self.goblank = wx.RadioButton(self, label="Blank Screen",
style=wx.RB_GROUP)
self.golive = wx.RadioButton(self, label="Go Live")
blankersizer = wx.BoxSizer(wx.HORIZONTAL)
blankersizer.AddStretchSpacer()
blankersizer.Add(self.goblank, 0, wx.RIGHT|wx.ALIGN_CENTER, 10)
blankersizer.Add(self.golive, 0, wx.ALIGN_CENTER)
blankersizer.AddStretchSpacer()
mainsizer = wx.BoxSizer(wx.VERTICAL)
mainsizer.Add(oospanel, 1, wx.GROW|wx.BOTTOM, 10)
mainsizer.Add(blankersizer, 0, wx.GROW)
self.SetSizer(mainsizer)
# vim: autoindent shiftwidth=4 expandtab textwidth=80

View File

@ -5,8 +5,8 @@ wx.Frame for the main OpenLP.org window
"""
import wx
import mainpanel
import controlpanel
import canvas
class MainFrame(wx.Frame):
"Main OpenLP.org frame"
@ -19,68 +19,73 @@ class MainFrame(wx.Frame):
MenuBar = wx.MenuBar()
FileMenu = wx.Menu()
item = FileMenu.Append(wx.ID_EXIT, text = "&Exit")
self.Bind(wx.EVT_MENU, self.OnQuit, item)
item = FileMenu.Append(wx.ID_ANY, text = "&Open")
self.Bind(wx.EVT_MENU, self.OnOpen, item)
item = FileMenu.Append(wx.ID_PREFERENCES, text = "&Preferences")
self.Bind(wx.EVT_MENU, self.OnPrefs, item)
MenuBar.Append(FileMenu, "&File")
HelpMenu = wx.Menu()
item = HelpMenu.Append(wx.ID_HELP, "OpenLP.org &Help")
self.Bind(wx.EVT_MENU, self.OnHelp, item)
# This gets put in the App menu on OS X
item = HelpMenu.Append(wx.ID_ABOUT, "&About")
self.Bind(wx.EVT_MENU, self.OnAbout, item)
MenuBar.Append(HelpMenu, "&Help")
self.SetMenuBar(MenuBar)
self.MainSplitter = wx.SplitterWindow(self, size=self.GetClientSize(), style=wx.SP_3D)
self.PreviewSplitter = wx.SplitterWindow(self.MainSplitter, size=self.MainSplitter.GetClientSize(), style=wx.SP_3D)
self.LiveSplitter = wx.SplitterWindow(self.MainSplitter, size=self.MainSplitter.GetClientSize(), style=wx.SP_3D)
LiveControlPanel = controlpanel.ControlPanel(self.LiveSplitter,title="Live")
PreviewControlPanel = controlpanel.ControlPanel(self.PreviewSplitter,title="Preview")
LiveCanvas = canvas.Canvas(self.LiveSplitter)
PreviewCanvas = canvas.Canvas(self.PreviewSplitter)
self.Panel = mainpanel.MainPanel(self)
self.MainSplitter.SplitVertically(self.PreviewSplitter, self.LiveSplitter)
self.LiveSplitter.SplitHorizontally(LiveControlPanel,LiveCanvas)
self.PreviewSplitter.SplitHorizontally(PreviewControlPanel,PreviewCanvas)
self.MainSplitter.SetMinimumPaneSize(200)
self.LiveSplitter.SetMinimumPaneSize(200)
self.PreviewSplitter.SetMinimumPaneSize(200)
self.Fit()
self.MainSplitter.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.MainSplitterOnChanged)
self.LiveSplitter.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.LiveSplitterOnChanged)
self.PreviewSplitter.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.PreviewSplitterOnChanged)
self.Bind(wx.EVT_SIZE, self.OnSize)
MainSizer = wx.BoxSizer(wx.HORIZONTAL)
MediaManagerFrame = wx.Panel(self, size=wx.Size(200,200))
OrderOfServiceFrame = wx.Panel(self, size=wx.Size(200,200))
self.SetSizer(MainSizer)
MainSizer.Add(MediaManagerFrame, flag=wx.EXPAND)
MainSizer.Add(self.MainSplitter, proportion=1, flag=wx.EXPAND)
MainSizer.Add(OrderOfServiceFrame, flag=wx.EXPAND)
self.CreateStatusBar(1)
self.SetStatusText("openlp.org")
MainSizer.SetSizeHints(self)
def OnQuit(self,Event):
self.Destroy()
def OnAbout(self, event):
dlg = wx.MessageDialog(self, "This is a small program to test\n"
"the use of menus on Mac, etc.\n",
"About Me", wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
def OnHelp(self, event):
dlg = wx.MessageDialog(self, "This would be help\n"
"If there was any\n", "Test Help", wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
def OnOpen(self, event):
dlg = wx.MessageDialog(self, "This would be an open Dialog\n"
"If there was anything to open\n", "Open File",
wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
def OnPrefs(self, event):
dlg = wx.MessageDialog(self, "This would be an preferences Dialog\n"
"If there were any preferences to set.\n",
"Preferences", wx.OK | wx.ICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
# vim: autoindent shiftwidth=4 expandtab textwidth=80
self.SetAutoLayout(True)
self.Layout()
def MainSplitterOnChanged(self,event):
self.MainSplitter.SetSashPosition(self.MainSplitter.GetClientSize().GetWidth()/2,True)
def LiveSplitterOnChanged(self,event):
WindowList = self.LiveSplitter.GetChildren()
for Node in WindowList:
Node.Refresh()
def PreviewSplitterOnChanged(self,event):
WindowList = self.PreviewSplitter.GetChildren()
for Node in WindowList:
Node.Refresh()
def OnSize(self,event):
self.Layout()
self.MainSplitterOnChanged(event)
self.LiveSplitterOnChanged(event)
self.PreviewSplitterOnChanged(event)

View File

@ -1,30 +0,0 @@
"""
wx.Panel for operator interface
"""
import wx
import controller
import leftpanel
class MainPanel(wx.Panel):
"Operator interface"
def __init__(self, parent, *args, **kwargs):
"Panel constructor"
wx.Panel.__init__(self, parent, *args, **kwargs)
controlbook = controller.Controller(self, size=wx.Size(400,300))
leftside = leftpanel.LeftPanel(self)
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(leftside, 0, wx.GROW|wx.TOP|wx.BOTTOM|wx.LEFT, 15)
sizer.Add(controlbook, 1, wx.GROW|wx.ALL, 15)
self.SetSizerAndFit(sizer)
sizer.SetSizeHints(parent)
# vim: autoindent shiftwidth=4 expandtab textwidth=80

31
oos.py
View File

@ -1,31 +0,0 @@
"""
Order of Service panel
"""
# TODO: change this from a list box to our own custom widget to allow the
# traditional OpenLP OOS entry with an icon
import wx
class OrderOfService(wx.Panel):
"Order Of Service Panel"
def __init__(self, parent, *args, **kwargs):
"Panel constructor"
wx.Panel.__init__(self, parent, *args, **kwargs)
sizer = wx.BoxSizer(wx.VERTICAL)
self.list = wx.ListBox(self, size=wx.Size(180, 250))
self.list.Append("foo")
sizer.Add(self.list, 1)
#sizer.Add(self.list, 1, wx.GROW)
self.SetSizer(sizer)
# vim: autoindent shiftwidth=4 expandtab textwidth=80

View File

@ -13,7 +13,7 @@ import mainframe
class OpenLP(wx.PySimpleApp):
def OnInit(self):
frame = mainframe.MainFrame(None, title="OpenLP.org")
frame = mainframe.MainFrame(None, title="openlp.org")
frame.Show()
import sys
@ -33,10 +33,6 @@ class OpenLP(wx.PySimpleApp):
"File Opened", wx.OK|wx.ICON_INFORMATION)
def MacOpenFile(self, filename):
self.OpenFileMessage(filename)
if __name__ == '__main__':
app = OpenLP()
app.MainLoop()

80
slide.py Normal file
View File

@ -0,0 +1,80 @@
import wx
class Slide(wx.Window):
SlideNum = 0
Selected = False
SlideText = ""
SlideType = ""
def __init__(self, parent, slideText, slideNum, slideType, *args, **kwargs):
wx.Window.__init__(self, parent, *args, **kwargs)
self.SlideText = slideText
self.SlideNum = slideNum
self.SlideType = slideType
self.Bind(wx.EVT_MOUSEDOWN, self.OnMouseDown)
self.Bind(wx.EVT_PAINT, self.OnPaint)
def GetHeight(self):
DC = wx.ClientDC(self)
DC.SetFont(wx.Font(pointSize=8, family=wx.FONTFAMILY_MODERN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL,underline=False,face="Tahoma"))
FontHeight = DC.GetTextExtent("by")[1]
Tokenizer = wx.StringTokenizer(self.SlideText,"\n")
ArrayString = wx.ArrayString()
while Tokenizer.HasMoreTokens():
Token = Tokenizer.GetNextToken()
ArrayString.Add(Token)
return FontHeight*(ArrayString.Count()+1)
def GetIndex(self):
return self.SlideNum
def SetSelected(self):
if not self.Selected:
self.Selected = True
Refresh()
def DropSelected(self):
if self.Selected:
self.Selected = False
Refresh()
def OnPaint(self, event):
DC = wx.PaintDC(self)
DC.SetFont(wx.Font(pointSize=9, family=wx.FONTFAMILY_MODERN, style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL,underline=False,face="Tahoma"))
if self.Selected:
Colour = wx.Colour(0,26,102)
else:
Colour = wx.Colour(55,102,255)
DC.SetBrush(wx.Brush(Colour))
DC.SetPen(wx.Pen(Colour))
FontHeight = DC.GetTextExtent("by")[1]
DC.DrawRectangle(0,0,self.GetParent().GetSize().GetWidth(),FontHeight)
DC.SetTextForeground(wx.Colour(255,255,255))
DC.DrawText(self.SlideType,5,0)
Tokenizer = wx.StringTokenizer(self.SlideText,"\n")
ArrayString = wx.ArrayString()
while Tokenizer.HasMoreTokens():
Token = Tokenizer.GetNextToken()
ArrayString.Add(Token)
self.SetSize(wx.Size(self.GetParent().GetSize().GetWidth(),FontHeight*(ArrayString.Count()+1)))
DC.SetBrush(wx.Brush(wx.Colour(255,255,255)))
DC.SetPen(wx.Pen(wx.Colour(255,255,255)))
DC.DrawRectangle(0,FontHeight,self.GetSize().GetWidth(),self.GetSize().GetHeight()-FontHeight)
DC.SetTextForeGround(wx.Colour(0,0,0))
for i in range(0,ArrayString.Count()):
DC.DrawText(ArrayString.Item(i),5,(i+1)*FontHeight)
def OnMouseDown(self, event):
self.GetParent().SetSelected(self.SlideNum)

30
slidepanel.py Normal file
View File

@ -0,0 +1,30 @@
import wx
import slide
class SlidePanel(wx.Window):
SlideEnum = 1
NextY = 0
def __init__(self, parent, *args, **kwargs):
wx.Window.__init__(self, parent, *args, **kwargs)
def AddSlide(self, slideText, slideType):
slide = slide.Slide(self, pos=wx.Point(0,self.NextY+10), slideText=slideText, slideNum=self.SlideEnum, slideType=slideType)
self.SlideEnum = self.SlideEnum+1
self.NextY = self.NextY + slide.GetHeight()+10
self.SetVirtualSize(self.GetSize().GetWidth(),self.NextY)
self.SetScrollRate(1,1)
slide.Refresh()
def SetSelected(self, index):
WindowList = self.GetChildren()
for Node in WindowList:
Current = Node.GetData()
if Current.GetIndex() == index:
Current.SetSelected()
else:
Current.DropSelected()