I have a screen with data loading from a sqlite database. I’ve created a screen in wxpython to display the info, with a series of nested sizers. The TextCtrl boxes are in a FlexGridSizer (with associated StaticText labels).
So, how do I reload the TextCtrl fields with new data from the database without redrawing the entire window? When I try to change the info in the fields, it doesn’t display in the same positions and overwrites some static text in the top boxsizer.
I’m attaching the file with the code.
On Friday, September 12, 2014 9:16:18 AM UTC-4, Mark Halegua wrote:
I have a screen with data loading from a sqlite database. I’ve created a screen in wxpython to display the info, with a series of nested sizers. The TextCtrl boxes are in a FlexGridSizer (with associated StaticText labels).
So, how do I reload the TextCtrl fields with new data from the database without redrawing the entire window? When I try to change the info in the fields, it doesn’t display in the same positions and overwrites some static text in the top boxsizer.
I’m attaching the file with the code.
I have a screen with data loading from a sqlite database. I've created a screen in wxpython to display the info, with a series of nested sizers. The TextCtrl boxes are in a FlexGridSizer (with associated StaticText labels).
So, how do I reload the TextCtrl fields with new data from the database without redrawing the entire window? When I try to change the info in the fields, it doesn't display in the same positions and overwrites some static text in the top boxsizer.
I'm attaching the file with the code.
Don't recreate TextCtrl, but use its "ChangeValue" method.
So, 'lname_text' becomes 'self.lname_text' in your __init__ method and then when changing the value you do 'self.lname_text.ChangeValue('databasevalue')
BTW, when using sizers you should not hard coded sizes to controls/widgets.
I have a screen with data loading from a sqlite database. I've created a screen in wxpython to display the info, with a series of nested sizers. The TextCtrl boxes are in a FlexGridSizer (with associated StaticText labels).
So, how do I reload the TextCtrl fields with new data from the database without redrawing the entire window? When I try to change the info in the fields, it doesn't display in the same positions and overwrites some static text in the top boxsizer.
I'm attaching the file with the code.
You could also use 'validators' to update controls with values from a database.
There are a few tips on this in the wxPython wiki and Mike and I did MediaLocker some time ago as a demo on how one could do this type of stuff.
Thanks, but I found the SetValue method and it work! Appreciate the help.
You’re the second person to say I shouldn’t hard code sizes in widgets. I need to look at that. Unsure what you mean.
Again, thanks.
Mark
···
On Friday, September 12, 2014 9:45:49 AM UTC-4, werner wrote:
Hi Mark,
On 9/12/2014 15:16, Mark Halegua wrote:
I have a screen with data loading from a sqlite database. I’ve
created a screen in wxpython to display the info, with a series of
nested sizers. The TextCtrl boxes are in a FlexGridSizer (with
associated StaticText labels).
So, how do I reload the TextCtrl fields with new data from the
database without redrawing the entire window? When I try to change
the info in the fields, it doesn’t display in the same positions and
overwrites some static text in the top boxsizer.
I’m attaching the file with the code.
Don’t recreate TextCtrl, but use its “ChangeValue” method.
So, ‘lname_text’ becomes ‘self.lname_text’ in your init method and
then when changing the value you do
'self.lname_text.ChangeValue(‘databasevalue’)
BTW, when using sizers you should not hard coded sizes to controls/widgets.
Thanks. I’ll look at your code later. Did find using SetValue method for changing the ctrl data worked.
Mark
···
On Friday, September 12, 2014 9:58:30 AM UTC-4, werner wrote:
Hi Mark,
On 9/12/2014 15:16, Mark Halegua wrote:
I have a screen with data loading from a sqlite database. I’ve
created a screen in wxpython to display the info, with a series of
nested sizers. The TextCtrl boxes are in a FlexGridSizer (with
associated StaticText labels).
So, how do I reload the TextCtrl fields with new data from the
database without redrawing the entire window? When I try to change
the info in the fields, it doesn’t display in the same positions and
overwrites some static text in the top boxsizer.
I’m attaching the file with the code.
You could also use ‘validators’ to update controls with values from a
database.
There are a few tips on this in the wxPython wiki and Mike and I did
MediaLocker some time ago as a demo on how one could do this type of stuff.
Thanks, but I found the SetValue method and it work! Appreciate the help.
Great, just FYI SetValue generates a EVT_TEXT event where ChangeValue does not. IIRC ChangeValue only exists for controls where SetValue generates the event.
You're the second person to say I shouldn't hard code sizes in widgets. I need to look at that. Unsure what you mean.
Wow, I wish I’d have known that a week ago when I was trying to figure out how to detect keyboard vs programmatic TextCtrl input (I was using SetValue for the programmatic method)
···
On Friday, September 12, 2014 7:45:43 AM UTC-7, werner wrote:
Hi Mark,
On 9/12/2014 16:40, Mark Halegua wrote:
Werner,
Thanks, but I found the SetValue method and it work! Appreciate the help.
Great, just FYI SetValue generates a EVT_TEXT event where ChangeValue
does not. IIRC ChangeValue only exists for controls where SetValue
generates the event.