[PythonCE] code examples for the Wiki

Telion telionce@yahoo.com
Mon, 7 Oct 2002 08:35:54 -0700 (PDT)


Thank you Jeff.

> 1. Send a quick popup message to the user:
> 
> >>> import win32sys
> >>> win32sys.MessageBox(0, "My Message", "My Title", 1)
> >>> win32sys.MessageBeep()

I think (probably Mark?) moved MessageBeep() to win32gui.
So, it worked well just by changing win32sys to win32gui.

>>> import win32gui
>>> win32gui.MessageBox(0, "My Message", "My Title", 1)

But, it goes into TaskBar on my HPC2000.
It seems that I have to give hwnd.
(We can use sys.stdout.hwnd)


>>> win32gui.MessageBeep()
MessageBeep() does not work on my machine... 
Does it work on iPaq, Jordana?



I tested other types of MessageBox.

>>> from win32gui import MessageBox
>>> import sys
>>> hw = sys.stdout.hwnd

MessageBox(hw, "Test Message", "Test caption",0) #0 ok only. always 1
MessageBox(hw, "Test Message", "Test caption",1)  #1 No bottun 
ok,enter=1
Esc,close=2
MessageBox(hw, "Test Message", "Test caption",0 |2) #2 quit=3 retry=4 
cancel=5
MessageBox(hw, "Test Message", "Test caption",1| 2)  #3 yes=6 no=7
cancel,Esx,close=2
MessageBox(hw, "Test Message", "Test caption",0|0|4) #4  yes=6 no=7 
MessageBox(hw, "Test Message", "Test caption",1|0|4) #5  quit=4 retry=2 
MessageBox(hw, "Test Message", "Test caption",0|2|4) #6  Nothing always 
1
# 12 <== 1 button without test on it
# 16 = X icon, 32 = ? icon, 48 = ! icon, 64 = i  icon, 80 = blank icon?
# 512 <== focus on the last item
# 256 <== focus on the second bottun
# 1024 <== No focus on the bottun

MessageBox(hw, "Test Message", "Test caption",1| 2|32|256)

MessageBox(0, "Test Message", "Test caption",0|2|4) #6  It Go to 
Taskbar! (HPC
only?)
MessageBox(hw, "Do you get it?", "Python CE 2.2 ",3+32) 


> 2. Launch another CE application from Python:
> 
> >>> import win32sh
> >>> win32sh.ShellExecuteEx(0, 0, "", "\\Windows\\calc.exe",
>                           "", "\\Windows", 1)
> 
> 3. Launch a shortcut from Python:
> 
> >>> import win32sh
> >>> win32sh.SHGetShortcutTarget("\\tmp\\Expenses.lnk")
> >>> win32sh.ShellExecuteEx(0,0,"","\\tmp\\Expenses.lnk","","",1)

These one didn't go.
I think we have to verify the win32sh module.
I compiled it but I didn't have time to test.
Maybe we have to modify source code for unicode.

Yet another TO-DO items.

Meanwhile we may use win32process.CreateProcess for launching.


> 4. Obtaining the IP address from a connected CE device:
> 
> >>> import socket
> >>> hostname = socket.gethostname()
> >>> ip = socket.gethostbyname(hostname)
> >>> print ip
> 192.168.55.101

This one went without any problem

Do they work on PPC Python?





=====
Telion
- telionce@yahoo.com -
http://pages.ccapcable.com/lac/PythonCE.html

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com