Reputation: 75
I am trying to build a tool that allows user to create a tree, using dynamically created and drag-gable buttons as nodes, in the GUI window. I want to add a function to my tool that allows the user to save the tree in any picture format. The saved file need not load load into my app again! Just like the Print Screen function in windows.
How do I do it ?
Thanks in Advance!
Upvotes: 3
Views: 1133
Reputation: 8558
If you mean you want to take a screenshot of your GUI, you can use ImageGrab
from the Python Imaging Library: http://effbot.org/imagingbook/imagegrab.htm
Upvotes: 0
Reputation: 20586
No special library is required, you have everything needed to grab the display of any windows and save to a file. Simething like this:
1 def OnSaveToFile( self, event ):
2 context = wx.ClientDC( self )
3 memory = wx.MemoryDC( )
4 x, y = self.ClientSize
5 bitmap = wx.EmptyBitmap( x, y, -1 )
6 memory.SelectObject( bitmap )
7 memory.Blit( 0, 0, x, y, context, 0, 0)
8 memory.SelectObject( wx.NullBitmap)
9 bitmap.SaveFile( 'test.jpg', wx.BITMAP_TYPE_JPEG )
Upvotes: 4