[PythonCE] DLL hourglass in ctypes

2008-08-12 Thread Adam Walley
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@python.org
http://mail.python.org/mailman/listinfo/pythonce


Re: [PythonCE] DLL hourglass in ctypes

2008-08-12 Thread Brad Clements

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,[EMAIL PROTECTED](315)268-1000
http://www.murkworks.com  
AOL-IM: BKClements


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


Re: [PythonCE] DLL hourglass in ctypes

2008-08-12 Thread Christopher Fairbairn
Hi,

On Wed 13/08/08 05:43 , "Adam Walley" [EMAIL PROTECTED] 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@python.org
http://mail.python.org/mailman/listinfo/pythonce


Re: [PythonCE] DLL hourglass in ctypes

2008-08-12 Thread Brad Clements

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,[EMAIL PROTECTED](315)268-1000
http://www.murkworks.com  
AOL-IM: BKClements


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


Re: [PythonCE] DLL hourglass in ctypes

2008-08-12 Thread John Hampton

Brad Clements wrote:

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@python.org
http://mail.python.org/mailman/listinfo/pythonce