My version of a Date Picker ctrl

Robin Dunn wrote:

> Hi Karsten et al
>
> Here is a revised version of datectrl_1.4 - I have found
and fixed a few
> more bugs.
>
> I have another question for Robin regarding the customised
bitmap button.
> The following relates to gkt2 only.
>
> Karsten has already reported that, once the button is selected, its
> appearance stays 'selected' after moving off it. I have
confirmed that the
> demo shows the same behaviour.

I've been able to reproduce it in your sample on XP too. It
looks to me
like it is simply that showing the dialog is preventing the ComboCtrl
from seeing the EVT_LEFT_UP or something so it doesn't know
that it is
supposed to redraw the button in the unclicked state. The ComboCtrl
should probably do something like capturing the mouse on
left-down and
handling the EVT_CAPTURE_LOST/_CHANGED events as if it was a left-up.

You can probably work around this by not showing the dialog in
OnButtonClick, and capturing the mouse and waiting for either
capture-lost or the left-up event and doing it there instead if the
mouse is still within the bounds of the button.

>
> I have now noticed another oddity. If you hover the mouse
over the button,
> it turns a tasteful shade of blue. I am using the default
theme installed by
> Fedora 10. Other themes may behave differently.
>
> With the demo, if the mouse leaves the button, the
background colour reverts
> to the original. In my program, I have a tooltip that is
displayed if the
> mouse stays over the button for> 0.5 sec. If you move the
mouse over the
> button and then off within 0.5 sec, it behaves the same -
it changes to blue
> and then reverts. However, if you leave it there long
enough for the tooltip
> to be displayed, then when moving off, the tooltip
disappears, but the
> background stays blue!

I'm also able to see it in your sample on XP, so it's not
strictly a GTK
issue either. When the tip window is shown it becomes the
active window
(and I think it captures the mouse) so it causes a EVT_LEAVE_WINDOW
event for the combo button, and so it is redrawn without the
mouse-over
state even though the cursor happens to still be within its
bounds. You
could probably do something in your on_mouse_leave such that
it does not
call Skip in this case, but then you may need to force it
somehow when
the tip window is dismissed.

Thanks for the input, Robin.

I spent a couple of hours experimenting with your suggestions, but I could
not get it working properly. As it is a minor issue, I decided to leave it
alone for now.

I have uploaded the latest version to the wiki -

http://wiki.wxpython.org/DateEditorAndPicker#preview

I included a note and a link to this discussion, so if anyone feels like
following it up they will be very welcome :wink:

Frank

···

On 9/12/10 2:06 AM, Frank Millman wrote:

Looks like there was a bug with setup_input_format when the input
string has '%Y' anywhere except at the end - example with input string
as '%Y-%m-%d'. I have attached the code with some changes in the
function 'setup_input_format' to fix this -
https://docs.google.com/leaf?id=0B5FPKF1eKo0kODQ5ZGQwZTYtM2FlMC00YTE5LWE4M2EtNDEwMWZhNDAxM2U4&hl=en.

Thanks,

Raja

···

On Sep 14, 1:39 pm, "Frank Millman" <fr...@chagford.com> wrote:

Robin Dunn wrote:

> On 9/12/10 2:06 AM, Frank Millman wrote:
> > Hi Karsten et al

> > Here is a revised version of datectrl_1.4 - I have found
> and fixed a few
> > more bugs.

> > I have another question for Robin regarding the customised
> bitmap button.
> > The following relates to gkt2 only.

> > Karsten has already reported that, once the button is selected, its
> > appearance stays 'selected' after moving off it. I have
> confirmed that the
> > demo shows the same behaviour.

> I've been able to reproduce it in your sample on XP too. It
> looks to me
> like it is simply that showing the dialog is preventing the ComboCtrl
> from seeing the EVT_LEFT_UP or something so it doesn't know
> that it is
> supposed to redraw the button in the unclicked state. The ComboCtrl
> should probably do something like capturing the mouse on
> left-down and
> handling the EVT_CAPTURE_LOST/_CHANGED events as if it was a left-up.

> You can probably work around this by not showing the dialog in
> OnButtonClick, and capturing the mouse and waiting for either
> capture-lost or the left-up event and doing it there instead if the
> mouse is still within the bounds of the button.

> > I have now noticed another oddity. If you hover the mouse
> over the button,
> > it turns a tasteful shade of blue. I am using the default
> theme installed by
> > Fedora 10. Other themes may behave differently.

> > With the demo, if the mouse leaves the button, the
> background colour reverts
> > to the original. In my program, I have a tooltip that is
> displayed if the
> > mouse stays over the button for> 0.5 sec. If you move the
> mouse over the
> > button and then off within 0.5 sec, it behaves the same -
> it changes to blue
> > and then reverts. However, if you leave it there long
> enough for the tooltip
> > to be displayed, then when moving off, the tooltip
> disappears, but the
> > background stays blue!

> I'm also able to see it in your sample on XP, so it's not
> strictly a GTK
> issue either. When the tip window is shown it becomes the
> active window
> (and I think it captures the mouse) so it causes a EVT_LEAVE_WINDOW
> event for the combo button, and so it is redrawn without the
> mouse-over
> state even though the cursor happens to still be within its
> bounds. You
> could probably do something in your on_mouse_leave such that
> it does not
> call Skip in this case, but then you may need to force it
> somehow when
> the tip window is dismissed.

Thanks for the input, Robin.

I spent a couple of hours experimenting with your suggestions, but I could
not get it working properly. As it is a minor issue, I decided to leave it
alone for now.

I have uploaded the latest version to the wiki -

DateEditorAndPicker - wxPyWiki

I included a note and a link to this discussion, so if anyone feels like
following it up they will be very welcome :wink:

Frank

Raja wrote:

Looks like there was a bug with setup_input_format when the input
string has '%Y' anywhere except at the end - example with input string
as '%Y-%m-%d'. I have attached the code with some changes in the
function 'setup_input_format' to fix this -
https://docs.google.com/leaf?id=0B5FPKF1eKo0kODQ5ZGQwZTYtM2FlM
C00YTE5LWE4M2EtNDEwMWZhNDAxM2U4&hl=en.

Thanks for spotting this, Raja. Definitely a bug.

I found that your modification worked, but only if '%Y' was at the
beginning. The day and month positions do not need to be adjusted if they
come *before* the year. I added a test to check for this, but then I
realised I could eliminate the need for the test if I shuffled the code
around to calculate the year position first, as this automatically adjusts
the day and month positions if they come later.

Then I changed all other occurrences in the program that refer to 'day,
month, and year' to the sequence 'year, month, and day'. A bit obsessive, I
know, but I find that it aids readability of a program if it is internally
consistent.

I have attached a revised version - datectrl_1.5.py . Please check it out.
If I have not heard of any problems within a few days, I will upload it to
the wiki.

Thanks again.

Frank

datectrl_1.5.py (14 KB)

Raja wrote:

Looks like there was a bug with setup_input_format when the input
string has '%Y' anywhere except at the end - example with input string
as '%Y-%m-%d'. I have attached the code with some changes in the
function 'setup_input_format' to fix this -
https://docs.google.com/leaf?id=0B5FPKF1eKo0kODQ5ZGQwZTYtM2FlM
C00YTE5LWE4M2EtNDEwMWZhNDAxM2U4&hl=en.

I have replied to this with a revised version attached, but for some reason
I sometimes have problems with my ISP when attaching files, and I have not
received my own message back as I would normally.

I see that my message has made it to the Google Groups archive, with the
attachment, so if anyone else does not receive my original message, please
pick it up from there.

Frank

Frank Millman wrote:

Raja wrote:
>
> Looks like there was a bug with setup_input_format when the input
> string has '%Y' anywhere except at the end - example with input string
> as '%Y-%m-%d'. I have attached the code with some changes in the
> function 'setup_input_format' to fix this -
> https://docs.google.com/leaf?id=0B5FPKF1eKo0kODQ5ZGQwZTYtM2FlM
> C00YTE5LWE4M2EtNDEwMWZhNDAxM2U4&hl=en.
>

Thanks for spotting this, Raja. Definitely a bug.

I found that your modification worked, but only if '%Y' was at the

beginning.

The day and month positions do not need to be adjusted if they come

*before*

the year. I added a test to check for this, but then I realised I could

eliminate

the need for the test if I shuffled the code around to calculate the year

position

first, as this automatically adjusts the day and month positions if they

come later.

Then I changed all other occurrences in the program that refer to 'day,

month, and

year' to the sequence 'year, month, and day'. A bit obsessive, I know, but

I find

that it aids readability of a program if it is internally consistent.

I have attached a revised version - datectrl_1.5.py . Please check it out.
If I have not heard of any problems within a few days, I will upload it to

the wiki.

I have now uploaded datectrl_1.5.py to the wiki.

Frank