List Info

Thread: RE: Updating a wx.Grid from SQL Server




RE: Updating a wx.Grid from SQL Server
country flaguser name
United States
2007-11-06 10:25:31
 

> -----Original Message-----
> From: Geoff Skerrett [mailto:Geoffteammsa.com] 
> Sent: Monday, November 05, 2007 4:48 PM
> To: wxPython-userslists.wxwidgets.org
> Subject: RE: [wxPython-users] Updating a wx.Grid from
SQL Server
> 
> > -----Original Message-----
> > From: Mike Driscoll [mailto:mdriscollco.marshall.ia.us]
> > Sent: Monday, November 05, 2007 6:32 PM
> > To: wxPython-userslists.wxwidgets.org
> > Subject: [wxPython-users] Updating a wx.Grid from
SQL Server
> > 
> > Hi,
> > 
> > I have a wx.Grid object that is displaying a
user's hours per pay 
> > period by accessing data stored in SQL Server.
What I would 
> like to be 
> > able to do is allow the user to click some buttons
labeled Next and 
> > Prev to go to the next or previous pay period and
display 
> those hours. 
> > Unfortunately, the number of rows change between
pay period 
> for this 
> > particular type of user and I cannot get the grid
to change 
> > accordingly.
> > 
> > If I create the entire frame from scratch, it
works great. 
> > But I would like to just update the grid object. I
tried destroying 
> > the grid and then recreating it, but the grid
doesn't seem to get 
> > re-added to my sizer, so it's "smushed"
> > up in the corner of the frame. How do I re-add it
to the 
> sizer at the 
> > correct place? Is there a better way then
destroying it?
> > 
> > I'm using wxPython 2.8, Python 2.4 and Windows XP
Pro.
> > 
> I think the solution is to a single grid object, but
with a 
> virtual table.  
> When the period changes, you create a new table and
then 
> "set" the grid to the new table.
> 
> Check out the Grid_MegaExample in the demo for an
example.
> 
> G.
> 

This does indeed seem to be one way to do it. Unfortunately,
this code is
above my head. I've been reading and re-reading it for about
an hour and I
just don't get it. Also, the wiki muddies things up a bit
since it
suggests both virtual tables in one place and
deleting/recreating the
grid's parent widget in another:

http://wiki
.wxpython.org/UpdatingGridData or
http://wiki.wxpython.
org/wxGrid
http://wi
ki.wxpython.org/AppendingGridTable

Oh well. Thanks for the tip.

Mike


------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
For additional commands, e-mail: wxPython-users-helplists.wxwidgets.org


RE: Updating a wx.Grid from SQL Server
country flaguser name
Denmark
2007-11-06 13:33:20
> > I think the solution is to a single grid object,
but with a virtual 
> > table.
> > When the period changes, you create a new table
and then "set" the 
> > grid to the new table.
> > 
> > Check out the Grid_MegaExample in the demo for an
example.
> > 
> > G.
> > 
> 
> This does indeed seem to be one way to do it.
Unfortunately, 
> this code is above my head. I've been reading and
re-reading 
> it for about an hour and I just don't get it. Also, the
wiki 
> muddies things up a bit since it suggests both virtual
tables 
> in one place and deleting/recreating the grid's parent
widget 
> in another:
> 
> http://wiki
.wxpython.org/UpdatingGridData or 
> http://wiki.wxpython.
org/wxGrid 
> http://wi
ki.wxpython.org/AppendingGridTable
> 
> Oh well. Thanks for the tip.
> 
> Mike
> 

Well like everything, you will get your "A Ha!"
moment eventually !

If it would help, I have a small app that uses this
technique to
read/view data from a file in "binary" mode,
diplaying the ascii on one
line and the hex on the next.  If a new file is loaded, the
grid is
never rebuilt, just signaled that the data has changed. So
it isn't
exactly working SQL - I think you would just need to
abstract the
recordset return by a .fetchall to adjust it.

If interested send me a private email

Imageguy1206
- at -
Gmail
Com


------------------------------------------------------------
---------
To unsubscribe, e-mail: wxPython-users-unsubscribelists.wxwidgets.org
For additional commands, e-mail: wxPython-users-helplists.wxwidgets.org


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )