dabodemo Commit
Revision 484
Date: 2007-01-16 06:43:48 -0800 (Tue, 16 Jan 2007)
Author: Ed

Changed:
U   branches/stable/DaboDemo/samples/dEditBox.py
A   branches/stable/DaboDemo/samples/dGauge.py
A   branches/stable/DaboDemo/samples/dGrid.py
U   branches/stable/DaboDemo/samples/dLabel.py
A   branches/stable/DaboDemo/samples/dSlider.py

Log:
Added some additional demos that work with the stable code.


Diff:
Modified: branches/stable/DaboDemo/samples/dEditBox.py
===================================================================
--- branches/stable/DaboDemo/samples/dEditBox.py        2007-01-13 00:08:29 UTC 
(rev 483)
+++ branches/stable/DaboDemo/samples/dEditBox.py        2007-01-16 14:43:48 UTC 
(rev 484)
@@ -9,14 +9,14 @@
                sz = self.Sizer = dabo.ui.dSizer("v")
                sz.appendSpacer(25)
                
-               self.edt = dabo.ui.dEditBox(self, Width=300, Height=160)
+               self.edt = dabo.ui.dEditBox(self, Width=400, Height=200)
                self.edt.Value = self.getGetty()
-               sz.append(self.edt)
+               sz.append(self.edt, halign="center")
                sz.appendSpacer(10)
 
                btn = dabo.ui.dButton(self, Caption="Selection Info")
                btn.bindEvent(dEvents.Hit, self.onSelectionInfo)
-               sz.append(btn)
+               sz.append(btn, halign="center")
                
        
        def onSelectionInfo(self, evt):

Added: branches/stable/DaboDemo/samples/dGauge.py
===================================================================
--- branches/stable/DaboDemo/samples/dGauge.py  2007-01-13 00:08:29 UTC (rev 
483)
+++ branches/stable/DaboDemo/samples/dGauge.py  2007-01-16 14:43:48 UTC (rev 
484)
@@ -0,0 +1,73 @@
+import random
+import dabo
+dabo.ui.loadUI("wx")
+import dabo.dEvents as dEvents
+from dabo.dLocalize import _
+
+
+class TestPanel(dabo.ui.dPanel):
+       def afterInit(self):
+               sz = self.Sizer = dabo.ui.dSizer("v")
+               sz.appendSpacer(25)
+               
+               bsz = dabo.ui.dBorderSizer(self, "v", Caption="Horizontal 
Gauge")
+               self.gaugeH = dabo.ui.dGauge(self)
+               bsz.append(self.gaugeH, "x", border=30, 
+                       borderSides=("Left", "Right"))
+               
+               self.lblH = dabo.ui.dLabel(self)
+               bsz.append(self.lblH, halign="center")
+               sz.append(bsz, "x", halign="center", border=20, 
borderSides=("Left", "Right"))
+               sz.appendSpacer(50)
+               
+               hsz = dabo.ui.dBorderSizer(self, "h", Caption="Vertical Gauge")
+               self.gaugeV = dabo.ui.dGauge(self, Orientation="v")
+               hsz.append(self.gaugeV, "x", border=30, borderSides=("Left", 
"Right"), halign="center")
+               hsz.appendSpacer(10)
+               
+               self.lblV = dabo.ui.dLabel(self)
+               hsz.append(self.lblV, valign="middle")
+               sz.append(hsz, 1, halign="center")
+               
+               self.tmr = dabo.ui.callEvery(500, self.updateGauges)
+               self.update()
+               self.layout()
+               
+               
+               
+       def updateGauges(self):
+               increase = random.randrange(3,10)
+               gh = self.gaugeH
+               val = gh.Value + increase 
+               if val > gh.Range:
+                       val -= gh.Range
+               gh.Value = val
+               self.lblH.Caption = "%s%% complete" % int(gh.Percentage)
+
+               increase = random.randrange(3,10)
+               gv = self.gaugeV
+               val = gv.Value + increase 
+               if val > gv.Range:
+                       val -= gv.Range
+               gv.Value = val
+               self.lblV.Caption = "%s%% complete" % int(gv.Percentage)
+               self.layout()
+       
+       def onDestroy(self, evt):
+               self.tmr.stop()
+
+
+category = "controls.dGauge"
+
+overview = """
+<p>A <b>dGauge</b> is a horizontal or vertical bar which shows a quantity in a 
graphical 
+fashion. It is often used to indicate progress through lengthy tasks, such as 
file copying or 
+data analysis.</p>
+
+<p>You set the Range property of dGauge to set the 'total' for the task, and 
then update it 
+by setting the <b>Value</b> property to the current value; the gauge then 
updates to 
+reflect the percentage of the total for that value. You can alternately set 
the <b>Percentage</b> 
+property, and the appropriate Value for that Percentage will be set.</p>
+
+<p>Gauges do not raise any events, or respond to user interaction. They are 
simply a convenient way to display the progress of a task or process.</p>
+"""


Property changes on: branches/stable/DaboDemo/samples/dGauge.py
___________________________________________________________________
Name: svn:eol-style
   + native

Added: branches/stable/DaboDemo/samples/dGrid.py
===================================================================
--- branches/stable/DaboDemo/samples/dGrid.py   2007-01-13 00:08:29 UTC (rev 
483)
+++ branches/stable/DaboDemo/samples/dGrid.py   2007-01-16 14:43:48 UTC (rev 
484)
@@ -0,0 +1,151 @@
+import dabo
+dabo.ui.loadUI("wx")
+import dabo.dEvents as dEvents
+from dabo.dLocalize import _
+
+
+class DemoGrid(dabo.ui.dGrid):
+       def initProperties(self):
+               self.DataSet = [
+                               {"name" : "Ed Leafe", "age" : 49, "coder" :  
True, "color": "cornsilk"},
+                               {"name" : "Paul McNett", "age" : 37, "coder" :  
True, "color": "wheat"},
+                               {"name" : "Ted Roche", "age" : 48, "coder" :  
True, "color": "goldenrod"},
+                               {"name" : "Derek Jeter", "age": 32 , "coder" :  
False, "color": "white"},
+                               {"name" : "Halle Berry", "age" : 38, "coder" :  
False, "color": "orange"},
+                               {"name" : "Steve Wozniak", "age" : 56, "coder" 
:  True, "color": "yellow"},
+                               {"name" : "LeBron James", "age" : 22, "coder" : 
 False, "color": "gold"},
+                               {"name" : "Madeline Albright", "age" : 69, 
"coder" :  False, "color": "red"}]
+               self.Editable = True
+               #self.Sortable = False
+               #self.Searchable = False
+
+       def afterInit(self):
+               col = dabo.ui.dColumn(self, Name="Geek", Order=10, 
DataField="coder",
+                               DataType="bool", Width=60, Caption="Geek?", 
Sortable=False,
+                               Searchable=False, Editable=True)
+               self.addColumn(col)
+
+               col.CustomRenderers[1] = col.stringRendererClass
+               col.CustomEditors[1] = col.stringEditorClass
+               col.HeaderFontBold = False
+
+               col = dabo.ui.dColumn(self, Name="Person", Order=20, 
DataField="name",
+                               DataType="string", Width=200, 
Caption="Celebrity Name",
+                               Sortable=True, Searchable=True, Editable=True, 
Expand=True)
+               self.addColumn(col)
+               
+               col.HeaderFontItalic = True
+               col.HeaderBackColor = "orange"
+               col.HeaderVerticalAlignment = "Top"
+               col.HeaderHorizontalAlignment = "Left"
+
+               self.addColumn(Name="Age", Order=30, DataField="age",
+                               DataType="integer", Width=40, Caption="Age",
+                               Sortable=True, Searchable=True, Editable=True)
+
+               col = dabo.ui.dColumn(self, Name="Color", Order=40, 
DataField="color",
+                               DataType="string", Width=40, Caption="Favorite 
Color",
+                               Sortable=True, Searchable=True, Editable=True, 
Expand=True)
+               self.addColumn(col)
+
+               col.ListEditorChoices = dabo.dColors.colors
+               col.CustomEditorClass = col.listEditorClass
+
+               col.HeaderVerticalAlignment = "Bottom"
+               col.HeaderHorizontalAlignment = "Right"
+               col.HeaderForeColor = "brown"
+
+               self.RowLabels = ["a", "b", "c", "d", "e", "f", "g", "h", "i", 
"j"]
+
+
+
+class TestPanel(dabo.ui.dPanel):
+       def afterInit(self):
+               sz = self.Sizer = dabo.ui.dSizer("v")
+               sz.appendSpacer(20)
+               
+               txt = _("Click on a column's header to sort on that column. The 
leftmost column is set to not be sortable, though. " + 
+                               "You can also drag the columns to re-arrange 
their order. Right-clicking on a column header gives you auto-size " + 
+                               "choices. You can also drag the lines between 
columns or rows to manually change their size.")
+               lbl = dabo.ui.dLabel(self, Alignment="center", Height=70, 
Caption=txt)
+               lbl.DynamicWidth = lambda: self.Parent.Width * 0.8
+               lbl.FontSize -= 1
+               
+               sz.append(lbl, halign="center")
+               sz.appendSpacer(15)
+               
+               self.grid = DemoGrid(self)
+               sz.append(self.grid, 2, "x", border=40, borderSides=("left", 
"right"))
+               sz.appendSpacer(20)                     
+               gsz = dabo.ui.dGridSizer(HGap=15)
+               
+               chk = dabo.ui.dCheckBox(self, Caption="Allow Editing?",
+                               DataSource=self.grid, DataField="Editable")
+               chk.refresh()
+               gsz.append(chk, row=0, col=0)
+               
+               chk = dabo.ui.dCheckBox(self, Caption="Show Row Labels", 
+                               DataSource=self.grid, DataField="ShowRowLabels")
+               gsz.append(chk, row=1, col=0)
+               chk.refresh()
+               
+               chk = dabo.ui.dCheckBox(self, Caption="Size All Rows 
Together?", 
+                               DataSource=self.grid, DataField="SameSizeRows")
+               gsz.append(chk, row=2, col=0)
+               chk.refresh()
+               
+               chk = dabo.ui.dCheckBox(self, Caption="Alternate Row 
Coloring?", 
+                               DataSource=self.grid, 
DataField="AlternateRowColoring")
+               gsz.append(chk, row=3, col=0)
+               chk.refresh()
+               
+               chk = dabo.ui.dCheckBox(self, Caption="Show Cell Borders?", 
+                               DataSource=self.grid, 
DataField="ShowCellBorders")
+               gsz.append(chk, row=0, col=1)
+               chk.refresh()
+               
+               chk = dabo.ui.dCheckBox(self, Caption="Allow Multiple 
Selection?", 
+                               DataSource=self.grid, 
DataField="MultipleSelection")
+               chk.refresh()
+               gsz.append(chk, row=1, col=1)
+
+               chk = dabo.ui.dCheckBox(self, Caption="Allow Row Resizing?", 
+                               DataSource=self.grid, DataField="ResizableRows")
+               chk.refresh()
+               gsz.append(chk, row=2, col=1)
+
+               chk = dabo.ui.dCheckBox(self, Caption="Allow Column Resizing?", 
+                               DataSource=self.grid, 
DataField="ResizableColumns")
+               chk.refresh()
+               gsz.append(chk, row=3, col=1)
+
+               radSelect = dabo.ui.dRadioList(self, Choices=["Row", "Col", 
"Cell"],
+                               ValueMode="string", Caption="Sel Mode",
+                               DataSource=self.grid, DataField="SelectionMode")
+               radSelect.refresh()
+               gsz.append(radSelect, row=0, col=2, rowSpan=4)
+               
+               sz.append(gsz, halign="Center", border=10)
+               gsz.setColExpand(True, 2)
+               
+               btn = dabo.ui.dButton(self, Caption="Set Col.1 Header Color")
+               btn.bindEvent(dEvents.Hit, self.onSetHeadColor)
+               sz.append(btn, halign="center")
+               sz.appendSpacer(4)
+               dabo.ui.callAfter(self.update)
+               dabo.ui.callAfter(self.layout)
+
+       def onSetHeadColor(self, evt):
+               c1 = self.grid.Columns[1]
+               bc = c1.HeaderBackColor
+               new = dabo.ui.getColor(bc)
+               if new:
+                       c1.HeaderBackColor = new
+
+
+category = "controls.dGrid"
+
+overview = """
+<p>The <b>dGrid</b> class is used to display (and optionally edit) 
+tabular data. 
+"""


Property changes on: branches/stable/DaboDemo/samples/dGrid.py
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: branches/stable/DaboDemo/samples/dLabel.py
===================================================================
--- branches/stable/DaboDemo/samples/dLabel.py  2007-01-13 00:08:29 UTC (rev 
483)
+++ branches/stable/DaboDemo/samples/dLabel.py  2007-01-16 14:43:48 UTC (rev 
484)
@@ -77,7 +77,8 @@
                lbl.BackColor = "yellow"
                sz.append(lbl)
                
-               ## Add back to post-0.7 release
+               ## Add back to post-0.7 release when the WordWrap property
+               ## is added to dLabel.
                if False:
                        btn = dabo.ui.dButton(self, Caption=_("Show WordWrap 
demo"))
                        btn.bindEvent(dEvents.Hit, self.onShowWWDemo)

Added: branches/stable/DaboDemo/samples/dSlider.py
===================================================================
--- branches/stable/DaboDemo/samples/dSlider.py 2007-01-13 00:08:29 UTC (rev 
483)
+++ branches/stable/DaboDemo/samples/dSlider.py 2007-01-16 14:43:48 UTC (rev 
484)
@@ -0,0 +1,59 @@
+import dabo
+dabo.ui.loadUI("wx")
+import dabo.dEvents as dEvents
+from dabo.dLocalize import _
+
+
+class TestPanel(dabo.ui.dPanel):
+       def afterInit(self):
+               sz = self.Sizer = dabo.ui.dSizer("v")
+               sz.appendSpacer(25)
+               
+               self.slider = dabo.ui.dSlider(self, Min=0, Max=88, Value=42,
+                               ShowLabels=True)
+               self.slider.bindEvent(dEvents.Hit, self.onSliderHit)
+               sz.append(self.slider, "x", border=30, 
+                       borderSides=("Left", "Right"))
+               sz.appendSpacer(25)
+               
+               lbl = dabo.ui.dLabel(self, Caption="Min:")
+               spn = dabo.ui.dSpinner(self, Max=1000000, 
DataSource=self.slider,
+                               DataField="Min")
+               hsz = dabo.ui.dSizer("h")
+               hsz.append(lbl, valign="middle")
+               hsz.append(spn, valign="middle")
+               sz.append(hsz, halign="center")
+               
+               lbl = dabo.ui.dLabel(self, Caption="Max:")
+               spn = dabo.ui.dSpinner(self, Max=1000000, 
DataSource=self.slider,
+                               DataField="Max")
+               hsz = dabo.ui.dSizer("h")
+               hsz.append(lbl, valign="middle")
+               hsz.append(spn, valign="middle")
+               sz.append(hsz, halign="center")
+               
+               self.update()
+               self.layout()
+
+       def onSliderHit(self, evt):
+               self.Form.logit(_("Hit: Value=%s") % self.slider.Value)
+               
+
+
+
+category = "controls.dSlider"
+
+overview = """
+<p>The <b>dSlider</b> class is a handy UI tool to display a value in relation
+to a range of possible values.</p>
+
+<p>You control the range of the slider using the <b>Min</b> and <b>Max</b> 
+properties, and set its value with the <b>Value</b> property. The slider will 
then 
+display its 'head' in a position proportional to its value in relation to the 
Min and 
+Max values. Dragging the 'head' changes the Value property, and also generates 
+a <b>Hit event</b>.</p>
+
+<p>If the <b>ShowLabels</b> property is True, then the slider will also 
display 
+its Min and Max values, as well as its current Value. Please note that this is 
must be 
+set when the control is created; it has no effect once the control exists.</p>
+"""


Property changes on: branches/stable/DaboDemo/samples/dSlider.py
___________________________________________________________________
Name: svn:eol-style
   + native




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev

Reply via email to