Hi guys,
I’ve made a fully functioning wxPython app, published with Pyinstaller, but I can’t seem to make the window remain visible when clicked off to another program.
It’s a drag and drop app so I want it sitting next to my ‘finder’ window so I can drag images onto it. If I click any other window it disappears (not just to the back, but it even disappears completely even if nothing is under it). It only work if its technically ‘focussed’ and I drag images onto it from an unfocussed ‘finder’ window.
I’ve tried ‘self.SetWindowStyle(wx.STAY_ON_TOP)’ to no avail, and I’ve pasted the core of the frame code below.
(Note that I’ve removed buttons/images etc and just kept what I thought was relevant)
Any help would be greatly appreciated as it’s driving me nuts!
Would it be wxPython or PyInstaller causing the issue?
class MyFrame(wx.Frame):
def __init__(self, parent, ID, title):
wx.Frame.__init__(self, parent, ID, title, size=(300, 474), style=wx.FRAME_TOOL_WINDOW)
self.SetBackgroundColour((30, 30, 30))
self.SetWindowStyle(wx.STAY_ON_TOP)
global panel0
panel0 = wx.Panel(self, -1)
global panel1
panel1 = wx.Panel(self, -1)
global panel2
panel2 = wx.Panel(self, -1)
# wx.StaticLine(panel2, wx.ID_ANY, (100, 100), (100, 10), wx.LI_HORIZONTAL)
panel0.SetBackgroundColour((20, 20, 20))
panel1.SetBackgroundColour((30, 30, 30))
panel2.SetBackgroundColour((30, 30, 30))
# panel0.SetSize(100,100)
self.file_drop_target = DropTarget(self)
self.SetDropTarget(self.file_drop_target)
box = wx.BoxSizer(wx.VERTICAL)
box.Add(panel0, 0, wx.EXPAND, 0)
box.Add(panel1, 0, wx.EXPAND, 0)
box.Add(panel2, 0, wx.EXPAND, 0)
self.SetAutoLayout(True)
self.SetSizer(box)
self.Layout()
global mainimage
MyFrame.mainimage = wx.StaticBitmap(panel1, -1, image_file, (0, 0))
# close top menu
global closeButton
closeButton = wx.lib.buttons.GenButton(panel0, -1, label=u"\u2B24", pos=(2, 0), size=(24, 24))
# closeButton.Bind(wx.EVT_LEFT_DOWN, self.ButtonPress)
closeButton.Bind(wx.EVT_BUTTON, self.CloseApp)
closeButton.SetBackgroundColour((20, 20, 20))
closeButton.SetForegroundColour((40, 40, 40))
closeButton.SetBezelWidth(0)
closeButton.SetUseFocusIndicator(False)
closeButton.Bind(wx.EVT_ENTER_WINDOW, self.CloseButtonHover)
closeButton.Bind(wx.EVT_LEAVE_WINDOW, self.CloseButtonLeave)
# Text warnings
ch_u = "My Program"
txt2 = ch_u
st1 = wx.StaticText(panel2, label=txt2, pos=(64, 130), size=(136, 26), style=wx.ALIGN_CENTER)
st1.SetForegroundColour((70, 70, 70))
st1.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL))
MyFrame.havefiles = 0
panel0.Bind(wx.EVT_LEFT_DOWN, self.OnMouseLeftDown)
panel0.Bind(wx.EVT_MOTION, self.OnMouseMotion)
panel0.Bind(wx.EVT_LEFT_UP, self.OnMouseLeftUp)
menuBar = wx.MenuBar()
fileMenu = wx.Menu()
exitMenuItem = fileMenu.Append(wx.NewId(), "Exit", "Exit the application")
menuBar.Append(fileMenu, "&File")
self.Bind(wx.EVT_MENU, self.onExit, exitMenuItem)
self.SetMenuBar(menuBar)
``