Eero Pajarre | 3 Jun 22:30

wxTimer

Has anybody used wxTimer in wxLua (lua-side) programming?
The only related example I found, was the wxluacan program,
and it seems to use timer events from the C/C++ side.

I can create the wxTimer, but I am not sure what
I am missing when I try to bind it to an event handler.

   Eero

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
Piotr Strzelczyk | 3 Jun 23:18

Re: wxTimer

Hello,

> Has anybody used wxTimer in wxLua (lua-side) programming?

Yes, I've used it.

> I can create the wxTimer, but I am not sure what
> I am missing when I try to bind it to an event handler.

Maybe this fragments of code will be useful for you:

gstimer = wx.wxTimer(frame)
frame:Connect(wx.wxEVT_TIMER, TimerTick) 

gstimer:Start(20)

the TimerTick() function is called 50 times per second
(variable frame point main window of application).

near the end of program (or when needed) you should use:

gstimer:Stop()

Best regards

Piotr Strzelczyk

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
(Continue reading)

Eero Pajarre | 4 Jun 10:21

Re: wxTimer

On Wed, Jun 4, 2008 at 12:18 AM, Piotr Strzelczyk <piotr@...> wrote:

> Maybe this fragments of code will be useful for you:
>
> gstimer = wx.wxTimer(frame)
> frame:Connect(wx.wxEVT_TIMER, TimerTick)
>
> gstimer:Start(20)
>

Thanks,

Your code wasn't much different from my experiment,
and I changed my version to match yours.

I still don't get my Tick function called...
(my timer seems to be ok, it returns correct value for
GetInterval and IsRunning.)

Is your experience from Linux or Windows or some other platform?

I am trying this on Windows (XP).

   Eero

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
(Continue reading)

Piotr Strzelczyk | 4 Jun 10:45

Re: wxTimer


> I still don't get my Tick function called...
> (my timer seems to be ok, it returns correct value for
> GetInterval and IsRunning.)
>   
Strange, I have no problems with it.
But I'll try to ask some silly questions which may help you:
I what part of program timer should work? All events work when the 
program is in main loop (e.g. initialization is ended).
Do you have multithread program (corutine)? Events has to be processed 
in `main' thread.

> Is your experience from Linux or Windows or some other platform?
I compiled/tested my project ( http://psview.sf.net/ ) under Linux (gcc) 
and Windows (mingw or VC++)
in both cases timer works fine.

Best regards

Piotr Strzelczyk

--

-- 
Piotr Strzelczyk
Sopot, Poland
e-mail: piotr@...; skype: piotrstrz

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
(Continue reading)

Eero Pajarre | 4 Jun 11:29

Re: wxTimer

On Wed, Jun 4, 2008 at 11:45 AM, Piotr Strzelczyk <piotr@...> wrote:
>
>> I still don't get my Tick function called...
>> (my timer seems to be ok, it returns correct value for
>> GetInterval and IsRunning.)
>>
> Strange, I have no problems with it.
> But I'll try to ask some silly questions which may help you:
> I what part of program timer should work? All events work when the
> program is in main loop (e.g. initialization is ended).
> Do you have multithread program (corutine)? Events has to be processed
> in `main' thread.
>

I start the timer while initializing, and my program "ends" into the main
loop, the GUI is otherwise active, so I the main loop must be running.
(This is for testing purposes, I added the timer stuff to an
existing application)

My Tick function currently just prints a message (which is redirected to
a texty box in application). The message appears if I directly call the tick
function, but not from the timer.

No coroutines.

I have to do some more tests, my wxLua base application is not
from the current wxLua distribution (instead it was originally
based on version from long time ago, and I have updated it
where I have noticed it necessary).

(Continue reading)

Eero Pajarre | 4 Jun 11:50

Re: wxTimer

On Wed, Jun 4, 2008 at 12:29 PM, Eero Pajarre <epajarre@...> wrote:

>
> I have to do some more tests, my wxLua base application is not
> from the current wxLua distribution (instead it was originally
> based on version from long time ago, and I have updated it
> where I have noticed it necessary).
>

Ok, thanks for you help Piotr.

It looks like the problem is specific to my wxLua based application,
now I just have to find out what is wrong there. :-(  On the first look
I did not notice "essential" differences, when comparing the the
current official wxLua.

  Eero

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
John Labenski | 4 Jun 16:47

Re: wxTimer

On Wed, Jun 4, 2008 at 5:50 AM, Eero Pajarre <epajarre@...> wrote:
> On Wed, Jun 4, 2008 at 12:29 PM, Eero Pajarre <epajarre@...> wrote:
>
>>
>> I have to do some more tests, my wxLua base application is not
>> from the current wxLua distribution (instead it was originally
>> based on version from long time ago, and I have updated it
>> where I have noticed it necessary).
>>
>
> Ok, thanks for you help Piotr.
>
> It looks like the problem is specific to my wxLua based application,
> now I just have to find out what is wrong there. :-(  On the first look
> I did not notice "essential" differences, when comparing the the
> current official wxLua.

I don't know how "old" your version is, but if it's more than a year
old, the implementation is actually quite different. If I were you, I
would upgrade it since the Lua code has changed very little, but the
internal C/C++ has changed a lot, hopefully for the better.

Regards,
    John

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
(Continue reading)

Eero Pajarre | 4 Jun 16:58

Re: wxTimer

On Wed, Jun 4, 2008 at 5:47 PM, John Labenski <jlabenski@...> wrote:
>
> I don't know how "old" your version is, but if it's more than a year
> old, the implementation is actually quite different. If I were you, I
> would upgrade it since the Lua code has changed very little, but the
> internal C/C++ has changed a lot, hopefully for the better.

I seem to have some code lines from year 2002 ....
Here I mean my wxLuaStandaloneApp code parts, for wxLua
I am using rather recent version from CVS.

Of course I must have updated my code a lot, otherwise it would not
even compile with the current wxLua.

I will let you know when I find out what was the problem.

   Eero

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
Attila | 4 Jun 18:32

wxMutexGuiEnter

Hi all, I have a problem again :)

Previously John helped me find out what was wrong - the secondary thread  
wanted to access the GUI, which is forbidden under GTK. So I've rewritten  
my application, now it works on both OS, just I have a problem again.  
Exactly two.
1. The application is _very_ slow now
2. In this way, the program isn't punctual

This application uses luasocket, and reads the data from there, then it  
parses it, and adds some data to a ListCtrl. But. If I except (and get)  
500 lines on the socket, just about 200 appears in the list. I tried both  
wx.wxPostEvent() and MyApp:AddPendingEvent(), the result is the same. I  
made some debugs too, and I saw the data on the socket, but not on the  
connected function...

So, I've decided to check wxWidgets manual, maybe it has some tricks to  
fix this problem. I find a 'function(?)', called wxMutexGuiEnter() and  
wxMutexGuiLeave(), which provides the possibility to modify the GUI from  
the secondary threads. The only problem that wxLUA doesn't wrap wxThread.

My question(s):
- Will be that wrapped in the closer-future?
- Is there any other way to reach the GUI w/o any data get lost and the  
GUI itself freeze?

Thanks for the replyes:
Attila Pázmándi

-------------------------------------------------------------------------
(Continue reading)

Eero Pajarre | 5 Jun 15:07

Re: wxTimer

On Wed, Jun 4, 2008 at 5:58 PM, Eero Pajarre <epajarre@...> wrote:
>
> I will let you know when I find out what was the problem.
>

(I promised to tell, so here it comes)

Actually I lied earlier, but I didn't do it on purpose...

I said that I had changed my code to look like the
code from Piotr. Actually my code looked like this:

local tim=wx.wxTimer(frame);
frame:Connect(wx.wxEVT_TIMER,
	      Tick);

tim:Start(200);

And the problem is.... the word "local".

When the code file is executed if the
timer is not stored somewhere (like the globals
table) it can be garbage collected.

The difference between my application and the
official wxLua application was that my application
calls lua_gc after executing the lua file, and thus
triggers the problem immediately. with wxLua
the problem just remains hidden (for a while).

(Continue reading)

Eero Pajarre | 5 Jun 15:13

Re: wxTimer

On Wed, Jun 4, 2008 at 5:58 PM, Eero Pajarre <epajarre@...> wrote:
>
> I will let you know when I find out what was the problem.
>

(I promised to tell, so here it comes)

Actually I lied earlier, but I didn't do it on purpose...

I said that I had changed my code to look like the
code from Piotr. Actually my code looked like this:

local tim=wx.wxTimer(frame);
frame:Connect(wx.wxEVT_TIMER,
	      Tick);

tim:Start(200);

And the problem is.... the word "local".

When the code file is executed if the
timer is not stored somewhere (like the globals
table) it can be garbage collected.

The difference between my application and the
official wxLua application was that my application
calls lua_gc after executing the lua file, and thus
triggers the problem immediately. with wxLua
the problem just remains hidden (for a while).

(Continue reading)


Gmane