I have a wxGrid that I populate with a call to a database. I've set
up a method to sort the data depending on the column label that is
clicked. I can see that the sort is working as designed by having it
print out the data, but I can't get my grid to refresh to show the
sorted data.
I'm fairly new to wxPython and have googled all over. I've tried
processing the wxGrid message to no avail. Can someone point me to
some documentation or a tutorial dealing with this? Maybe a code
snippet?
Thanks
David
My workaround right now is to call self.grid_1.ClearGrid() and then
repopulate the grid. Is this the best way to do this? I guess it
works for now.
···
On 5/16/06, David Boucha <boucha@gmail.com> wrote:
I have a wxGrid that I populate with a call to a database. I've set
up a method to sort the data depending on the column label that is
clicked. I can see that the sort is working as designed by having it
print out the data, but I can't get my grid to refresh to show the
sorted data.
I'm fairly new to wxPython and have googled all over. I've tried
processing the wxGrid message to no avail. Can someone point me to
some documentation or a tutorial dealing with this? Maybe a code
snippet?
David Boucha wrote:
I have a wxGrid that I populate with a call to a database. I've set
up a method to sort the data depending on the column label that is
clicked. I can see that the sort is working as designed by having it
print out the data, but I can't get my grid to refresh to show the
sorted data.
I'm fairly new to wxPython and have googled all over. I've tried
processing the wxGrid message to no avail. Can someone point me to
some documentation or a tutorial dealing with this? Maybe a code
snippet?
If you are new to wxPython it may be early enough to convince you to give Dabo a try. Dabo is a 3-tier database application development framework, where the UI tier wraps wxPython into a simplified layer.
http://dabodev.com
You can forget about using the db and biz tiers and just use the ui tier instead of using wxPython directly, and your grid problem can be solved with the following code:
#-- begin sample code
import dabo
dabo.ui.loadUI("wx")
app = dabo.dApp()
app.setup()
# populate your dataset from a database, but here's a sample:
ds = ({"last_name": "McNett", "first_name": "Paul"},
{"last_name": "Bundy", "first_name": "Bud"})
grd = app.MainForm.addObject(dabo.ui.dGrid)
grd.DataSet = ds
grd.addColumn(Caption="Last Name", DataField="last_name")
grd.addColumn(Caption="First Name", DataField="first_name")
app.start()
#-- end sample code
Click on the column headers to sort, type into the grid to search.
···
--
Paul McNett
http://paulmcnett.com
http://dabodev.com
Thanks for the info, Paul. I'll look into Dabo further.
David
···
On 5/16/06, Paul McNett <p@ulmcnett.com> wrote:
David Boucha wrote:
> On 5/16/06, David Boucha <boucha@gmail.com> wrote:
>> I have a wxGrid that I populate with a call to a database. I've set
>> up a method to sort the data depending on the column label that is
>> clicked. I can see that the sort is working as designed by having it
>> print out the data, but I can't get my grid to refresh to show the
>> sorted data.
>>
>> I'm fairly new to wxPython and have googled all over. I've tried
>> processing the wxGrid message to no avail. Can someone point me to
>> some documentation or a tutorial dealing with this? Maybe a code
>> snippet?
>
> My workaround right now is to call self.grid_1.ClearGrid() and then
> repopulate the grid. Is this the best way to do this? I guess it
> works for now.
You should actually use a custom data table, and have it virtually feed
the grid the requested column values when the grid asks for them, from
your model. This complexity is already abstracted for you if you use
Dabo's dGrid instead, per my previous message!
--
Paul McNett