Created
April 5, 2013 17:50
-
-
Save jarobins/5321234 to your computer and use it in GitHub Desktop.
Rotate an image in wxPython. Not working quite right
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
Created on Thu Apr 04 14:01:09 2013 | |
@author: jrobins | |
""" | |
import wx | |
class MyFrame(wx.Frame): | |
def __init__(self, *args, **kw): | |
wx.Frame.__init__(self, *args, **kw) | |
self.bitmap = wx.Bitmap('frontcv22.png') | |
self.image = self.bitmap.ConvertToImage() | |
self.img_height = self.bitmap.GetHeight() | |
self.img_width = self.bitmap.GetWidth() | |
self.img_center = (self.img_height, self.img_width) | |
print self.img_center | |
wx.EVT_PAINT(self, self.OnPaint) | |
self.Bind(wx.EVT_TIMER, self.OnTimer) | |
self.counter = 0 | |
self.Centre() | |
self.timer = wx.Timer(self) | |
self.timer.Start(50) | |
def OnPaint(self, event): | |
self.dc = wx.PaintDC(self) | |
self.dc.DrawBitmap(self.bitmap, 0, 0) | |
def OnTimer(self, event): | |
self.counter += .1 | |
self.bitmap = self.image.Rotate(self.counter, self.img_center).ConvertToBitmap() | |
self.dc.Clear() | |
self.dc.DrawBitmap(self.bitmap, 0, 0) | |
app = wx.App(False) | |
frame = MyFrame(None, -1, "Rotate") | |
frame.SetSize(wx.Size(400, 400)) | |
frame.Show(True) | |
app.MainLoop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment