[PythonCE] PPYGUI - parent window and closing it

2008-07-10 Thread Adam Walley
Hello, Alexandre.

I have begun testing some ideas using the PPYGUI and find it very easy to
work with. However, I would like to ask if there is a way to know when the
user has pressed the 'X' button in the top right of the window to close the
app? The reason I ask, is that when I run some ppygui code a blank Python
window opens, then the ppygui app window opens on top of it. When I close
the app using the top right 'X' I am returned to the blank Python window.
This is very similar to the situation on the desktop version of Python,
where a terminal window opens unless your Python file is run with the .pyw
extension.

I can implement a 'close' button that executes the sys.exit() command, and
this successfully closes the app and the blank Python terminal window
together. Nevertheless that top right 'X' is still there, and I would prefer
the users of my app to have something consistent and which behaves as
expected (i.e when you press 'X' the app exits or at least is hidden fully).

How do it detect this 'close' event for the main app?

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


Re: [PythonCE] The State of Affairs

2008-07-10 Thread Alexandre Delattre

Chris,

Also, if we are to encourage developers to build solutions that will  
work on the PDA, I think distribution is a problem. The environment is  
workable as a hacker, but if we want to simply the deployment and  
actually ship applications, at this point it seems a bit complex. It  
would be nice if there was a Py2App, or even, something along the  
lines where the solution could be bundled into a directory (not as an  
EXE, just as Python and your application files) for easy distribution.



I do agree the distribution is problematic especially for end-users having no 
experience of python.
The problem I see with a py2exe-like solution, is that if each application should hold ~4Mb 
(which is approximatively the size of python.dll+python.exe+standard library) this limits the number of apps
you can install on a handheld device. In my opinion, the separation of interpreter and source files is a more 
viable option on PDA, even if flash memory is getting cheaper and cheaper.


What I really like to start implementing is a web-based approach of programs distribution, 
a bit like apt-get on debian linux (with a graphical frontend of course) or like the Installer.app on jailbreaked

iphones.

This way it would allow us to search/install/uninstall python programs and libs 
from a common online source, in a few clicks,
directly on pda/smartphone, or by transferring the package with traditional 
methods if the first option is not possible.
Uploading new applications should be made easy too.

To do that we need:

* Choose a package format for storage/description of application files.
 We could use .cab or design a format specific for PythonCE applications.
 Some times ago, we made some brainstorming with Jared Forsyth on a .ppyp 
format (Pocket Python Package),
 which is a distutils-like way of defining packages.
 
* Create the Installer application itself, with it's logic and gui, 
 and ship it by default in the PythonCE distribution.


* Make a desktop application for easy cross installation of packages, when 
there's no direct web access on the
 pda. I've seen there are already existing RAPI bindings, this may help a lot, 
and seems the most 'universal' way
 to transfer files (i.e. by usb)

* Set up a web service for uploading and hosting packages, managing versions, 
...
 I think Django web framework could really help here, but no problem if it's 
another framework or not even in python


While a such project won't be achieved in one day, I definitely think it is 
worth the effort and will make PythonCE
superior to .NET regarding distribution user experience.

Regards,
Alexandre

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


Re: [PythonCE] The State of Affairs

2008-07-10 Thread Brad Clements

Alexandre Delattre wrote:


What I really like to start implementing is a web-based approach of 
programs distribution, a bit like apt-get on debian linux (with a 
graphical frontend of course) or like the Installer.app on jailbreaked

iphones.


When I was working on PythonCE years ago I had the same concerns.

I am wondering if Python eggs, easyinstall and setuptools could be put 
to use for this. Rather than starting from scratch.


I think easyinstall at least gets you the dependency checking, 
downloading (non-graphical) and installation. removal is a pain.


Maybe you could start with a simple gui that uses setuptools and 
easyinstall codebase.


http://peak.telecommunity.com/DevCenter/EasyInstall



(and sorry, I no longer have a CE device but just lurk on the list these 
days),


--
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] PPYGUI - parent window and closing it

2008-07-10 Thread Alexandre Delattre

Hello, Alexandre.



I have begun testing some ideas using the PPYGUI and find it very easy to
work with. However, I would like to ask if there is a way to know when the
user has pressed the 'X' button in the top right of the window to close the
app? The reason I ask, is that when I run some ppygui code a blank Python
window opens, then the ppygui app window opens on top of it. When I close
the app using the top right 'X' I am returned to the blank Python window.
This is very similar to the situation on the desktop version of Python,
where a terminal window opens unless your Python file is run with the .pyw
extension.



I can implement a 'close' button that executes the sys.exit() command, and
this successfully closes the app and the blank Python terminal window
together. Nevertheless that top right 'X' is still there, and I would prefer
the users of my app to have something consistent and which behaves as
expected (i.e when you press 'X' the app exits or at least is hidden fully).



How do it detect this 'close' event for the main app?



Adam


Currently the best option is to install the tMan task manager 
 or others,
which allow to close program when clicking 'X' instead of the default minimize 
behaviour which is problematic
with PythonCE (other PythonCE gui toolkits have the same problem regarding 
this).

PPygui has already some inner logic, which makes the 'app.run()'
line returns when the main frame is closed (with tMan), so it'll work well with 
it.

Unfortunately the .pyw extension is buggy on PythonCE due to a mis-written 
registry key,
You can fix it with a registry editor of your choice, by setting the key:
HKEY_CLASSES_ROOT/Python.File.NoShell/Shell/Open/Command/Default = 
"\Program Files\Python25\python.exe" /nopcceshell "%1"



You can also intercept the 'close' event at application level (but still need 
tMan to work)

import ppygui as gui
class MainFrame(gui.CeFrame):
 def __init__(self):
   gui.CeFrame.__init__(self, title='Hello')
   self.bind(close=self.on_close)

 def on_close(self, ev):
   if gui.Message.yesno('Confirmation', 
'Do you want to quit', 
'question', self) == 'yes':

 ev.skip() # If user say yes, let the close event be further processed by 
the default implementation which will close the window for good


Hope this helps,
Alexandre

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


Re: [PythonCE] PPYGUI - parent window and closing it

2008-07-10 Thread Adam Walley
That's perfect! Thanks for your suggestions. I have adjusted the registry to
allow for .pyw files without the shell (CeRegEditor did the job). Now when I
run my code and press the 'X' in the top right corner, the whole thing exits
smoothly and fully - Great!

I didn't want to use tMan because that would mean that my users would need
to use/install it too. Binding the close signal to the app works very nicely
with the emulator without tMan, but not on my WM5 device (as you had
explained).

Thanks again for the assistance.

Adam.

2008/7/10 Alexandre Delattre <[EMAIL PROTECTED]>:

> Hello, Alexandre.
>>
>
>  I have begun testing some ideas using the PPYGUI and find it very easy to
>> work with. However, I would like to ask if there is a way to know when the
>> user has pressed the 'X' button in the top right of the window to close
>> the
>> app? The reason I ask, is that when I run some ppygui code a blank Python
>> window opens, then the ppygui app window opens on top of it. When I close
>> the app using the top right 'X' I am returned to the blank Python window.
>> This is very similar to the situation on the desktop version of Python,
>> where a terminal window opens unless your Python file is run with the .pyw
>> extension.
>>
>
>  I can implement a 'close' button that executes the sys.exit() command, and
>> this successfully closes the app and the blank Python terminal window
>> together. Nevertheless that top right 'X' is still there, and I would
>> prefer
>> the users of my app to have something consistent and which behaves as
>> expected (i.e when you press 'X' the app exits or at least is hidden
>> fully).
>>
>
>  How do it detect this 'close' event for the main app?
>>
>
>  Adam
>>
>
> Currently the best option is to install the tMan task manager <
> http://pda.jasnapaka.com/tman/> or others,
> which allow to close program when clicking 'X' instead of the default
> minimize behaviour which is problematic
> with PythonCE (other PythonCE gui toolkits have the same problem regarding
> this).
>
> PPygui has already some inner logic, which makes the 'app.run()'
> line returns when the main frame is closed (with tMan), so it'll work well
> with it.
>
> Unfortunately the .pyw extension is buggy on PythonCE due to a mis-written
> registry key,
> You can fix it with a registry editor of your choice, by setting the key:
> HKEY_CLASSES_ROOT/Python.File.NoShell/Shell/Open/Command/Default =
> "\Program Files\Python25\python.exe" /nopcceshell "%1"
>
>
> You can also intercept the 'close' event at application level (but still
> need tMan to work)
>
> import ppygui as gui
> class MainFrame(gui.CeFrame):
>  def __init__(self):
>   gui.CeFrame.__init__(self, title='Hello')
>   self.bind(close=self.on_close)
>
>  def on_close(self, ev):
>   if gui.Message.yesno('Confirmation','Do you want
> to quit','question', self) == 'yes':
> ev.skip() # If user say yes, let the close event be further processed
> by the default implementation which will close the window for good
>
>
> Hope this helps,
> Alexandre
>
>
___
PythonCE mailing list
PythonCE@python.org
http://mail.python.org/mailman/listinfo/pythonce


Re: [PythonCE] PPYGUI - parent window and closing it

2008-07-10 Thread Alexandre Delattre
Adam, there's one downside to not use tMan: even if the window disappear it is 
still running background and the only way to really close it is in the Memory 
app of the control panel.

But rejoice, following this discussion I've been able to modify ppygui so that 
windows are really closed even without tMan :)

Now, even a .py file will see it's terminal closed when the gui main frame is 
closed, without using tMan.

Expect to see the code in svn in a few hours.

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


Re: [PythonCE] PPYGUI - parent window and closing it

2008-07-10 Thread Adam Walley
Alexandre,

Thank you for this news. I will update things tomorrow and see if it works.
Just to be clear, when I originally tested my app, the Python shell launches
and the ppygui app opens on top of it. I was able to go into
settings/system/memory and close the Python shell without affecting the
normal operation of the ppygui. Also, when I exited my ppygui app using my
sys.exit() button everything closes correctly and is no longer resident - I
checked this in settings/system/memory. When I used the 'X' then both the
shell and the app would remain resident until I terminated them manually.
This also prevented me from running another app until I had done this.

Using the registry tweak, the Python shell is not visible and it does not
even appear in the list under settings/system/memory; only my app's name
appears. When I exit, everything is closed normally whether I use my own
sys.exit() button or the 'X' in the corner, and nothing remains in memory
(unless it somehow stays there without appearing in the system's list).

These are my experiences specific to my iPAQ1950 running WM5 and PythonCE
2.5, so other systems may not behave exactly this way (though PythonCE does
seem to be quite consistent).

Anyhow, I think this problem has been resolved, so thanks again.

Adam

On 10/07/2008, Alexandre Delattre <[EMAIL PROTECTED]>
wrote:
>
> Adam, there's one downside to not use tMan: even if the window disappear it
> is still running background and the only way to really close it is in the
> Memory app of the control panel.
>
> But rejoice, following this discussion I've been able to modify ppygui so
> that windows are really closed even without tMan :)
>
> Now, even a .py file will see it's terminal closed when the gui main frame
> is closed, without using tMan.
>
> Expect to see the code in svn in a few hours.
>
> Alexandre
>
> ___
> PythonCE mailing list
> PythonCE@python.org
> http://mail.python.org/mailman/listinfo/pythonce
>
>
___
PythonCE mailing list
PythonCE@python.org
http://mail.python.org/mailman/listinfo/pythonce