Create executable for wxPython script

Hi!

I personally would suggest McMillian's installer
http://www.mcmillan-inc.com/install1.html
which looks a little bit more usefriendly for me, and also exists for
both Windows and Linux platforms.

···

----
Sincerely Yours, Victor V. Kryukov, UFG
phone: +7501 967 3727, ext. 4387
email: vkryukov@ufg.com

-----Original Message-----
From: Bjorn Platzen [mailto:bplatzen@sosnetz.de]
Sent: Tuesday, November 12, 2002 3:01 PM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Create executable for wxPython script

Hi!

> Is there a way I can package up a set of wxPython and
Python scripts to
> create an executable, so that neither Python nor wxPython need to be
> installed on the machine the scripts will be run on?

Do you want to create executables for Win, Lin or Mac?

For win there exist a distutil named py2exe[1]. This worked
good for me ...

At the bottom of the py2exe-Homepage you will find some more
links to related
work that should work on Lin as well.

hth,

Bjoern

[1] http://starship.python.net/crew/theller/py2exe/

--
small office solutions
info@sosnetz.de - http://www.sosnetz.de

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwindows.org

Hi all,

I want to second this recommendation - I use it for my program and it works like a charm. I tried py2exe first, but it seemed to have trouble including all of my program libraries, so I switched to Installer and it worked without problems. (I think it was the win32 libraries that py2exe was having trouble with, but it was a while back.) Apparently with some tweaks you can now run it on Mac OS X as well. =)

Kevin

···

On Tuesday, November 12, 2002, at 07:12 AM, Krjukov Victor wrote:

Hi!

I personally would suggest McMillian's installer
HOAX.COM: unravelling the truth from fiction, past to present...
which looks a little bit more usefriendly for me, and also exists for
both Windows and Linux platforms.

----
Sincerely Yours, Victor V. Kryukov, UFG
phone: +7501 967 3727, ext. 4387
email: vkryukov@ufg.com

-----Original Message-----
From: Bjorn Platzen [mailto:bplatzen@sosnetz.de]
Sent: Tuesday, November 12, 2002 3:01 PM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] Create executable for wxPython script

Hi!

Is there a way I can package up a set of wxPython and

Python scripts to

create an executable, so that neither Python nor wxPython need to be
installed on the machine the scripts will be run on?

Do you want to create executables for Win, Lin or Mac?

For win there exist a distutil named py2exe[1]. This worked
good for me ...

At the bottom of the py2exe-Homepage you will find some more
links to related
work that should work on Lin as well.

hth,

Bjoern

[1] http://starship.python.net/crew/theller/py2exe/

--
small office solutions
info@sosnetz.de - http://www.sosnetz.de

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwindows.org

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Hi everyone. I've written a control (subclassed from wxControl) for a
button-like object that uses an image. It's set up so that when the user
clicks on the button, it "depresses" by painting a "pressed" image on the
control (it's a more dramatic effect than a normal BitmapButton, so I had to
write my own).

Now for the problem...the images I want to use are transparent PNG's. For
example, I want to make images that look like arrows, but have transparent
backgrounds, so I can have a large button that looks like the shape of an
arrow, but will also look like the user pressed it when they click on it.
The platform I'm working on is Linux...the images display correctly when I
put them into a wxStaticBitmap (but of course the click behaviour that I
want is unavailable)

Almost everything works great, but I can't seem to get it to paint the
transparency correctly. It just shows gray in the transparent area. I'm
putting this button over the top of an existing wxStaticBitmap that fills
the screen as a background image...could that be a problem? Maybe I'm not
setting the mask correctly when I Blit the image to the screen? Or do I
need to capture what's underneath it and merge the two together before I
Blit to the screen? Maybe I can still do what I want in wxBitmapButton and
I did all this work for nothing?

Here's my relevant code if anyone needs it:

···

---------------

  def __init__(self, parent, id, imagefile, anchorpoint):
    # Other stuff deleted for brevity
    self.imgup = imagefile

    data = open(imagefile, "rb").read()
    stream = StringIO(data)
    self.bmp = wxBitmapFromImage(wxImageFromStream(stream))
    mysize = wxSize(self.bmp.GetWidth(), self.bmp.GetHeight())
    wxControl.__init__(self, parent, id, anchorpoint, mysize)

    EVT_LEAVE_WINDOW(self, self.OnMouseLeave)
    EVT_LEFT_DOWN(self, self.OnMouseDown)
    EVT_LEFT_UP(self, self.OnMouseUp)
    EVT_PAINT(self, self.OnPaint)

  def OnPaint(self, event):
    self.dc = wxPaintDC(self)
    self.DrawBMP(self.dc)

  def DrawBMP(self, dc=None):
    if dc is None:
      dc = wxClientDC(self)

    tmpdc = wxMemoryDC()
    tmpdc.SelectObject(self.bmp)
    dc.Blit( 0, 0, self.bmp.GetWidth(), self.bmp.GetHeight(), tmpdc, 0, 0,
wxCOPY, TRUE )

  def OnMouseDown(self, event):
    if self.enabled:
      self.bmp.LoadFile(self.imgdown, wxBITMAP_TYPE_PNG)
      self.DrawBMP()

  def OnMouseLeave(self, event):
    # Restore the up image in case they left focus without releasing the mouse
    if self.enabled:
      self.bmp.LoadFile(self.imgup, wxBITMAP_TYPE_PNG)
      self.DrawBMP()

  def OnMouseUp(self, event):
    if self.enabled:
      self.bmp.LoadFile(self.imgup, wxBITMAP_TYPE_PNG)
      self.DrawBMP()
---------------

Thanks!

-D

Maybe you can use static bitmaps still, put the depressed one behind the
'up' one and when they click make the 'up' one invisible.

I know you can do it with a normal DC though. In windows controls paint that
grey stuff when they erase background, I think you can intercept that event,
and paint whatever's behind your control instead of the grey stuff. I guess
the only tricky bit is finding out what to paint behind the control.
Perhaps, the first time you erase the background, copy the rect of where
your control is from the screen dc into a memory dc, then every time you
erase background blit it in...

If you get it working, upload it to the list, it'd be good to have in the
library.
      EVT_ERASE_BACKGROUND(func) Process a wxEVT_ERASE_BACKGROUND event.
Remarks

Use the m_DC device context to draw into, don't create wxPaintDC in the
event handler.

Matthew Sherborne

···

----- Original Message -----
From: "Dave Kelly" <dkelly@inav.net>
To: <wxPython-users@lists.wxwindows.org>
Sent: Thursday, November 14, 2002 5:51 AM
Subject: [wxPython-users] DC Blit with transparent image?

Hi everyone. I've written a control (subclassed from wxControl) for a
button-like object that uses an image. It's set up so that when the user
clicks on the button, it "depresses" by painting a "pressed" image on the
control (it's a more dramatic effect than a normal BitmapButton, so I had

to

write my own).

Now for the problem...the images I want to use are transparent PNG's. For
example, I want to make images that look like arrows, but have transparent
backgrounds, so I can have a large button that looks like the shape of an
arrow, but will also look like the user pressed it when they click on it.
The platform I'm working on is Linux...the images display correctly when I
put them into a wxStaticBitmap (but of course the click behaviour that I
want is unavailable)

Almost everything works great, but I can't seem to get it to paint the
transparency correctly. It just shows gray in the transparent area. I'm
putting this button over the top of an existing wxStaticBitmap that fills
the screen as a background image...could that be a problem? Maybe I'm not
setting the mask correctly when I Blit the image to the screen? Or do I
need to capture what's underneath it and merge the two together before I
Blit to the screen? Maybe I can still do what I want in wxBitmapButton

and

I did all this work for nothing?

Here's my relevant code if anyone needs it:

---------------

def __init__(self, parent, id, imagefile, anchorpoint):
# Other stuff deleted for brevity
self.imgup = imagefile

data = open(imagefile, "rb").read()
stream = StringIO(data)
self.bmp = wxBitmapFromImage(wxImageFromStream(stream))
mysize = wxSize(self.bmp.GetWidth(), self.bmp.GetHeight())
wxControl.__init__(self, parent, id, anchorpoint, mysize)

EVT_LEAVE_WINDOW(self, self.OnMouseLeave)
EVT_LEFT_DOWN(self, self.OnMouseDown)
EVT_LEFT_UP(self, self.OnMouseUp)
EVT_PAINT(self, self.OnPaint)

def OnPaint(self, event):
self.dc = wxPaintDC(self)
self.DrawBMP(self.dc)

def DrawBMP(self, dc=None):
if dc is None:
dc = wxClientDC(self)

tmpdc = wxMemoryDC()
tmpdc.SelectObject(self.bmp)
dc.Blit( 0, 0, self.bmp.GetWidth(), self.bmp.GetHeight(), tmpdc, 0, 0,
wxCOPY, TRUE )

def OnMouseDown(self, event):
if self.enabled:
self.bmp.LoadFile(self.imgdown, wxBITMAP_TYPE_PNG)
self.DrawBMP()

def OnMouseLeave(self, event):
# Restore the up image in case they left focus without releasing the mouse
if self.enabled:
self.bmp.LoadFile(self.imgup, wxBITMAP_TYPE_PNG)
self.DrawBMP()

def OnMouseUp(self, event):
if self.enabled:
self.bmp.LoadFile(self.imgup, wxBITMAP_TYPE_PNG)
self.DrawBMP()
---------------

Thanks!

-D

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Dave Kelly wrote:

Hi everyone. I've written a control (subclassed from wxControl) for a
button-like object that uses an image. It's set up so that when the user
clicks on the button, it "depresses" by painting a "pressed" image on the
control (it's a more dramatic effect than a normal BitmapButton, so I had to
write my own).

Now for the problem...the images I want to use are transparent PNG's. For
example, I want to make images that look like arrows, but have transparent
backgrounds, so I can have a large button that looks like the shape of an
arrow, but will also look like the user pressed it when they click on it.
The platform I'm working on is Linux...the images display correctly when I
put them into a wxStaticBitmap (but of course the click behaviour that I
want is unavailable)

Almost everything works great, but I can't seem to get it to paint the
transparency correctly. It just shows gray in the transparent area.

What you are seeing is the background of the wxControl window. On wxMSW you can get rid of it by catching the EVT_ERASE_BACKGROUND event and doing nothing in the handler. On other platforms you'll need to figure out what is beneath the window and drawing that on the background (this will work on windows too.)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi everyone. I've written a control (subclassed from wxControl) for a
button-like object that uses an image. It's set up so that when the user
clicks on the button, it "depresses" by painting a "pressed" image on the
control (it's a more dramatic effect than a normal BitmapButton, so I had
to write my own).

Now for the problem...the images I want to use are transparent PNG's.

For

example, I want to make images that look like arrows, but have

transparent

backgrounds, so I can have a large button that looks like the shape of an
arrow, but will also look like the user pressed it when they click on it.
The platform I'm working on is Linux...the images display correctly when

I

put them into a wxStaticBitmap (but of course the click behaviour that I
want is unavailable)

Almost everything works great, but I can't seem to get it to paint the
transparency correctly. It just shows gray in the transparent area.

What you are seeing is the background of the wxControl window. On wxMSW
you can get rid of it by catching the EVT_ERASE_BACKGROUND event and
doing nothing in the handler. On other platforms you'll need to figure
out what is beneath the window and drawing that on the background (this
will work on windows too.)

In case anyone is interested, here is how I solved this problem:

I basically created three wxMemoryDC's. Into the first one I selected a
wxEmptyBitmap of the same size as my control. Then, I created a second
wxMemoryDC into which I selected the background bitmap, offset by the size
and location of my control within the parent (i.e, this is the background
image as it would appear directly under my control). Then I created a third
wxMemoryDC into which I selected the bitmap of my button itself.

Once these were set up, I Blit'ed (is that the right verb?) the 2nd MemoryDC
onto the first, and then the 3rd onto the first, and this is what I draw to
the screen. This whole process is done in the OnPaint override. I could
probably speed it up by creating the empty and bliting the 2nd onto it, and
then saving this as a bitmap within the class instance, so I would only have
to reblit the last step each time (when the graphics change like for a
button push, etc), but maybe I'll do that another time. I can't decide if
it would be enough of a performance increase for me to bother.

Anyway, this works like a charm. Most people probably won't need this, as
not many people need a background image for a screen with a transparent
bitmap for buttons, but in my case this works well.

I can post code if anyone is interested.

-D

···

-----Original Message-----

Dave Kelly wrote:

In case anyone is interested, here is how I solved this problem:

I basically created three wxMemoryDC's. Into the first one I selected a
wxEmptyBitmap of the same size as my control. Then, I created a second
wxMemoryDC into which I selected the background bitmap, offset by the size
and location of my control within the parent (i.e, this is the background
image as it would appear directly under my control). Then I created a third
wxMemoryDC into which I selected the bitmap of my button itself.

Once these were set up, I Blit'ed (is that the right verb?) the 2nd MemoryDC
onto the first, and then the 3rd onto the first, and this is what I draw to
the screen. This whole process is done in the OnPaint override. I could
probably speed it up by creating the empty and bliting the 2nd onto it, and
then saving this as a bitmap within the class instance, so I would only have
to reblit the last step each time (when the graphics change like for a
button push, etc), but maybe I'll do that another time. I can't decide if
it would be enough of a performance increase for me to bother.

Anyway, this works like a charm. Most people probably won't need this, as
not many people need a background image for a screen with a transparent
bitmap for buttons, but in my case this works well.

I can post code if anyone is interested.

I would be, and it would be nice to add a page to the wxPyWiki about it too.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Hi Dave!

Could you please, provide this transparent button code to me? I am still
learning wxWindows and trying to do transparent buttons on top of
dynamically updated background, so your unoptimized code (everything in
OnPaint) seems like just what I need!

Thanks in advance!

···

--
Vadim Bich

----- Original Message -----
From: "Dave Kelly" <dk@alboe.org>
To: <wxPython-users@lists.wxwindows.org>
Sent: Monday, November 18, 2002 20:18
Subject: RE: [wxPython-users] DC Blit with transparent image?

>-----Original Message-----
>> Hi everyone. I've written a control (subclassed from wxControl) for a
>> button-like object that uses an image. It's set up so that when the

user

>> clicks on the button, it "depresses" by painting a "pressed" image on

the

>> control (it's a more dramatic effect than a normal BitmapButton, so I

had

>> to write my own).
>>
>> Now for the problem...the images I want to use are transparent PNG's.
For
>> example, I want to make images that look like arrows, but have
transparent
>> backgrounds, so I can have a large button that looks like the shape of

an

>> arrow, but will also look like the user pressed it when they click on

it.

>> The platform I'm working on is Linux...the images display correctly

when

I
>> put them into a wxStaticBitmap (but of course the click behaviour that

I

>> want is unavailable)
>>
>> Almost everything works great, but I can't seem to get it to paint the
>> transparency correctly. It just shows gray in the transparent area.
>
> What you are seeing is the background of the wxControl window. On wxMSW
> you can get rid of it by catching the EVT_ERASE_BACKGROUND event and
> doing nothing in the handler. On other platforms you'll need to figure
> out what is beneath the window and drawing that on the background (this
> will work on windows too.)

In case anyone is interested, here is how I solved this problem:

I basically created three wxMemoryDC's. Into the first one I selected a
wxEmptyBitmap of the same size as my control. Then, I created a second
wxMemoryDC into which I selected the background bitmap, offset by the size
and location of my control within the parent (i.e, this is the background
image as it would appear directly under my control). Then I created a

third

wxMemoryDC into which I selected the bitmap of my button itself.

Once these were set up, I Blit'ed (is that the right verb?) the 2nd

MemoryDC

onto the first, and then the 3rd onto the first, and this is what I draw

to

the screen. This whole process is done in the OnPaint override. I could
probably speed it up by creating the empty and bliting the 2nd onto it,

and

then saving this as a bitmap within the class instance, so I would only

have

to reblit the last step each time (when the graphics change like for a
button push, etc), but maybe I'll do that another time. I can't decide if
it would be enough of a performance increase for me to bother.

Anyway, this works like a charm. Most people probably won't need this, as
not many people need a background image for a screen with a transparent
bitmap for buttons, but in my case this works well.

I can post code if anyone is interested.

-D

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

OK, it's attached. Hopefully the list accepts attachments? If not, I'll
respond with a web address where people can download it. The meat of it all
is in the TransBitmapButton.py file, but I added an application and panel so
you can all see how it runs.

The enclosed .tar.gz file works great on my Linux box. I haven't tested it
on Windows, but I would think it would work OK with a little tweaking. My
example might require wxPython 2.3.3, since I'm using wxImageFromStream to
read in the image files.

You'll have to add your own background image and the 3 image files for the
button, but other than that it should work out of the box.

Robin, who takes care of adding this to the wiki? Also, maybe the class
itself could be added to the wxPython Pit if anyone else wants it.

Finally, if anyone has any enhancements, let me know where to find 'em once
you add them in! I'd like to see anything people add to this class.

-D

transparent_bitmap_button.tar.gz (2.07 KB)

···

-----Original Message-----
From: Vadim Bich [mailto:avbich@optonline.net]
Sent: Tuesday, November 19, 2002 5:22 PM
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] DC Blit with transparent image?

Hi Dave!

Could you please, provide this transparent button code to me? I am still
learning wxWindows and trying to do transparent buttons on top of
dynamically updated background, so your unoptimized code (everything in
OnPaint) seems like just what I need!

Thanks in advance!
--
Vadim Bich

Dave Kelly wrote:

Robin, who takes care of adding this to the wiki?

You do. It is a user maintained website.

Also, maybe the class
itself could be added to the wxPython Pit if anyone else wants it.

I don't think the wxPython Pit is activly maintained any more. Perhaps a page should be added to the wiki for it and then people can add/edit their own entries...

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!