[wxPython-users] saving wx output as jpg
Karsten Hilbert
Karsten.Hilbert at gmx.net
Fri Dec 1 05:19:35 PST 2006
Thanks, GNUmed now features EMR screenshots for use in those
cases where I can't spare the time for properly filling in a
form. Like the near-anaphylactic shock I admitted last
night.
Karsten
On Fri, Dec 01, 2006 at 01:34:06PM +0200, Peter Damoc wrote:
> Here is a small sample that does just that... adapt it to your case. All the
> relevant code is in OnButton. ;)
>
> import wx
>
> class SFrame(wx.Frame):
> def __init__(self):
> wx.Frame.__init__(self, None, title="Window Shot")
> self.SetBackgroundColour("magenta")
> ssbutton = wx.Button(self, label = "Press For Window Shot")
> box = wx.BoxSizer(wx.VERTICAL)
> box.Add(wx.StaticText(self, label="Some Text"), 0, wx.ALIGN_CENTER)
> box.Add(ssbutton, 0, wx.ALIGN_CENTER)
> self.SetSizer(box)
>
> ssbutton.Bind(wx.EVT_BUTTON, self.OnButton)
>
> def OnButton(self, evt):
> w, h = self.GetClientSize()
> dc = wx.ClientDC(self)
> mdc = wx.MemoryDC()
> img = wx.EmptyBitmap(w, h)
> mdc.SelectObject(img)
> mdc.Blit(0,0,w,h,dc,0,0)
> img.SaveFile("winshot.jpg", wx.BITMAP_TYPE_JPEG)
> evt.Skip()
> wx.Bell()
>
> app = wx.App(0)
> frame = SFrame()
> frame.Show()
> app.MainLoop()
--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346
More information about the wxpython-users
mailing list