delay before action

Hi list,

I've got a TextCtrl that receive text used as part of a query.

I'd like it to wait for 2~3 seconds for other characters input
thus avoiding multiple and costly queries.

How can I introduce this delay?

JY

···

--
Police up your spare rounds and frags. Don't leave nothin' for the
dinks. -- Willem Dafoe in "Platoon"

I’ve got a TextCtrl that receive text used as part of a query.

I’d like it to wait for 2~3 seconds for other characters input
thus avoiding multiple and costly queries.

What event does the delay begin with?

How can I introduce this delay?

Use a wxTimer?

I've got a TextCtrl that receive text used as part of a query.
>
> I'd like it to wait for 2~3 seconds for other characters input
> thus avoiding multiple and costly queries.
>

What event does the delay begin with?

By the hit of the first key into the TextCtrl.

> How can I introduce this delay?
>

Use a wxTimer?

I guess so, some sort of timing auto restarting at zero on each key
hit. The PB is I don't see how to avoid a recursion.

···

On Sun, 25 Dec 2011 21:46:52 -0800 C M <cmpython@gmail.com> wrote:

--
Excellent day for drinking heavily. Spike the office water cooler.

def OnTimer(self, evt):
        self.Timer.Stop()
        self.PostQuery() # or whatever

    def OnKeyPress(self, evt):
        self.Timer.Stop()
        self.Timer.Start()

What recursion?

Gadget/Steve

···

On 26/12/2011 1:03 PM, Jean-Yves F. Barbier wrote:

On Sun, 25 Dec 2011 21:46:52 -0800 > C M <cmpython@gmail.com> wrote:

I've got a TextCtrl that receive text used as part of a query.

I'd like it to wait for 2~3 seconds for other characters input
thus avoiding multiple and costly queries.

What event does the delay begin with?

By the hit of the first key into the TextCtrl.

How can I introduce this delay?

Use a wxTimer?

I guess so, some sort of timing auto restarting at zero on each key
hit. The PB is I don't see how to avoid a recursion.

Let see if I understand it:
This one seems to be triggered by the timer revolution achievement?

    def OnTimer(self, evt):
        self.Timer.Stop()
        self.PostQuery() # or whatever

This one eventually stops a running timer and restart a new one?

    def OnKeyPress(self, evt):
        self.Timer.Stop()
        self.Timer.Start()

What I don't understand is why the 1st block stops its own timer if
if is to be triggered at the end of timing?

JY

···

On Mon, 26 Dec 2011 13:16:19 +0000 Gadget/Steve <GadgetSteve@live.co.uk> wrote:
--
A vasectomy means never having to say you're sorry.

In case it is a multi-shot timer, looking closer at the docs you would do:
            self.Timer.Start(timelimit, True)
for the start and get rid of both Stop statements.

···

On 26/12/2011 1:35 PM, Jean-Yves F. Barbier wrote:

On Mon, 26 Dec 2011 13:16:19 +0000 > Gadget/Steve <GadgetSteve@live.co.uk> wrote:

Let see if I understand it:
This one seems to be triggered by the timer revolution achievement?

    def OnTimer(self, evt):
        self.Timer.Stop()
        self.PostQuery() # or whatever

This one eventually stops a running timer and restart a new one?

    def OnKeyPress(self, evt):
        self.Timer.Stop()
        self.Timer.Start()

What I don't understand is why the 1st block stops its own timer if
if is to be triggered at the end of timing?

JY

Correct. Calling Start on a running timer essentially does a restart.

···

On 12/26/11 5:44 AM, Gadget/Steve wrote:

On 26/12/2011 1:35 PM, Jean-Yves F. Barbier wrote:

On Mon, 26 Dec 2011 13:16:19 +0000 >> Gadget/Steve<GadgetSteve@live.co.uk> wrote:

Let see if I understand it:
This one seems to be triggered by the timer revolution achievement?

     def OnTimer(self, evt):
         self.Timer.Stop()
         self.PostQuery() # or whatever

This one eventually stops a running timer and restart a new one?

     def OnKeyPress(self, evt):
         self.Timer.Stop()
         self.Timer.Start()

What I don't understand is why the 1st block stops its own timer if
if is to be triggered at the end of timing?

JY

In case it is a multi-shot timer, looking closer at the docs you would do:
             self.Timer.Start(timelimit, True)
for the start and get rid of both Stop statements.

--
Robin Dunn
Software Craftsman

So I did, unfortunately my favorite guinea-pig didn't like it: he
hadn't time to type his query (this one's representative as he can't
bear IT, need it badly and is quick tempered).

JY

···

On Mon, 26 Dec 2011 13:44:52 +0000 Gadget/Steve <GadgetSteve@live.co.uk> wrote:

In case it is a multi-shot timer, looking closer at the docs you would do:
            self.Timer.Start(timelimit, True)
for the start and get rid of both Stop statements.

--
To teach is to learn.

why dont you just do it onIdle ... that way who cares if its costly
theres not much else goin on so query...just have a flag if its
changed since last query and do the query on wx.EVT_IDLE

···

On Dec 26, 11:22 am, "Jean-Yves F. Barbier" <12u...@gmail.com> wrote:

On Mon, 26 Dec 2011 13:44:52 +0000 > > Gadget/Steve <GadgetSt...@live.co.uk> wrote:
> In case it is a multi-shot timer, looking closer at the docs you would do:
> self.Timer.Start(timelimit, True)
> for the start and get rid of both Stop statements.

So I did, unfortunately my favorite guinea-pig didn't like it: he
hadn't time to type his query (this one's representative as he can't
bear IT, need it badly and is quick tempered).

JY
--
To teach is to learn.

IMHO the OP meant that the price charged by the data centre for
processing each query was high in a monetary sense rather than that a
lot of processing power was used by each query....

···

On 26/12/2011 7:50 PM, joran wrote:

why dont you just do it onIdle ... that way who cares if its costly
theres not much else goin on so query...just have a flag if its
changed since last query and do the query on wx.EVT_IDLE

No, I'm gonna go back to the CTRL-CR method; I often forget
that searching better is worse than keeping good enough:(

···

On Mon, 26 Dec 2011 11:50:07 -0800 (PST) joran <joranbeasley@gmail.com> wrote:

why dont you just do it onIdle ... that way who cares if its costly
theres not much else goin on so query...just have a flag if its
changed since last query and do the query on wx.EVT_IDLE

--

No, I meant it in term of bandwidth (there's a lot of users,
many road warriors and a not so big BW).

JY

···

On Mon, 26 Dec 2011 20:03:07 +0000 Gadget/Steve <GadgetSteve@live.co.uk> wrote:

>
IMHO the OP meant that the price charged by the data centre for
processing each query was high in a monetary sense rather than that a
lot of processing power was used by each query....

--
high technology, n.:
  A California innovation composed of equal parts of silicon
        and marijuana.