Python Forum
Display transparent image as overlay
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display transparent image as overlay
#1
I am trying to create a program that simply displays a PNG (that has transparency), the image will be a map protractor that can be dragged around on the screen while viewing land navigation maps. I found the following example which almost does what i'm after, except SetTransparent() changes the alpha of the image too which i do not want, and it would be nice to get rid of the borders around the window as well (show image only).

import wx

class Frame(wx.Frame):

    def __init__(self, image, parent=None, id=-1,pos=wx.DefaultPosition, title='wxPython'):
        temp = image.ConvertToBitmap()
        size = temp.GetWidth(), temp.GetHeight()
        wx.Frame.__init__(self, parent, id, title, pos, size)
        self.bmp = wx.StaticBitmap(parent=self, bitmap=temp)
        self.SetClientSize(size)
        self.SetTransparent(100)

class App(wx.App):
    def OnInit(self):
        image = wx.Image('1.png', wx.BITMAP_TYPE_ANY)
        self.frame = Frame(image)
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True

app = App()
app.MainLoop()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to display <IPython.core.display.HTML object>? pythopen 3 46,008 May-06-2023, 08:14 AM
Last Post: pramod08728
Information Unable to display joystick's value from Python onto display box MelfoyGray 2 2,248 Nov-11-2020, 02:23 AM
Last Post: MelfoyGray
  case transparent names in configpaser Skaperen 4 2,630 Oct-02-2020, 01:16 AM
Last Post: Skaperen
  Display the bottom image of the line and cut the upper image using Opencv jenkins43 1 3,254 May-27-2019, 06:56 AM
Last Post: heiner55
  Display image from URL mr_byte31 1 20,474 Aug-25-2018, 09:59 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020