In my application I want to provide for the change of an element of my
form on the fly and make this you change an element of the sizer.
When you press the button the textctrl item sizer is replaced with datepickerctrl but
this does not work. In fact, the calendar just show, but when I position mouse over there disappears.
In my application I want to provide for the change of an element of my
form on the fly and make this you change an element of the sizer.
When you press the button the textctrl item sizer is replaced with
datepickerctrl but
this does not work. In fact, the calendar just show, but when I position
mouse over there disappears.
I duplicate the problem in sample runnable code
I'm not sure this is the right approach, but I think you have to
.Hide() the textCtrl in addition to using .Replace() on the sizer. I
also think you might want to check if the datepickerctrl is already
there before you create a new one. So, you could rewrite your
function as something like:
def OnTest(self,evt):
date_picker_exists = False #test if already there
for child in self.container.GetChildren():
if isinstance(child, wx.DatePickerCtrl):
date_picker_exists = True
Sure. By the way, it occurs to me that if you want to do a switching
back-and-forth from one control to the other, you will want to create
everything in the beginning and then just .Hide() and .Show() them as
needed (this way you are never trying to create a second instance of a
control).
···
On Mon, Aug 23, 2010 at 5:26 PM, Fabio Spadaro <fabiolinospad@gmail.com> wrote:
Hi C M
2010/8/23 C M <cmpython@gmail.com>
On Mon, Aug 23, 2010 at 4:50 PM, Fabio Spadaro <fabiolinospad@gmail.com> >> wrote:
> In my application I want to provide for the change of an element of my
> form on the fly and make this you change an element of the sizer.
> When you press the button the textctrl item sizer is replaced with
> datepickerctrl but
> this does not work. In fact, the calendar just show, but when I position
> mouse over there disappears.
> I duplicate the problem in sample runnable code
I'm not sure this is the right approach, but I think you have to
.Hide() the textCtrl in addition to using .Replace() on the sizer. I
also think you might want to check if the datepickerctrl is already
there before you create a new one. So, you could rewrite your
function as something like:
def OnTest(self,evt):
date_picker_exists = False #test if already there
for child in self.container.GetChildren():
if isinstance(child, wx.DatePickerCtrl):
date_picker_exists = True
You used Replace() so the textctrl is no longer in the sizer, so it's position is not managed by the sizer when the window changes size. Create and add both widgets to the sizer at the beginning and Hide() one of them. Then when you want to switch just Hide() one, Show() the other and do a Layout(). There's no need for the first half of what you have in OnTest.
···
On 8/25/10 5:18 AM, Fabio Spadaro wrote:
Still not working. I modified the code changing
sizer.Add (self.grid, 1, wx.EXPAND).
If you press button datepickerctrl appears, if you press
again reappears textctrl but if you resize the window the
textctrl remains anchored in its position.
Any idea?
If you press button datepickerctrl appears, if you press
again reappears textctrl but if you resize the window the
textctrl remains anchored in its position.
Any idea?
You used Replace() so the textctrl is no longer in the sizer, so it’s position is not managed by the sizer when the window changes size. Create and add both widgets to the sizer at the beginning and Hide() one of them. Then when you want to switch just Hide() one, Show() the other and do a Layout(). There’s no need for the first half of what you have in OnTest.
If you press button datepickerctrl appears, if you press
again reappears textctrl but if you resize the window the
textctrl remains anchored in its position.
Any idea?
You used Replace() so the textctrl is no longer in the sizer, so it’s position is not managed by the sizer when the window changes size. Create and add both widgets to the sizer at the beginning and Hide() one of them. Then when you want to switch just Hide() one, Show() the other and do a Layout(). There’s no need for the first half of what you have in OnTest.
I followed your suggestion and it works. As the two widgets that alternate in sizer
are textctrl and genericdatepicker, I want based on an X event is changed
Local and consequently the layout of the calendar. The simplest solution would be
to create so many genericdatepicker 's widgets into sizer as there are languages
managed (English, Italian, etc.) and use hide or show as appropriate. But I do not
I want this, there is a better solution that you suggest?
If you've got many possible widgets that could be displayed then I would probably go back to creating them on-demand. Just be sure to always put the new widget in the sizer and take the old one out. You should probably also Destroy() the old one so you don't have to worry about keeping track of it.
···
On 8/26/10 3:53 AM, Fabio Spadaro wrote:
I followed your suggestion and it works. As the two widgets that
alternate in sizer
are textctrl and genericdatepicker, I want based on an X event is changed
Local and consequently the layout of the calendar. The simplest solution
would be
to create so many genericdatepicker 's widgets into sizer as there are
languages
managed (English, Italian, etc.) and use hide or show as appropriate.
But I do not
I want this, there is a better solution that you suggest?