PtUnrealizeWidget problem.

Why PtUnrealizeWidget/PtRealizeWidget do not remove , return text from the
display?

Janusz Ruszel.





#include <stdio.h>

#include <Pt.h>

#include <sys/neutrino.h>

PhArea_t area = { {0, 0}, {200,40} };

PtWidget_t *window;

PtWidget_t *txt;

PhPoint_t pos = {-100,-100};

void *

slowThread( void*)

{

while (true)

{

PtEnter(0);

PtUnrealizeWidget(txt);

sleep(3);

PtRealizeWidget(txt);

PtLeave(0);

sleep(3);


printf(“run\n”);

}

}

main(int argc, char *argv[])

{

PtAppContext_t app;

int nargs = 0;

PtArg_t args[4];



if (PtInit(NULL) == -1)

PtExit(EXIT_FAILURE);

PtSetArg(&args[nargs++], Pt_ARG_POS, &area.pos, 0);

PtSetArg(&args[nargs++], Pt_ARG_DIM, &area.size,

0);

PtSetArg(&args[nargs++], Pt_ARG_WINDOW_TITLE,

“hello”, 0);

if ((window = PtCreateWidget(PtWindow,

Pt_NO_PARENT,

nargs, args)) == NULL)

PtExit(EXIT_FAILURE);

nargs = 0;

area.pos.y = 15;

PtSetArg(&args[nargs++], Pt_ARG_POS, &area.pos, 0);

PtSetArg(&args[nargs++], Pt_ARG_DIM, &area.size,

0);

PtSetArg(&args[nargs++], Pt_ARG_TEXT_STRING,

“hello, world…”, 0);

txt = PtCreateWidget(PtText, window, nargs, args);

PtRealizeWidget(window);


ThreadCreate(

0,

slowThread,

NULL,

NULL );




PtMainLoop();

}

Try a PtFlush() to apply the changes you made immediately.
Markus

“Janusz Ruszel” <janusz_ruszel@notvalid.com> schrieb im Newsbeitrag
news:bfhlsg$sml$1@inn.qnx.com

Why PtUnrealizeWidget/PtRealizeWidget do not remove , return text from the
display?

Janusz Ruszel.





#include <stdio.h

#include <Pt.h

#include <sys/neutrino.h

PhArea_t area = { {0, 0}, {200,40} };

PtWidget_t *window;

PtWidget_t *txt;

PhPoint_t pos = {-100,-100};

void *

slowThread( void*)

{

while (true)

{

PtEnter(0);

PtUnrealizeWidget(txt);

sleep(3);

PtRealizeWidget(txt);

PtLeave(0);

sleep(3);


printf(“run\n”);

}

}

main(int argc, char *argv[])

{

PtAppContext_t app;

int nargs = 0;

PtArg_t args[4];



if (PtInit(NULL) == -1)

PtExit(EXIT_FAILURE);

PtSetArg(&args[nargs++], Pt_ARG_POS, &area.pos, 0);

PtSetArg(&args[nargs++], Pt_ARG_DIM, &area.size,

0);

PtSetArg(&args[nargs++], Pt_ARG_WINDOW_TITLE,

“hello”, 0);

if ((window = PtCreateWidget(PtWindow,

Pt_NO_PARENT,

nargs, args)) == NULL)

PtExit(EXIT_FAILURE);

nargs = 0;

area.pos.y = 15;

PtSetArg(&args[nargs++], Pt_ARG_POS, &area.pos, 0);

PtSetArg(&args[nargs++], Pt_ARG_DIM, &area.size,

0);

PtSetArg(&args[nargs++], Pt_ARG_TEXT_STRING,

“hello, world…”, 0);

txt = PtCreateWidget(PtText, window, nargs, args);

PtRealizeWidget(window);


ThreadCreate(

0,

slowThread,

NULL,

NULL );




PtMainLoop();

}

Janusz Ruszel wrote:

Why PtUnrealizeWidget/PtRealizeWidget do not remove , return text from the
display?

Janusz Ruszel.



#include <stdio.h

#include <Pt.h

#include <sys/neutrino.h

PhArea_t area = { {0, 0}, {200,40} };

PtWidget_t *window;

PtWidget_t *txt;

PhPoint_t pos = {-100,-100};

void *

slowThread( void*)

{

while (true)

{

PtEnter(0);

PtUnrealizeWidget(txt);

sleep(3);

PtRealizeWidget(txt);

PtLeave(0);

sleep(3);



printf(“run\n”);

}

}

main(int argc, char *argv[])

{

PtAppContext_t app;

int nargs = 0;

PtArg_t args[4];



if (PtInit(NULL) == -1)

PtExit(EXIT_FAILURE);

PtSetArg(&args[nargs++], Pt_ARG_POS, &area.pos, 0);

PtSetArg(&args[nargs++], Pt_ARG_DIM, &area.size,

0);

PtSetArg(&args[nargs++], Pt_ARG_WINDOW_TITLE,

“hello”, 0);

if ((window = PtCreateWidget(PtWindow,

Pt_NO_PARENT,

nargs, args)) == NULL)

PtExit(EXIT_FAILURE);

nargs = 0;

area.pos.y = 15;

PtSetArg(&args[nargs++], Pt_ARG_POS, &area.pos, 0);

PtSetArg(&args[nargs++], Pt_ARG_DIM, &area.size,

0);

PtSetArg(&args[nargs++], Pt_ARG_TEXT_STRING,

“hello, world…”, 0);

txt = PtCreateWidget(PtText, window, nargs, args);

PtRealizeWidget(window);



ThreadCreate(

0,

slowThread,

NULL,

NULL );



PtMainLoop();

}

I think just calling the sleep - function will not do the trick! You have
to give Photon the chance to work in the background!
Try to call PtBkgdHandlerProcess() after the Realize/Unrealize and before
the sleep function!
Good luck,
Frank

PtFlush() does not work in this case.
Janusz
“Markus Loffler” <markus@qrts.com> wrote in message
news:bfi60a$9vb$1@inn.qnx.com

Try a PtFlush() to apply the changes you made immediately.
Markus

“Janusz Ruszel” <> janusz_ruszel@notvalid.com> > schrieb im Newsbeitrag
news:bfhlsg$sml$> 1@inn.qnx.com> …
Why PtUnrealizeWidget/PtRealizeWidget do not remove , return text from
the
display?

Janusz Ruszel.





#include <stdio.h

#include <Pt.h

#include <sys/neutrino.h

PhArea_t area = { {0, 0}, {200,40} };

PtWidget_t *window;

PtWidget_t *txt;

PhPoint_t pos = {-100,-100};

void *

slowThread( void*)

{

while (true)

{

PtEnter(0);

PtUnrealizeWidget(txt);

sleep(3);

PtRealizeWidget(txt);

PtLeave(0);

sleep(3);


printf(“run\n”);

}

}

main(int argc, char *argv[])

{

PtAppContext_t app;

int nargs = 0;

PtArg_t args[4];



if (PtInit(NULL) == -1)

PtExit(EXIT_FAILURE);

PtSetArg(&args[nargs++], Pt_ARG_POS, &area.pos, 0);

PtSetArg(&args[nargs++], Pt_ARG_DIM, &area.size,

0);

PtSetArg(&args[nargs++], Pt_ARG_WINDOW_TITLE,

“hello”, 0);

if ((window = PtCreateWidget(PtWindow,

Pt_NO_PARENT,

nargs, args)) == NULL)

PtExit(EXIT_FAILURE);

nargs = 0;

area.pos.y = 15;

PtSetArg(&args[nargs++], Pt_ARG_POS, &area.pos, 0);

PtSetArg(&args[nargs++], Pt_ARG_DIM, &area.size,

0);

PtSetArg(&args[nargs++], Pt_ARG_TEXT_STRING,

“hello, world…”, 0);

txt = PtCreateWidget(PtText, window, nargs, args);

PtRealizeWidget(window);


ThreadCreate(

0,

slowThread,

NULL,

NULL );




PtMainLoop();

}
\

PtBkgdHandlerProcess() does the trick ( thanks ) but only when mouse coursor
pointing out the window. The test window does not need to be focused.
Janusz.

“Frank” <nospam@please.com> wrote in message
news:bfinmn$lb1$1@tiger.openqnx.com

Janusz Ruszel wrote:

Why PtUnrealizeWidget/PtRealizeWidget do not remove , return text from
the
display?

Janusz Ruszel.





#include <stdio.h

#include <Pt.h

#include <sys/neutrino.h

PhArea_t area = { {0, 0}, {200,40} };

PtWidget_t *window;

PtWidget_t *txt;

PhPoint_t pos = {-100,-100};

void *

slowThread( void*)

{

while (true)

{

PtEnter(0);

PtUnrealizeWidget(txt);

sleep(3);

PtRealizeWidget(txt);

PtLeave(0);

sleep(3);


printf(“run\n”);

}

}

main(int argc, char *argv[])

{

PtAppContext_t app;

int nargs = 0;

PtArg_t args[4];



if (PtInit(NULL) == -1)

PtExit(EXIT_FAILURE);

PtSetArg(&args[nargs++], Pt_ARG_POS, &area.pos, 0);

PtSetArg(&args[nargs++], Pt_ARG_DIM, &area.size,

0);

PtSetArg(&args[nargs++], Pt_ARG_WINDOW_TITLE,

“hello”, 0);

if ((window = PtCreateWidget(PtWindow,

Pt_NO_PARENT,

nargs, args)) == NULL)

PtExit(EXIT_FAILURE);

nargs = 0;

area.pos.y = 15;

PtSetArg(&args[nargs++], Pt_ARG_POS, &area.pos, 0);

PtSetArg(&args[nargs++], Pt_ARG_DIM, &area.size,

0);

PtSetArg(&args[nargs++], Pt_ARG_TEXT_STRING,

“hello, world…”, 0);

txt = PtCreateWidget(PtText, window, nargs, args);

PtRealizeWidget(window);


ThreadCreate(

0,

slowThread,

NULL,

NULL );




PtMainLoop();

}



I think just calling the sleep - function will not do the trick! You have
to give Photon the chance to work in the background!
Try to call PtBkgdHandlerProcess() after the Realize/Unrealize and before
the sleep function!
Good luck,
Frank

Janusz Ruszel <janusz_ruszel@notvalid.com> wrote:

PtFlush() does not work in this case.

Where did you put the call? :slight_smile:

I took your code and added two PtFlush() calls to it: one before the
sleep() and the other one before the PtLeave(). And the program now
does what I think you wanted it to do. :slight_smile:

BTW It’s not a good idea to call PtExit() if PtInit() has failed. Like
most other Pt functions, PtExit() should only be called after PtInit()
has succeeded.

“Wojtek Lerch” <wojtek_l@yahoo.ca> wrote in message
news:bfjn89$fe6$1@inn.qnx.com

Janusz Ruszel <> janusz_ruszel@notvalid.com> > wrote:
PtFlush() does not work in this case.

Where did you put the call? > :slight_smile:

I took your code and added two PtFlush() calls to it: one before the
sleep() and the other one before the PtLeave(). And the program now
does what I think you wanted it to do. > :slight_smile:

The text is still does not remov from the window.
I wanted the text to shows up and removes from the window. This is what I
wanted to do :slight_smile:

BTW It’s not a good idea to call PtExit() if PtInit() has failed. Like
most other Pt functions, PtExit() should only be called after PtInit()
has succeeded.

This code is a part of Photon documentation, I cut and pasted from.

Janusz Ruszel.

Janusz Ruszel <janusz_ruszel@notvalid.com> wrote:

“Wojtek Lerch” <> wojtek_l@yahoo.ca> > wrote in message
news:bfjn89$fe6$> 1@inn.qnx.com> …
Janusz Ruszel <> janusz_ruszel@notvalid.com> > wrote:
PtFlush() does not work in this case.

Where did you put the call? > :slight_smile:

I took your code and added two PtFlush() calls to it: one before the
sleep() and the other one before the PtLeave(). And the program now
does what I think you wanted it to do. > :slight_smile:

The text is still does not remov from the window.
I wanted the text to shows up and removes from the window. This is what I
wanted to do > :slight_smile:

That’s what it does dor me. Are you running 6.2.1B?

BTW It’s not a good idea to call PtExit() if PtInit() has failed. Like
most other Pt functions, PtExit() should only be called after PtInit()
has succeeded.

This code is a part of Photon documentation, I cut and pasted from.

I’ll ask the docs people to fix this. Thanks.

“Wojtek Lerch” <wojtek_l@yahoo.ca> wrote in message
news:bfk2tg$mnn$1@inn.qnx.com

Janusz Ruszel <> janusz_ruszel@notvalid.com> > wrote:
“Wojtek Lerch” <> wojtek_l@yahoo.ca> > wrote in message
news:bfjn89$fe6$> 1@inn.qnx.com> …
Janusz Ruszel <> janusz_ruszel@notvalid.com> > wrote:
PtFlush() does not work in this case.

Where did you put the call? > :slight_smile:

I took your code and added two PtFlush() calls to it: one before the
sleep() and the other one before the PtLeave(). And the program now
does what I think you wanted it to do. > :slight_smile:

The text is still does not remov from the window.
I wanted the text to shows up and removes from the window. This is what
I
wanted to do > :slight_smile:

That’s what it does dor me. Are you running 6.2.1B?

I am running 6.2.0 A.

BTW It’s not a good idea to call PtExit() if PtInit() has failed. Like
most other Pt functions, PtExit() should only be called after PtInit()
has succeeded.

This code is a part of Photon documentation, I cut and pasted from.

I’ll ask the docs people to fix this. Thanks.

Hi,

I had the same phenomenon as you did: when I used the
PtBkgdHandlerProcess() function, the widget got realized/unrealized when
it had the focus on itself.
I removed these calls and had only the PtFlush-calls after the
realize/unrealize calls in my code, everything is working fine!