dabo Commit
Revision 6977
Date: 2011-11-24 16:56:11 -0800 (Thu, 24 Nov 2011)
Author: Nate
Trac: http://trac.dabodev.com/changeset/6977

Changed:
U   trunk/dabo/ui/uiwx/dLinePlot.py
A   trunk/demo/samples/dLinePlot.py

Log:
Fixed dLinePlot from crashing when you instantiated an object with no traces 
defined.

Added a demo for the dLinePlot object.  It's super simple at the moment and I 
plan on fleshing it out more.

Diff:
Modified: trunk/dabo/ui/uiwx/dLinePlot.py
===================================================================
--- trunk/dabo/ui/uiwx/dLinePlot.py     2011-11-24 15:11:03 UTC (rev 6976)
+++ trunk/dabo/ui/uiwx/dLinePlot.py     2011-11-25 00:56:11 UTC (rev 6977)
@@ -159,7 +159,8 @@
                self.SetPointLabelFunc(self.DrawPointLabel)
 
                self.setDefaults()
-               self.Draw(self._plotManager)
+               if len(self.Traces) != 0:
+                       self.Draw(self._plotManager)
 
        def appendLineFromEquation(self, equation, Start, End, points=1000.0, 
LineColor='black', LineStyle='solid',
                                               LineWidth=1, Caption=""):
@@ -183,7 +184,7 @@
                line.LineStyle = LineStyle
 
                self.Traces.append(line)
-               self.Redraw
+               self.Redraw()
 
        def appendMarkerFromPoints(self, points, Color='black', 
MarkerShape='circle', Width=1,
                                           FillStyle='solid', MarkerSize=2, 
Caption=""):
@@ -194,7 +195,7 @@
                marker.FillStyle = FillStyle
 
                self.Traces.append(marker)
-               self.Redraw
+               self.Redraw()
 
        def OnSize(self,event):
                # The Buffer init is done here, to make sure the buffer is 
always
@@ -219,7 +220,7 @@
        def DrawPointLabel(self, dc, mDataDict):
                """
                This is the fuction that defines how the pointLabels are plotted
-               
+
                        dc - DC that will be passed
                        mDataDict - Dictionary of data that you want to use for 
the pointLabel
 

Added: trunk/demo/samples/dLinePlot.py
===================================================================
--- trunk/demo/samples/dLinePlot.py                             (rev 0)
+++ trunk/demo/samples/dLinePlot.py     2011-11-25 00:56:11 UTC (rev 6977)
@@ -0,0 +1,79 @@
+# -*- coding: utf-8 -*-
+import dabo
+dabo.ui.loadUI("wx")
+import dabo.dEvents as dEvents
+from dabo.dLocalize import _
+import numpy.oldnumeric as _Numeric
+
+class TestPanel(dabo.ui.dPanel):
+       def afterInit(self):
+               self.linePlot = self.createLinePlot()
+
+               sz = self.Sizer = dabo.ui.dSizer("h")
+               sz.append(self.createControlPanel(self.linePlot), "expand")
+               sz.appendSpacer(10)
+               sz.append1x(self.linePlot)
+
+
+       def createControlPanel(self, linePlot):
+               bs = dabo.ui.dBorderSizer(self, Caption="Control Panel", 
orientation="v")
+               gs = dabo.ui.dGridSizer(MaxCols=2, HGap=5, VGap=5)
+               gs.setColExpand(True, 1)
+
+               txtTitle = dabo.ui.dTextBox(self, DataSource=linePlot, 
DataField="Caption", Width=200)
+               txtXAxisLabel = dabo.ui.dTextBox(self, DataSource=linePlot, 
DataField="XAxisLabel")
+               txtYAxisLabel = dabo.ui.dTextBox(self, DataSource=linePlot, 
DataField="YAxisLabel")
+
+               gs.append(dabo.ui.dLabel(self, Caption="Title"), halign="right")
+               gs.append(txtTitle, "expand")
+
+               gs.append(dabo.ui.dLabel(self, Caption="X Axis Label"), 
halign="right")
+               gs.append(txtXAxisLabel, "expand")
+
+               gs.append(dabo.ui.dLabel(self, Caption="Y Axis Label"), 
halign="right")
+               gs.append(txtYAxisLabel, "expand")
+
+               bs.append(gs, 'x')
+               return bs
+
+
+       def createLinePlot(self):
+               linePlot = dabo.ui.dLinePlot(self)
+               linePlot.XAxisLabel = "X Axis"
+               linePlot.YAxisLabel = "Y Axis"
+               linePlot.Caption = "Title of Graph"
+
+               # 1000 points cos function, plotted as blue line
+               linePlot.appendLineFromEquation("2*_Numeric.cos(%s)", 5, 10, 
Caption="Blue Line", LineWidth=2, LineColor='blue')
+
+               line = []
+               for i in range(10):
+                       line.append((i, float(i)/2))
+               linePlot.appendLineFromPoints(line)
+
+               data1 = 2.*_Numeric.pi*_Numeric.arange(200)/200.
+               data1.shape = (100, 2)
+               data1[:,1] = _Numeric.sin(data1[:,0])
+               linePlot.appendMarkerFromPoints(data1, Caption='Green Markers', 
Color='green', MarkerShape='circle', MarkerSize=1)
+
+               # A few more points...
+               points = [(0., 0.), (_Numeric.pi/4., 1.), (_Numeric.pi/2, 0.), 
(3.*_Numeric.pi/4., -1)]
+               linePlot.appendMarkerFromPoints(points, Caption='Cross Legend', 
Color='blue', MarkerShape='cross')
+
+               linePlot.Draw(linePlot._plotManager)
+
+               return linePlot
+
+
+category = "Controls.dLinePlot"
+
+overview = """
+<p><b>A Line Plot</b> allows you to present data in a graph form.  The graph 
can have
+as many lines as necessary that can be generated either by an equation on by 
data points.
+</p>
+
+<p><b>dLinePlot</b> is the class that controlls this. The user can
+control a multitude of properties include label content and apperance, 
placement
+of different components of the graph, title and legend information, and much
+more.  The Apperance of the graph can be completely customized within Dabo.</p>
+"""



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to