DLL hourglass in ctypes

View: New views
7 Messages — Rating Filter:   Alert me  

DLL hourglass in ctypes

by Adam Walley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,
 
I am reporting back after some experimenting with building a DLL based on the SDL library. I have successfully created a very simple DLL that accepts 5 int values (color, x,y,w,h) and uses the SDL_RectFill function to draw directly to the screen. Then I use ctypes to import the DLL into pythonCE and access its functions from there. This may seem very basic, but it allows me to draw a rectangle of any size or colour to the screen, and I can do it using very straightforward python script. The DLL lives in the main Windows folder, and is automatically recognised by pythonCE when it starts.
 
My question is about the hourglass which appears on the screen while my script is running (in WM5 it's actually not an hourglass, but a kind of circular dial with windows colours). Is there any way I can prevent this from appearing while my python script runs?
 
My next plan was to try to use ppygui to make some buttons for user input.
 
Any thoughts or comments are very welcome.
 
Adam

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: DLL hourglass in ctypes

by bkc :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Adam Walley wrote:
>
>  
> My question is about the hourglass which appears on the screen while
> my script is running (in WM5 it's actually not an hourglass, but a
> kind of circular dial with windows colours). Is there any way I can
> prevent this from appearing while my python script runs?

I do not recall exactly, but I vaguely remember something about this.  
Do you have a windows message loop running?

I think the hour glass stays there until you start processing windows
messages.


--
Brad Clements,                bkc@...    (315)268-1000
http://www.murkworks.com                         
AOL-IM: BKClements

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Parent Message unknown Re: DLL hourglass in ctypes

by Christopher Fairbairn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Wed 13/08/08 05:43 , "Adam Walley" adam.walley@... sent:
> My question is about the hourglass which appears on the screen while
> my script is running (in WM5 it's actually not an hourglass, but a
> kind of circular dial with windows colours).

This is caused by a design decision from the original Windows CE port of Python.
The core executable displays a wait cursor and then waits for the internal shell
script (pcceshell.py) to load. One of the first things the shell script does is
turn off the wait cursor by calling back into the native C code.

If you run a script or do anything else which causes the python shell not to
load, the cursor won't be hidden. Libraries such as ppygui "resolve" this by
explictly hiding the wait cursor as part of their own initialisation process.

They use code along the lines of:

   import _pcceshell_support
  _pcceshell_support.Busy(0);

I haven't liked this, since it means each library needs to be aware of something
PythonCE specific. For cleaness I think the native C part of the Python
interpreter can (and should) take care of this.

Three options I experimented with were

1) Removing the wait cursor entirely if the PythonCE executable was being started
to run a specific script (didn't work too well, depending upon the size of your
script this meant the user was presented with no visual que that anything was
happening for a long period of time).

2) Modifying the script loading mechanism in pythonce.c so the native C code is
aware once the script has been parsed, but hasn't started execution and have it
explictly turn off the wait cursor before handing control over to the python code.

3) Always load the shell (even if PythonCE is started to run a specific script),
then launch the user script by simulating the user entering a call to the
execfile function.

If anyone is actively working on the core interpreter I would be happy to share
more detailed thoughts.

Hope it helps,
Christopher Fairbairn

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: DLL hourglass in ctypes

by bkc :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Christopher Fairbairn wrote:

>
> They use code along the lines of:
>
>    import _pcceshell_support
>   _pcceshell_support.Busy(0);
>
> I haven't liked this, since it means each library needs to be aware of something
> PythonCE specific. For cleaness I think the native C part of the Python
> interpreter can (and should) take care of this.
>  
Ah, this rings a bell.

I think according to the Windows CE compatibility guide, you're supposed
to show the hourglass until your application is "ready for user input".

I believe it's up to the application .py file, not any libraries or
interpreter, to make the Busy(0) call.

Only the application author knows how many modules need to be loaded and
when the application really has "started".



--
Brad Clements,                bkc@...    (315)268-1000
http://www.murkworks.com                         
AOL-IM: BKClements

_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: DLL hourglass in ctypes

by John Hampton-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Brad Clements wrote:
<snip>
> I think according to the Windows CE compatibility guide, you're supposed
> to show the hourglass until your application is "ready for user input".
>
> I believe it's up to the application .py file, not any libraries or
> interpreter, to make the Busy(0) call.
>
> Only the application author knows how many modules need to be loaded and
> when the application really has "started".

I'll admit to being completely out of my league when it comes to how
windows CE development should be done, however, I do like the idea of
being able to leave the hourglas running until I'm "ready for input".
I'm in the midst of creating a scanning application that will be loading
quite a few modules, and it would be nice to have the visual clue that
the user needs to wait.

Additionally, it would be nice to be able to turn on the hourglass when
entering a method that may take a while to complete. (I'm sure there is
probably an easy way to do this, I'm just not familiar with it yet.)

-John
_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: DLL hourglass in ctypes

by Adam Walley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, my initial question certainly seems to have stirred some interest. Thanks to everyone for the input. I think what I can draw from all this is that:

1. The hourglass/busy icon is useful to give users an indication of when the application is busy 'grinding' away at something and user input is not expected/possible at that time - as in the application John described in a previous post.

2. The hourglass/busy icon is NOT helpful when the application is doing some processing that involves some visual effects, since the hourglass/busy icon then interferes and obscures the display. This is a nuisance, when the application is trying to display something on screen (whether it requires user input or not). I would say most pygame applications fall into this category (and the idea of pygame for PythonCE is what prompted this post in the first place).

My conclusion would be that while there is no harm in having this icon appear by default, it cannot be left to the system to decide when the icon should appear. Therefore, a method of 'disabling' the icon, at least for the duration of the execution of a script, would be useful.

Jared kindly pointed out that the ppygui package already has this covered, so at least in the first instance I will see whether I can combine what I have built so far with ppygui to see if I can achieve a satisfactory result.

Thanks again to all.

Adam


2008/8/13 Brad Clements <bkc@...>
Christopher Fairbairn wrote:

They use code along the lines of:

  import _pcceshell_support
 _pcceshell_support.Busy(0);

I haven't liked this, since it means each library needs to be aware of something
PythonCE specific. For cleaness I think the native C part of the Python
interpreter can (and should) take care of this.
 
Ah, this rings a bell.

I think according to the Windows CE compatibility guide, you're supposed to show the hourglass until your application is "ready for user input".

I believe it's up to the application .py file, not any libraries or interpreter, to make the Busy(0) call.

Only the application author knows how many modules need to be loaded and when the application really has "started".




--
Brad Clements,                bkc@...    (315)268-1000
http://www.murkworks.com                          AOL-IM: BKClements

_______________________________________________


_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce

Re: DLL hourglass in ctypes

by Adam Walley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just one more note on this. Having tinkered a little with ppygui, I decided that although it is a very fine package, it would not really help with what I am aiming for - mainly because it is event based, whereas pygame apps would tend to need 'real-time' interaction, rather than waiting for the user to press something. If someone knows where/how I would put a main loop into a ppygui app then let me know.

I did find that adding the lines:

   import _pcceshell_support
   _pcceshell_support.Busy(0)

worked like a dream! No more hourglass/busy indicator/color wheel or whatever it's called (not knowing makes it harder to google). So thanks to Christopher for that tip.

Adam.

2008/8/13 Adam Walley <adam.walley@...>
Well, my initial question certainly seems to have stirred some interest. Thanks to everyone for the input. I think what I can draw from all this is that:

1. The hourglass/busy icon is useful to give users an indication of when the application is busy 'grinding' away at something and user input is not expected/possible at that time - as in the application John described in a previous post.

2. The hourglass/busy icon is NOT helpful when the application is doing some processing that involves some visual effects, since the hourglass/busy icon then interferes and obscures the display. This is a nuisance, when the application is trying to display something on screen (whether it requires user input or not). I would say most pygame applications fall into this category (and the idea of pygame for PythonCE is what prompted this post in the first place).

My conclusion would be that while there is no harm in having this icon appear by default, it cannot be left to the system to decide when the icon should appear. Therefore, a method of 'disabling' the icon, at least for the duration of the execution of a script, would be useful.

Jared kindly pointed out that the ppygui package already has this covered, so at least in the first instance I will see whether I can combine what I have built so far with ppygui to see if I can achieve a satisfactory result.

Thanks again to all.

Adam


2008/8/13 Brad Clements <bkc@...>

Christopher Fairbairn wrote:

They use code along the lines of:

  import _pcceshell_support
 _pcceshell_support.Busy(0);

I haven't liked this, since it means each library needs to be aware of something
PythonCE specific. For cleaness I think the native C part of the Python
interpreter can (and should) take care of this.
 
Ah, this rings a bell.

I think according to the Windows CE compatibility guide, you're supposed to show the hourglass until your application is "ready for user input".

I believe it's up to the application .py file, not any libraries or interpreter, to make the Busy(0) call.

Only the application author knows how many modules need to be loaded and when the application really has "started".




--
Brad Clements,                bkc@...    (315)268-1000
http://www.murkworks.com                          AOL-IM: BKClements

_______________________________________________



_______________________________________________
PythonCE mailing list
PythonCE@...
http://mail.python.org/mailman/listinfo/pythonce