On Thursday 19 November 2009 08:02:30 am John wrote:
> On Thursday 19 November 2009 07:59:56 am Paul McNett wrote:
> > John wrote:
> > > Sorry I thought I answered that question.  Yes it works.  And yes it's
> > > my code that does not work (in the sense it does not retain column
> > > sizing). I'm trying to determine why.  In dGrid test Dabo is creating a
> > > class but in my code I'm using the dGrid directly.  I would like to
> > > have this feature but I don't see the difference in my code and the
> > > code Dabo is using.  In my head it should work the same.  But indeed
> > > there must be a difference.  Maybe Paul's example will help me
> > > determine the issue.
> >
> > My example would be similar to the dGrid test. Why don't you make a small
> > example of what you are doing. Should be about 20 lines of code total.
> >
> > Paul
>
> OK I will - I just was unable to get your code example to work.  But I will
> do mine first.
>
> Johnf

Ok this is how I normally create a grid.   Is there a way to insure the format 
of the code in the email?   

#/usr/bin/env python
import wx
import dabo
dabo.settings.dateFormat ="%m/%d/%Y"

import dabo.dEvents as dEvents
import dabo.dException as dException


#from profilehooks import profile, coverage
dabo.ui.loadUI('wx')
from dabo.ui import dKeys as dKeys

class MainForm(dabo.ui.dForm):


    def afterInit(self):
        """Normally the programmer would add code to display the controls 
here.  The programmer could add panels that contain other controls etc. """
        self.Caption = "Replace with a Window Title"
        self.Sizer = vs = dabo.ui.dSizer("v")
        vs.appendSpacer(10)
        hoursGrid = dabo.ui.dGrid(self, RegID = "hoursgridID", SelectionMode 
= 'Row', AlternateRowColoring = True, ColumnCount = 3, Editable = False, 
MovableColumns = True)
        #I normally just set the datasource as in hoursGrid.DataSource 
= 'public.hours'  but in this case I needed the dataset and not the 
datasource.
        hoursGrid.DataSet = self.DataSet 
        hoursGrid.Columns[0].Caption = "Name"
        hoursGrid.Columns[0].DataField = "name"
        hoursGrid.Columns[0].HorizontalAlignment = 'Left'
        hoursGrid.Columns[1].Caption = "Age"
        hoursGrid.Columns[1].DataField = "age"
        hoursGrid.Columns[1].HorizontalAlignment = 'Center'
        hoursGrid.Columns[2].Caption = "Coder"
        hoursGrid.Columns[2].DataField = "coder"
        hoursGrid.Columns[2].HorizontalAlignment = 'Center'


        vs.append(hoursGrid, 0, 'x')

    def afterInitAll(self):
        pass
      

    def initProperties(self):
        ds = [
            {"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"}]
        for row in range(len(ds)):
            for i in range(20):
                ds[row]["i_%s" % i] = "sss%s" % i
        
        self.DataSet = dabo.db.dDataSet(ds)


if __name__ == "__main__":
    app = dabo.dApp()
    app.MainFormClass = MainForm
    app.start()



_______________________________________________
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