From 8e912248d54765a66e7f99433fce55e6a2b4fb98 Mon Sep 17 00:00:00 2001 From: Timothy Ebenezer Date: Tue, 4 Mar 2008 01:08:01 +0000 Subject: [PATCH] Rearranging and adding MediaManager class also redefined plugin Interface bzr-revno: 9 --- openlp.pyw | 40 +++++++++++ openlp/__init__.py | 0 openlp/controls/__init__.py | 0 canvas.py => openlp/controls/canvas.py | 0 .../controls/controlpanel.py | 2 +- openlp/controls/mediamanager.py | 32 +++++++++ slide.py => openlp/controls/slide.py | 0 .../controls/slidepanel.py | 2 +- openlp/ui/__init__.py | 0 mainframe.py => openlp/ui/mainframe.py | 21 +++--- plugin.py | 69 +++---------------- 11 files changed, 95 insertions(+), 71 deletions(-) create mode 100755 openlp.pyw create mode 100644 openlp/__init__.py create mode 100644 openlp/controls/__init__.py rename canvas.py => openlp/controls/canvas.py (100%) rename controlpanel.py => openlp/controls/controlpanel.py (98%) create mode 100644 openlp/controls/mediamanager.py rename slide.py => openlp/controls/slide.py (100%) rename slidepanel.py => openlp/controls/slidepanel.py (96%) create mode 100644 openlp/ui/__init__.py rename mainframe.py => openlp/ui/mainframe.py (91%) diff --git a/openlp.pyw b/openlp.pyw new file mode 100755 index 000000000..1676459f3 --- /dev/null +++ b/openlp.pyw @@ -0,0 +1,40 @@ +#!/usr/bin/env pythonw + +""" + +Entry point for OpenLP wx.App + +""" + +import wx + +from openlp.ui import mainframe + + +class OpenLP(wx.PySimpleApp): + def OnInit(self): + frame = mainframe.MainFrame(None, title="openlp.org") + frame.Show() + + import sys + for f in sys.argv[1:]: + self.OpenFileMessage(f) + + return True; + + + def OpenFileMessage(self, filename): + + # TODO: OOS loading here + # rename function, too + + dlg = wx.MessageDialog(None, + "This app was just asked to open:\n%s\n"%filename, + "File Opened", wx.OK|wx.ICON_INFORMATION) + + +if __name__ == '__main__': + app = OpenLP() + app.MainLoop() + +# vim: autoindent shiftwidth=4 expandtab textwidth=80 diff --git a/openlp/__init__.py b/openlp/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/openlp/controls/__init__.py b/openlp/controls/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/canvas.py b/openlp/controls/canvas.py similarity index 100% rename from canvas.py rename to openlp/controls/canvas.py diff --git a/controlpanel.py b/openlp/controls/controlpanel.py similarity index 98% rename from controlpanel.py rename to openlp/controls/controlpanel.py index 5ab1061e5..1d2ac81f9 100644 --- a/controlpanel.py +++ b/openlp/controls/controlpanel.py @@ -6,7 +6,7 @@ The openlp.org Control Panel import wx -import slidepanel +from openlp.controls import slidepanel class ControlPanel(wx.Window): diff --git a/openlp/controls/mediamanager.py b/openlp/controls/mediamanager.py new file mode 100644 index 000000000..f30e3fb6f --- /dev/null +++ b/openlp/controls/mediamanager.py @@ -0,0 +1,32 @@ +import wx + +class MediaManager(wx.Window): + + def __init__(self, parent, *args, **kwargs): + wx.Window.__init__(self, parent, *args, **kwargs) + MainSizer = wx.BoxSizer(wx.VERTICAL) + + MainSizer.AddSpacer(20) + + if wx.Platform == "__WXMAC__": + self.Notebook = wx.Choicebook(self, size=wx.Size(200,200)) + else: + self.Notebook = wx.Notebook(self, size=wx.Size(200,200)) + + MainSizer.Add(self.Notebook, proportion=1, flag=wx.EXPAND) + + self.SetSizer(MainSizer) + self.SetAutoLayout(True) + self.Layout() + + self.Bind(wx.EVT_PAINT, self.OnPaint) + self.Bind(wx.EVT_SIZE, self.OnSize) + + 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")) + DC.GradientFillLinear(wx.Rect(1,1,self.GetSize().GetWidth()-2,DC.GetTextExtent("by")[1]+2), wx.Colour(220,220,220), wx.Colour(255,255,255)) + DC.DrawText("Media Manager", 6, 2) + + def OnSize(self, event): + self.Layout() \ No newline at end of file diff --git a/slide.py b/openlp/controls/slide.py similarity index 100% rename from slide.py rename to openlp/controls/slide.py diff --git a/slidepanel.py b/openlp/controls/slidepanel.py similarity index 96% rename from slidepanel.py rename to openlp/controls/slidepanel.py index 8490ca41f..2243a3298 100644 --- a/slidepanel.py +++ b/openlp/controls/slidepanel.py @@ -1,6 +1,6 @@ import wx -import slide +from openlp.controls import slide class SlidePanel(wx.Window): diff --git a/openlp/ui/__init__.py b/openlp/ui/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/mainframe.py b/openlp/ui/mainframe.py similarity index 91% rename from mainframe.py rename to openlp/ui/mainframe.py index fd9bf4d12..6e6f1ec1c 100644 --- a/mainframe.py +++ b/openlp/ui/mainframe.py @@ -5,8 +5,9 @@ wx.Frame for the main OpenLP.org window """ import wx -import controlpanel -import canvas +from openlp.controls import controlpanel +from openlp.controls import canvas +from openlp.controls import mediamanager class MainFrame(wx.Frame): "Main OpenLP.org frame" @@ -40,19 +41,14 @@ class MainFrame(wx.Frame): self.LiveSplitter.SetMinimumPaneSize(200) self.PreviewSplitter.SetMinimumPaneSize(200) - 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)) + MediaManager = mediamanager.MediaManager(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(MediaManager, flag=wx.EXPAND) MainSizer.Add(self.MainSplitter, proportion=1, flag=wx.EXPAND) MainSizer.Add(OrderOfServiceFrame, flag=wx.EXPAND) @@ -64,7 +60,12 @@ class MainFrame(wx.Frame): self.SetAutoLayout(True) self.Layout() - + + 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) + def MainSplitterOnChanged(self,event): self.MainSplitter.SetSashPosition(self.MainSplitter.GetClientSize().GetWidth()/2,True) diff --git a/plugin.py b/plugin.py index 6e683e64b..534c66de1 100644 --- a/plugin.py +++ b/plugin.py @@ -1,68 +1,19 @@ """ -Custom classes for plugins +Base Plugin class """ -import wx - -# OOSItem should be extended into a plugin-specific object that encapsulates -# the data needed for that plugin to reference back to its internal data -# (like the songid or the path to a video file) -class OOSItem: - "'Order of Service' entry item" - - def __init__(self): - "OOSItem constructor" - - self.title = "Scaffold item" - - def gettitle(self): - "Accessor for title" - - return self.title - - def golive(self, window): - "Display this item onscreen" - pass - - def blank(self, window): - "Blank the screen, plugin is allowed to keep data ready" - pass - - def stop(self, window): - "Stop this plugin and destroy any canvases" - pass - - -# OLPPlugin describes a base class which will be extended by the each particular -# plugin. The plugin provides a series of objects to the host application: -# * panel to add to the control interface (class Controller) -# * operations for `go live', `[un]blank', `stop' -class OLPPlugin(wx.Panel): +class Plugin(Interface): "Plugin type" - 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) + def __init__(self, mediaManager, *args, **kwargs): + "Plugin constructor called with mediaManager argument which allows adding to the + mediaManager - generally adding a page to mediaManager.Notebook" + + def GetName(): + "Return the plugins name for future plugin manager" + + # vim: autoindent shiftwidth=4 expandtab textwidth=80