Domi 0 Newbie Poster

Is there any way to access a specific Window/Frame?

#!/usr/bin/python

# communicate.py

import wx


class LeftPanel(wx.Panel):
	
	
    def __init__(self, parent, id):
        wx.Panel.__init__(self, parent, id, style=wx.BORDER_SUNKEN)
        self.count = 0
		
        button1 = wx.Button(self, -1, "new frame", (-1, -1))
        self.Bind(wx.EVT_BUTTON, self.OnNewFrame, id=button1.GetId())
		
	
    def OnNewFrame(self,event):
        StockFrame(self,-1,'window %s' %self.count)
        self.count = self.count + 1


class StockFrame(wx.Frame):
    def __init__(self,parent,id,title):
        wx.Frame.__init__(self, parent,id,title,size=(-1,-1))
        
        self.newpanel = wx.Panel(self,-1)

        self.Center()
        self.Show(True)
		
	
class Communicate(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, size=(-1, 70))

        panel = wx.Panel(self, -1)

        leftPanel = LeftPanel(panel, -1)

        hbox = wx.BoxSizer()
        hbox.Add(leftPanel, 1, wx.EXPAND | wx.ALL, 5)

			
        panel.SetSizer(hbox) 
        self.Centre()
        self.Show(True)
		
		

app = wx.App()
Communicate(None, -1, 'widgets communicate')
app.MainLoop()

With that code, everytime I click "new frame" button it creates a new window with a different name, but what I want it to do is be able to close a specific window (say, I hit the button 5 times and I want to close Window 3). Currently I have no idea how to implement that. Also is it possible to only have one window open at a time per event? (I mean, "new frame" button can only create a specific window and only one version of that window can be open at any given time).

This has been boggling me for the last few hours and currently, I've found no real way to implement this :(, any help is appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.