I guess you could just rebind the button's click event to
def DoNothing(self, event): pass
instead of hiding it?
And then bind it back to the real event handler whenever you feel like.
I was also interested in the question in the subject line, so I wrote
a couple of lines (basically, the key stuff here is wxClientDC and
wxClientDC.Blit):
import wx
class MyApplication(wx.App):
def OnInit(self):
mainWin = MyWindow(None, -1, "doh")
self.SetTopWindow(mainWin)
return True
class MyWindow(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self, parent,
title = title,
size = (600, 400))
mainNotebook = wx.Notebook(self, wx.ID_ANY)
tabPanel = MyPanel(mainNotebook)
mainNotebook.AddPage(tabPanel, "Untitled")
self.Show(True)
class MyPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
panelSizer = wx.BoxSizer(wx.HORIZONTAL)
button = wx.Button(self, label = "button")
button.Bind(wx.EVT_BUTTON, self.OnBtnClick)
button2 = wx.Button(self, label = "button2")
panelSizer.Add(button)
panelSizer.Add(button2)
self.SetSizer(panelSizer)
def OnBtnClick(self, event):
windowDC = wx.ClientDC(self.GetParent())
panelDC = wx.ClientDC(self)
panelDC.Blit(150, 150, 200, 60, windowDC, 0, 0)
if __name__ == '__main__':
appClass = MyApplication(0)
appClass.MainLoop()
That should get you going
//Jonatan
···
On Mon, 3 Jan 2005 16:57:56 -0500, Ed Leafe <ed@leafe.com> wrote:
I'm wondering if there is a way to capture the image of what a control
would look like if it were visible. In other words, I'd like to create,
say, a wx.Button, and then either move it to (-500, -500) or make it
invisible with Show(False), so that it isn't available for the user to
click on or to receive mouse events. But I'd like to then create a
panel to serve as a proxy to the button, and somehow capture the image
of what the button would look like if it were visible, and then use a
DC to draw it on the panel. The user would interact with the panel,
which is only used for design purposes, and which should never get
focus or respond to clicks, etc.Am I being clear? And if so, is what I'm describing possible?