Hi,
I have this example that has a trayicon with a menu, in the menu one option is to close the app, which works, the other opens a new frame
I want to have a button on that new frame that closes “everything”, so I tried to have it call the function inside the other classes that closes everything, but it is not working and I don’t know how to fix it, I hve tried “Close”, the actual function that closes everything, closing from the Menu function, destroy, and searched a lot, but I guess this is just some basic thing that I am messing up… thanks for the help
(it should still work without the file for the icon image… well, except the part that doesn’t work
···
import wx, wx.adv
class Extra(wx.Frame):
def init(self, parent, id, title, lingua):
estilo = wx.CLIP_CHILDREN | wx.FRAME_NO_TASKBAR | wx.STAY_ON_TOP
wx.Frame.init(self, parent, id, title, wx.DefaultPosition, wx.Size(750, 200), style=estilo)
self.Centre()
self.Show()
wx.Button(self, 1, “OK”, (20, 160))
self.Bind(wx.EVT_BUTTON, self.Ok, id=1)
wx.Button(self, 2, “Close”, (500, 160))
self.Bind(wx.EVT_BUTTON, self.CloseAll, id=2)
def Ok(self, event):
self.Close()
--------------------------------------------------------------------------------------- the problem (maybe
def CloseAll(self, event):
MyFrame.Close()
---------------------------------------------------------------------------------------
class MyTaskBarIcon(wx.adv.TaskBarIcon):
def init(self, frame):
wx.adv.TaskBarIcon.init(self)
self.frame = frame
self.SetIcon(wx.Icon(‘toggle1.png’, wx.BITMAP_TYPE_PNG), ‘mytaskbaricon.py’)
self.Bind(wx.EVT_MENU, self.OnTaskBarClose, id=3)
self.Bind(wx.EVT_MENU, self.OnExtra, id=4)
def CreatePopupMenu(self):
menu = wx.Menu()
menu.Append(3, ‘Close’)
menu.Append(4, ‘Extra’)
return menu
def OnExtra(self, event):
Extra(None, 50, ‘titulo do frame? importa?’, “ze”)
def OnTaskBarClose(self, *args):
self.frame.Close()
class MyFrame(wx.Frame):
def init(self, parent, id, title):
wx.Frame.init(self, parent, id, title, (-1, -1), (290, 280))
self.tskic = MyTaskBarIcon(self)
self.Centre()
self.Bind(wx.EVT_CLOSE, self.OnClose)
def OnClose(self, *args):
self.tskic.Destroy()
self.Destroy()
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, -1, ‘mytaskbaricon.py’)
frame.Show(True)
self.SetTopWindow(frame)
return True
app = MyApp(0)
app.MainLoop()