Re: [python-win32] VT_UI1 ByRef behavior

2007-05-09 Thread Kevin Patterson

Alrighty, I'll keep looking in to it. I think it is easy to make the buffers
get returned as a python list. Almost all the code exists to help with that.
The tough part is telling the COM that the array being passed IN needs to
become a Safe Array where the size of each element is only VT_UI1. The
buffer is a great thing for that and at first glance the only thing I can
think of would be to modify PyCom_VariantFromPyObject to check the size of
the number to see if it will fit in VT_UI1 (it is already doing this for
ints and longs)...but i think that would be way to dangerous...

I might still look into a proposal for changing the output, but for the
input, I can't think of how to do it any other way than what you already
have. Perhaps I will just have to write a script that searches my generated
file from makepy and creates a layer in the python code...instead of on the
C side...oh well...

-Kevin

On 4/29/07, Mark Hammond <[EMAIL PROTECTED]> wrote:


> I was curious is there a way to prevent an array of VT_UI1's from being
> converted to a buffer? Or perhaps a way to modify the file generated
> from "makepy" to prevent the conversion?

Nope, no such facility exists.  Feel free to propose a patch though.

Cheers,

Mark


___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Win32 service with tray icon

2007-05-09 Thread Larry Bates
Mark Hammond wrote:
>> I'm writing a win32 service in Python.  I'd like to add a
>> tray icon displayed
>> whenever the service is running.  I have played around with
>> SysTrayIcon.py
>> [1], but if a user logs off and logs back on, the tray icon
>> disappears even
>> though the service is still running.  I think the answer is
>> probably getting
>> my service to recreate the icon whenever a logon event
>> happens.  I don't
>> really know much about win32 programming, though.  Can
>> someone point me in
>> the right direction to solve this problem?
> 
> Services have trouble interacting with the desktop.  The general approach is
> to have a dedicated taskbar application that communicates with the dedicated
> service using some kind of IPC.
> 
> Mark

Mark,

Please accept my apology for hijacking this thread, but it is exactly
what I want to implement.  I have a COM object that is doing an upload.
I want a system tray icon that:

1) Shows a heartbeat (upload progress indicator)
2) Provides the user with a way to cancel the upload

I found systrayicon.py and it almost does what I want.  I thought
about using socket server/client to have the two apps communicate
but I'm at a complete loss as to how to implement socket client
in the systrayicon.py program since it uses PumpMessages.  I just
don't see how to connect to my com server (which would also be
a socket server) inside some loop mechanism.

Thanks in advance for any assistance.

Regards,
Larry Bates

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Win32 service with tray icon

2007-05-09 Thread Tim Golden
Larry Bates wrote:
> Please accept my apology for hijacking this thread, but it is exactly
> what I want to implement.  I have a COM object that is doing an upload.
> I want a system tray icon that:
> 
> 1) Shows a heartbeat (upload progress indicator)
> 2) Provides the user with a way to cancel the upload
> 
> I found systrayicon.py and it almost does what I want.  I thought
> about using socket server/client to have the two apps communicate
> but I'm at a complete loss as to how to implement socket client
> in the systrayicon.py program since it uses PumpMessages.  I just
> don't see how to connect to my com server (which would also be
> a socket server) inside some loop mechanism.

Since I assume you're not looking for cross-platform
portability here, I'd be inclined to use one of
Windows' built-in mechanisms: Events, Pipes, Messages etc.
They should mesh with a suitable message loop, eg:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82236

TJG
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] Win32 service with tray icon

2007-05-09 Thread Thomas Heller
Larry Bates schrieb:
> Mark Hammond wrote:
>>> I'm writing a win32 service in Python.  I'd like to add a
>>> tray icon displayed
>>> whenever the service is running.  I have played around with
>>> SysTrayIcon.py
>>> [1], but if a user logs off and logs back on, the tray icon
>>> disappears even
>>> though the service is still running.  I think the answer is
>>> probably getting
>>> my service to recreate the icon whenever a logon event
>>> happens.  I don't
>>> really know much about win32 programming, though.  Can
>>> someone point me in
>>> the right direction to solve this problem?
>> 
>> Services have trouble interacting with the desktop.  The general approach is
>> to have a dedicated taskbar application that communicates with the dedicated
>> service using some kind of IPC.
>> 
>> Mark
> 
> Mark,
> 
> Please accept my apology for hijacking this thread, but it is exactly
> what I want to implement.  I have a COM object that is doing an upload.
> I want a system tray icon that:
> 
> 1) Shows a heartbeat (upload progress indicator)
> 2) Provides the user with a way to cancel the upload
> 
> I found systrayicon.py and it almost does what I want.  I thought
> about using socket server/client to have the two apps communicate
> but I'm at a complete loss as to how to implement socket client
> in the systrayicon.py program since it uses PumpMessages.  I just
> don't see how to connect to my com server (which would also be
> a socket server) inside some loop mechanism.

You set the sockets to non-blocking, and use WSAAsyncSelect to get
messages posted to the messageloop when something interesting happens
to the socket.  I do not know if pywin32 exposes WSAAsyncSelect, otherwise
you can use ctypes to call it.

Thomas




___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] GetOpenFileNameW & InitialDir

2007-05-09 Thread Michel Claveau
Hi!

I'have a problem with this code :

import win32gui
fname=win32gui.GetOpenFileNameW(InitialDir="C:\\dev")[0]
print fname


The InitialDir is not set. It's already the last dir opened, and not my 
request.

Any idea ?   Thanks by advance.


Michel Claveau



___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] GetOpenFileNameW & InitialDir

2007-05-09 Thread Paul Moore
On 09/05/07, Michel Claveau <[EMAIL PROTECTED]> wrote:
> I'have a problem with this code :
>
> import win32gui
> fname=win32gui.GetOpenFileNameW(InitialDir="C:\\dev")[0]
> print fname
>
> The InitialDir is not set. It's already the last dir opened, and not my
> request.
>
> Any idea ?   Thanks by advance.

You're using the ...W form. Shouldn't you therefore be using a unicode
string for InitialDir?

Paul.
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] how to create a valid Sink

2007-05-09 Thread Mark Hammond
> I'd like to ask for help on how to create a valid event Sink
> which I can
> pass to the Advise() method of a message stores table.

This might be tricky unless pywin32 already has support for the specific
interface you need.

> Any class I made up so far gives the same error:
>
> File "", line 333, in notify
> TypeError: The Python instance can not be converted to a COM object
>
> So what attributes does an object need to be convertable to a
> COM object?

It would need to be like any other pywin32 COM object; you should be able to
find info about that on the web.

Cheers,

Mark

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] how to create a valid Sink

2007-05-09 Thread Christian K.
Mark Hammond wrote:
>> I'd like to ask for help on how to create a valid event Sink
>> which I can
>> pass to the Advise() method of a message stores table.
> 
> This might be tricky unless pywin32 already has support for the specific
> interface you need.

I want to receive 'new mail' notifications from Outlook.

>> Any class I made up so far gives the same error:
>>
>> File "", line 333, in notify
>> TypeError: The Python instance can not be converted to a COM object
>>
>> So what attributes does an object need to be convertable to a
>> COM object?
> 
> It would need to be like any other pywin32 COM object; you should be able to
> find info about that on the web.

Forgive my ignorance but those are my first steps with com. Does that 
mean I should create and register a COM server?

Basically I'm trying to reimplement the following code in python:

http://www.codeproject.com/internet/CMapiEx.asp

Up to now this was straightforward, but at this point I'm stuck.

Thanks for any help, Christian

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] how to create a valid Sink

2007-05-09 Thread Mark Hammond
> Forgive my ignorance but those are my first steps with com. Does that
> mean I should create and register a COM server?

You should create one - you probably don't need to register it.

> Basically I'm trying to reimplement the following code in python:
>
> http://www.codeproject.com/internet/CMapiEx.asp
>
> Up to now this was straightforward, but at this point I'm stuck.

I can't see anything related to a "sink" on that page - but as a start,
consider looking at the spambayes package at spambayes.org - there is code
there that deals with MAPI in various ways.

Good luck,

Mark

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


Re: [python-win32] how to create a valid Sink

2007-05-09 Thread Christian K.


Mark Hammond wrote:
>> Forgive my ignorance but those are my first steps with com. Does that
>> mean I should create and register a COM server?
>
> You should create one - you probably don't need to register it.
>
>> Basically I'm trying to reimplement the following code in python:
>>
>> http://www.codeproject.com/internet/CMapiEx.asp
>>
>> Up to now this was straightforward, but at this point I'm stuck.
>
> I can't see anything related to a "sink" on that page - but as a start,

True, I was refering to the code in the zip file on that page. I'll 
attach MAPISink.h below.


> consider looking at the spambayes package at spambayes.org - there is 
code

> there that deals with MAPI in various ways.
>

Thank you. I'll have a look at it.

Christian

#ifndef __MAPISINK_H__
#define __MAPISINK_H__


//
// File: MAPISink.h
// Description: MAPI Advise Sink Wrapper
//
// Copyright (C) 2005-2006, Noel Dillabough
//
// This source code is free to use and modify provided this notice remains 
intact and that any enhancements
// or bug fixes are posted to the CodeProject page hosting this class for the 
community to benefit.
//
// Usage: see the Codeproject article at 
http://www.codeproject.com/internet/CMapiEx.asp
//




// CMAPISink

class CMAPISink : public IMAPIAdviseSink
{
public:
CMAPISink(LPNOTIFCALLBACK lpfnCallback,LPVOID lpvContext);

// Attributes
protected:
LPNOTIFCALLBACK m_lpfnCallback;  
LPVOID m_lpvContext;  
LONG m_nRef;  

// IUnknown
public:
STDMETHOD(QueryInterface)(REFIID riid,LPVOID FAR* ppvObj);
STDMETHOD_(ULONG, AddRef)();
STDMETHOD_(ULONG, Release)();

// IMAPIAdviseSink
public:
STDMETHOD_(ULONG, OnNotify)(ULONG cNotification,LPNOTIFICATION 
lpNotifications);
};  

#endif
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Re: GetOpenFileNameW & InitialDir

2007-05-09 Thread Roger Upole
> Hi!
> 
> I'have a problem with this code :
> 
> import win32gui
> fname=win32gui.GetOpenFileNameW(InitialDir="C:\\dev")[0]
> print fname
> 
> The InitialDir is not set. It's already the last dir opened, and not my 
> request.
> 
> Any idea ?   Thanks by advance.
> 
> Michel Claveau

I can't reproduce the behaviour you describe.  What OS
and versions of Python/Pywin32 are you using ?

 Roger

___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32