SaveFileDialog

The SaveFileDialog is very easy to use:

import clr clr.AddReference('System.Windows.Forms') clr.AddReference('System.Drawing')

from System.Drawing import Bitmap from System.Drawing.Imaging import ImageFormat from System.Windows.Forms import DialogResult, SaveFileDialog

image = Bitmap(1, 1)
 * 1) Not a very interesting image

dialog = SaveFileDialog dialog.Title = 'Save Chart as Jpg Image' dialog.Filter = 'Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*'

if dialog.ShowDialog == DialogResult.OK: # Should really check what format they *really* want! try: image.Save(dialog.FileName, ImageFormat.Jpeg) except IOError, e:       print 'An error occurred:', e

Back to Contents.