dabodemo Commit
Revision 505
Date: 2007-03-25 13:51:09 -0700 (Sun, 25 Mar 2007)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabodemo/changeset/505

Changed:
U   trunk/DaboDemo/DaboDemo.cdxml
A   trunk/DaboDemo/media/homer.jpg
U   trunk/DaboDemo/samples/dBitmapButton.py
U   trunk/DaboDemo/samples/dDateTextBox.py
U   trunk/DaboDemo/samples/dGrid.py
A   trunk/DaboDemo/samples/dImage.py
U   trunk/DaboDemo/samples/dLabel.py
U   trunk/DaboDemo/samples/dSpinner.py

Log:
Added the dImage demo, which is copied from my PyCon 2007 presentation.

Modified the other controls to accommodate recent changes to the framework.


Diff:
Modified: trunk/DaboDemo/DaboDemo.cdxml
===================================================================
--- trunk/DaboDemo/DaboDemo.cdxml       2007-03-25 12:14:40 UTC (rev 504)
+++ trunk/DaboDemo/DaboDemo.cdxml       2007-03-25 20:51:09 UTC (rev 505)
@@ -103,7 +103,7 @@
        if self.displayFrame.SelectedPageNumber == 0:
                # Switch to the demo
                self.demoPageFrame.showDemoPage()
-       self.demoPanel.layout()
+       self.demoPanel.layout(resetMin=True)
 ]]>
                </loadDemo>
                <treeSelection><![CDATA[
@@ -163,30 +163,26 @@
 
        <dSizer SlotCount="1" designerClass="LayoutSizer" 
Orientation="Vertical">
                <dSplitter SashPosition="201" sizerInfo="{'BorderSides': 
['All'], 'Proportion': 1, 'HAlign': 'Center', 'VAlign': 'Middle', 'Border': 0, 
'Expand': True}" designerClass="controlMix" Split="True" Orientation="Vertical">
-                       <dPanel designerClass="MixedSplitterPanel" 
Name="dPanel2">
+                       <dPanel designerClass="MixedSplitterPanel" 
Name="dPanel2" AlwaysResetSizer="True">
                                <dSizer SlotCount="1" 
designerClass="LayoutSizer" Orientation="Vertical">
                                        <dTreeView RegID="tree" 
sizerInfo="{'BorderSides': ['All'], 'Proportion': 1, 'HAlign': 'Center', 
'VAlign': 'Middle', 'Border': 0, 'Expand': True}" designerClass="controlMix">
                                                <code>
                                                        
<onTreeSelection><![CDATA[
 def onTreeSelection(self, evt):
        self.Form.treeSelection()
-
-
 ]]>
                                                        </onTreeSelection>
                                                </code>
                                        </dTreeView>
                                </dSizer>
                        </dPanel>
-                       <dPanel designerClass="MixedSplitterPanel" 
Name="dPanel1">
+                       <dPanel designerClass="MixedSplitterPanel" 
Name="dPanel1" AlwaysResetSizer="True">
                                <dSizer SlotCount="1" 
designerClass="LayoutSizer" Orientation="Vertical">
                                        <dPageFrameNoTabs RegID="displayFrame" 
sizerInfo="{'BorderSides': ['All'], 'Proportion': 1, 'HAlign': 'Center', 
'VAlign': 'Middle', 'Border': 0, 'Expand': True}" designerClass="controlMix" 
PageCount="2">
                                                <code>
                                                        <showContents><![CDATA[
 def showContents(self, showCode):
        self.SelectedPageNumber = {True: 1, False: 0}[showCode]
-
-
 ]]>
                                                        </showContents>
                                                </code>
@@ -200,8 +196,6 @@
        self.Source = """<div align="center"><img 
src="dabo_lettering_250x100.png"></div>
        <h1 align="center">Dabo Demonstration</h1>
        """
-
-
 ]]>
                                                                                
</afterInit>
                                                                        </code>
@@ -215,8 +209,6 @@
                                                                                
<showDemoPage><![CDATA[
 def showDemoPage(self):
        self.SelectedPageNumber = 2
-
-
 ]]>
                                                                                
</showDemoPage>
                                                                        </code>
@@ -234,8 +226,6 @@
                                                                                
                                <reset><![CDATA[
 def reset(self, hasMod):
        self.enableString("Modified", hasMod)
-
-
 ]]>
                                                                                
                                </reset>
                                                                                
                                <afterInit><![CDATA[
@@ -245,15 +235,13 @@
                                                                                
                                </afterInit>
                                                                                
                        </code>
                                                                                
                </dRadioList>
-                                                                               
                <dPanel Spacing="12" sizerInfo="{'BorderSides': ['All'], 
'Proportion': 0, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': 
True}" designerClass="LayoutSpacerPanel"></dPanel>
+                                                                               
                <dPanel Spacing="12" sizerInfo="{'BorderSides': ['All'], 
'Proportion': 0, 'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': 
True}" designerClass="LayoutSpacerPanel" AlwaysResetSizer="True"></dPanel>
                                                                                
                <dButton RegID="saveModButton" Caption="Save Changes" 
sizerInfo="{'BorderSides': ['All'], 'Proportion': 0, 'HAlign': 'Center', 
'VAlign': 'Middle', 'Border': 5, 'Expand': False}" designerClass="controlMix">
                                                                                
                        <code>
                                                                                
                                <onHit><![CDATA[
 def onHit(self, evt):
        # Save modified code
        self.Form.saveModCode()
-
-
 ]]>
                                                                                
                                </onHit>
                                                                                
                        </code>
@@ -264,8 +252,6 @@
 def onHit(self, evt):
        # Delete modified code
        self.Form.deleteModCode()
-
-
 ]]>
                                                                                
                                </onHit>
                                                                                
                        </code>
@@ -281,8 +267,6 @@
                                                                                
                        <onContentChanged><![CDATA[
 def onContentChanged(self, evt):
        self.Form.editorChanged()
-
-
 ]]>
                                                                                
                        </onContentChanged>
                                                                                
                </code>
@@ -300,25 +284,23 @@
        pos = self.dSplitter.SashPosition
        if pos/ht < .75:
                self.dSplitter.SashPosition = ht * .75
-               self.layout()
-
-
+               self.layout(resetMin=True)
 ]]>
                                                                                
        </onPageEnter>
                                                                                
</code>
 
                                                                                
<dSizer SlotCount="1" designerClass="LayoutSizer" Orientation="Vertical">
                                                                                
        <dSplitter SashPosition="449" sizerInfo="{'BorderSides': ['All'], 
'Proportion': 1, 'HAlign': 'Center', 'VAlign': 'Middle', 'Border': 0, 'Expand': 
True}" designerClass="controlMix" Split="True" Orientation="Horizontal">
-                                                                               
                <dPanel designerClass="MixedSplitterPanel" Name="dPanel2">
+                                                                               
                <dPanel designerClass="MixedSplitterPanel" Name="dPanel2" 
AlwaysResetSizer="True">
                                                                                
                        <dSizer SlotCount="1" designerClass="LayoutSizer" 
Orientation="Vertical">
-                                                                               
                                <dPanel RegID="demoPanel" 
sizerInfo="{'BorderSides': ['All'], 'Proportion': 1, 'HAlign': 'Center', 
'VAlign': 'Middle', 'Border': 0, 'Expand': True}" designerClass="controlMix">
+                                                                               
                                <dPanel RegID="demoPanel" 
sizerInfo="{'BorderSides': ['All'], 'Proportion': 1, 'HAlign': 'Center', 
'VAlign': 'Middle', 'Border': 0, 'Expand': True}" designerClass="controlMix" 
AlwaysResetSizer="True">
                                                                                
                                        <dSizer SlotCount="1" 
designerClass="LayoutSizer" Orientation="Vertical">
                                                                                
                                                <dPanel 
sizerInfo="{'BorderSides': ['All'], 'Proportion': 1, 'HAlign': 'Left', 
'VAlign': 'Top', 'Border': 0, 'Expand': True}" 
designerClass="LayoutPanel"></dPanel>
                                                                                
                                        </dSizer>
                                                                                
                                </dPanel>
                                                                                
                        </dSizer>
                                                                                
                </dPanel>
-                                                                               
                <dPanel designerClass="MixedSplitterPanel" Name="dPanel1">
+                                                                               
                <dPanel designerClass="MixedSplitterPanel" Name="dPanel1" 
AlwaysResetSizer="True">
                                                                                
                        <dSizer SlotCount="1" designerClass="LayoutSizer" 
Orientation="Vertical">
                                                                                
                                <dEditBox RegID="log" ReadOnly="True" 
designerClass="controlMix" sizerInfo="{'BorderSides': ['All'], 'Proportion': 1, 
'HAlign': 'Left', 'VAlign': 'Top', 'Border': 0, 'Expand': True}"></dEditBox>
                                                                                
                        </dSizer>

Added: trunk/DaboDemo/media/homer.jpg
===================================================================
(Binary files differ)


Property changes on: trunk/DaboDemo/media/homer.jpg
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/DaboDemo/samples/dBitmapButton.py
===================================================================
--- trunk/DaboDemo/samples/dBitmapButton.py     2007-03-25 12:14:40 UTC (rev 
504)
+++ trunk/DaboDemo/samples/dBitmapButton.py     2007-03-25 20:51:09 UTC (rev 
505)
@@ -10,11 +10,11 @@
                                DefaultBorderLeft=True)
                sz.appendSpacer(25)
                
-               lbl = dabo.ui.dLabel(self, Alignment="Center")
-               lbl.Caption = """Below are three dBitmapButtons. They will 
normally
-display the Ace of Spades, but when the mouse hovers over them, their 
-normal image will be the Ace of Hearts. If you click on them, the image 
-will change to the King of Spades for as long as you hold the mouse down."""
+               lbl = dabo.ui.dLabel(self, Alignment="Center", Width=400, 
WordWrap=True)
+               lbl.Caption = "Below are three dBitmapButtons. They will 
normally " + \
+                               "display the Ace of Spades, but when the mouse 
hovers over them, their " + \
+                               "normal image will be the Ace of Hearts. If you 
click on them, the image " + \
+                               "will change to the King of Spades for as long 
as you hold the mouse down."
                sz.append(lbl, halign="center")
                if self.Application.Platform == "Mac":
                        lbl = dabo.ui.dLabel(self, FontItalic=True, 

Modified: trunk/DaboDemo/samples/dDateTextBox.py
===================================================================
--- trunk/DaboDemo/samples/dDateTextBox.py      2007-03-25 12:14:40 UTC (rev 
504)
+++ trunk/DaboDemo/samples/dDateTextBox.py      2007-03-25 20:51:09 UTC (rev 
505)
@@ -14,17 +14,15 @@
                intro = "dDateTextBox is a specialized text control designed to 
make it easy to " + \
                                "display and maniputate date values. It 
features several shortcut keystrokes " + \
                                "that enable you to quickly navigate to the 
desired date value.\n\nYou can see " + \
-                               "the available keystrokes by hovering the mouse 
cursor over the control" + \
+                               "the available keystrokes by hovering the mouse 
cursor over the control " + \
                                "to display the ToolTip."
-#              lbl = dabo.ui.dLabel(self, Caption=intro, ForeColor="darkblue", 
FontBold=True,
-#                              WordWrap=True, Alignment="center")
                lbl = dabo.ui.dLabel(self, Caption=intro, ForeColor="darkblue", 
FontBold=True,
-                               Alignment="center")
-               lbl.Wrap(300)
+                               WordWrap=True, Alignment="center")
                sz.append(lbl, "x", halign="center")
                sz.appendSpacer(10)
                txt = dabo.ui.dDateTextBox(self, Value=datetime.date.today())
                sz.append(txt, halign="center")
+               dabo.ui.callAfter(self.layout)
                
 
 category = "Controls.dDateTextBox"

Modified: trunk/DaboDemo/samples/dGrid.py
===================================================================
--- trunk/DaboDemo/samples/dGrid.py     2007-03-25 12:14:40 UTC (rev 504)
+++ trunk/DaboDemo/samples/dGrid.py     2007-03-25 20:51:09 UTC (rev 505)
@@ -67,8 +67,9 @@
                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, WordWrap=True)
-               lbl.DynamicWidth = lambda: self.Parent.Width * 0.8
+               lbl = self.gridCaption = dabo.ui.dLabel(self, 
Alignment="center", Caption=txt, WordWrap=True)
+               # Keep the label 80% of the panel
+               lbl.DynamicWidth = lambda: self.Width * 0.8
                lbl.FontSize -= 1
                
                sz.append(lbl, halign="center")

Added: trunk/DaboDemo/samples/dImage.py
===================================================================
--- trunk/DaboDemo/samples/dImage.py                            (rev 0)
+++ trunk/DaboDemo/samples/dImage.py    2007-03-25 20:51:09 UTC (rev 505)
@@ -0,0 +1,120 @@
+import dabo
+dabo.ui.loadUI("wx")
+import dabo.dEvents as dEvents
+from dabo.dLocalize import _
+
+
+class TestPanel(dabo.ui.dPanel):
+       def afterInit(self):
+               # Set the idle update flag
+               self.needUpdate = False
+               
+               # Create a panel with horiz. and vert.  sliders
+               self.imgPanel = dabo.ui.dPanel(self)
+               self.VSlider = dabo.ui.dSlider(self, Orientation="V", Min=1, 
Max=100,
+                               Value=100, Continuous=True, OnHit=self.onSlider)
+               self.HSlider = dabo.ui.dSlider(self, Orientation="H", Min=1, 
Max=100,
+                               Value=100, Continuous=True, OnHit=self.onSlider)
+               
+               mainSizer = self.Sizer = dabo.ui.dSizer("V")
+               psz = self.imgPanel.Sizer = dabo.ui.dSizer("V")
+               hsz = dabo.ui.dSizer("H")
+               hsz.append1x(self.imgPanel)
+               hsz.appendSpacer(10)
+               hsz.append(self.VSlider, 0, "x")
+               mainSizer.DefaultBorder = 25
+               mainSizer.DefaultBorderLeft = mainSizer.DefaultBorderRight = 
True
+               mainSizer.appendSpacer(25)
+               mainSizer.append(hsz, 1, "x")
+               mainSizer.appendSpacer(10)
+               mainSizer.append(self.HSlider, 0, "x")
+               mainSizer.appendSpacer(10)
+
+               # Create the image control
+               self.img = dabo.ui.dImage(self.imgPanel, BackColor="yellow",
+                       DroppedFileHandler=self)
+               
+               hsz = dabo.ui.dSizer("H")
+               hsz.DefaultSpacing = 10
+               btn = dabo.ui.dBitmapButton(self, Picture="rotateCW", 
OnHit=self.rotateCW)
+               hsz.append(btn)
+               btn = dabo.ui.dBitmapButton(self, Picture="rotateCCW", 
OnHit=self.rotateCCW)
+               hsz.append(btn) 
+                       
+               self.ddScale = dabo.ui.dDropdownList(self, 
+                               Choices = ["Proportional", "Stretch", "Clip"],
+                               PositionValue = 0,
+                               ValueMode = "String")
+               self.ddScale.DataSource = self.img
+               self.ddScale.DataField = "ScaleMode"
+                               
+               btn = dabo.ui.dButton(self, Caption=_("Load Your Own Image"),
+                               OnHit=self.onLoadImage)
+                               
+               hsz.append(self.ddScale, "x")
+               hsz.append(btn, "x")
+               mainSizer.append(hsz, alignment="right")
+               mainSizer.appendSpacer(25)
+               
+               # Load an image
+               self.img.Picture = "media/homer.jpg"
+               
+       
+       def processDroppedFiles(self, filelist):
+               self.img.Picture = filelist[0]
+               
+       def rotateCW(self, evt):
+               self.img.rotateClockwise()
+
+       def rotateCCW(self, evt):
+               self.img.rotateCounterClockwise()
+
+       def onSlider(self, evt):
+               slider = evt.EventObject
+               val = slider.Value * 0.01
+               ornt = slider.Orientation[0].lower()
+               if ornt == "h":
+                       # Change the width of the image
+                       self.img.Width = (self.imgPanel.Width * val)
+               else:
+                       self.img.Height = (self.imgPanel.Height * val)
+
+       # Without Dabo, you need to create this exact string to get the same 
behavior.
+       #       JPEG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png|GIF Files 
(*.gif)|*.gif|Bitmap Files (*.bmp)|*.bmp|All Files (*)|*             
+       def onLoadImage(self, evt): 
+               f = dabo.ui.getFile("jpg", "png", "gif", "bmp", "*")
+               if f:
+                       self.img.Picture = f
+       
+       def onResize(self, evt):
+               self.needUpdate = True
+               
+       def onIdle(self, evt):
+               if self.needUpdate:
+                       self.needUpdate = False
+                       wd = self.HSlider.Value * 0.01 * self.imgPanel.Width
+                       ht = self.VSlider.Value * 0.01 * self.imgPanel.Height
+                       self.img.Size = (wd, ht)
+
+
+category = "Controls.dImage"
+
+overview = """
+<p>The <b>dImage</b> class is used to display images in your app. It provides 
+simple ways to control the sizing, scaling and rotation of images. It can use 
any 
+of the following common image formats: <b>PNG</b>, <b>JPEG</b>, 
+<b>GIF</b> and <b>BMP</b>.</p>
+
+<p>To display an image, just set the <b>Picture</b> property to the path to 
the 
+file containing the image; the class will do the rest. You can also set the 
DataSource
+and DataField to an image column in a database.</p>
+
+<p>The <b>ScaleMode</b> property controls how the image is scaled to fit the 
control size:</p>
+<ul>
+<li><b>Proportional</b>: the original ratio of the Width and Height is 
maintained, which may result in
+empty areas.</li>
+<li><b>Stretch</b>: the image completely fills the area allotted to it, which 
may result in distortion.</li>
+<li><b>Clip</b>: The original size of the image is maintained. Changing the 
control size just shows more
+or less of the image, or more empty space if the control is bigger than the 
original image size.</li>
+</ul>
+"""


Property changes on: trunk/DaboDemo/samples/dImage.py
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/DaboDemo/samples/dLabel.py
===================================================================
--- trunk/DaboDemo/samples/dLabel.py    2007-03-25 12:14:40 UTC (rev 504)
+++ trunk/DaboDemo/samples/dLabel.py    2007-03-25 20:51:09 UTC (rev 505)
@@ -49,11 +49,23 @@
                lbl.BackColor = "yellow"
                sz.append(lbl)
                
+               lbl = self.dynamicLabel = dabo.ui.dLabel(self, Caption="")
+               lbl.DynamicFontSize = lambda: self.Width * .05
+               lbl.DynamicCaption = self.getDynamicCaption
+               sz.append(lbl)
+               dabo.ui.callAfter(self.update)
+               
+               sz.appendSpacer(20)
+               sz.append(dabo.ui.dLine(self, Width=500), halign="Center")
+               sz.appendSpacer(20)
+
                btn = dabo.ui.dButton(self, Caption=_("Show WordWrap demo"))
                btn.bindEvent(dEvents.Hit, self.onShowWWDemo)
                sz.append(btn, halign="center")
        
-       
+       def getDynamicCaption(self):
+               return "DynamicFontSize: %s" % 
int(round(self.dynamicLabel.FontSize, 0))
+               
        def onShowWWDemo(self, evt):
                class WordWrapDialog(dabo.ui.dDialog):
                        def addControls(self):
@@ -66,7 +78,7 @@
                                lbl.FontSize += 1
                                sz.append(lbl, "x", border=40, 
borderSides=("Left", "Right"))
                
-                               sld = self.slider = dabo.ui.dSlider(self, 
Value=100)
+                               sld = self.slider = dabo.ui.dSlider(self, 
Value=100, Continuous=True)
                                sld.bindEvent(dEvents.Hit, self.onSlider)
                                sld.bindEvent(dEvents.Resize, self.onSlider)
                                sz.append(sld, "x", border=10)
@@ -85,7 +97,7 @@
                                wd = (self.slider.Value/100.0) * 
self.slider.Width
                                self.gettyLabel.Width = wd
                                
-               dlg = WordWrapDialog(self)
+               dlg = WordWrapDialog(self, BorderResizable=True)
                dlg.Centered = True
                dlg.show()
 

Modified: trunk/DaboDemo/samples/dSpinner.py
===================================================================
--- trunk/DaboDemo/samples/dSpinner.py  2007-03-25 12:14:40 UTC (rev 504)
+++ trunk/DaboDemo/samples/dSpinner.py  2007-03-25 20:51:09 UTC (rev 505)
@@ -8,11 +8,10 @@
        def afterInit(self):
                sz = self.Sizer = dabo.ui.dSizer("v")
                
-               lbl = dabo.ui.dLabel(self, Alignment="Center", 
-                               Caption=_("""Both of these spinners have a 
range from 0 to 10. 
-The only difference is that the top spinner has 
-its SpinnerWrap property set to True, which cycles
-it around when it reaches one of its limits."""))
+               lbl = dabo.ui.dLabel(self, Alignment="Center", WordWrap=True, 
Width=400,
+                               Caption=_("Both of these spinners have a range 
from 0 to 10. The only "
+                                               "difference is that the top 
spinner has its SpinnerWrap property set to "
+                                               "True, which cycles it around 
when it reaches one of its limits."))
                                
                lbl.FontSize += 3
                lbl.ForeColor = "darkBlue"




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

Reply via email to