Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import PIL.Image
- import wx
- import guitrial as gui
- #--------------------------------------------------------------------
- def loadjpg2scrollbitmap(self):
- image = PIL.Image.open("picture1.jpg")
- width, height = image.size
- image2 = wx.EmptyImage( width, height )
- image2.SetData( image.tobytes() )
- self.m_bitmapScroll.SetBitmap(wx.BitmapFromImage(image2))
- class MainFrame(gui.MyFrame):
- #constructor
- def __init__(self,parent):
- #initialize parent class
- gui.MyFrame.__init__(self,parent)
- self.m_bitmapScroll.Bind( wx.EVT_MOTION, self.m_bitmapScrollOnPaint ) #for drawing
- self.m_bitmapScroll.Bind(wx.EVT_MOTION, self.OnMouseMove)
- self.panel_pos = (0,0)
- loadjpg2scrollbitmap(self)
- scrollWin = self.m_scrolledWindow1
- scrollWin.SetScrollbars(0,20,0,100)
- #-------------------------------------------------------
- # DRAW RECTANGLE WITH MOUSE, GET COORDINATES
- def m_bitmapScrollOnLeftDown( self, event ):
- self.panel_pos = self.m_bitmapScroll.ScreenToClient(wx.GetMousePosition())
- def m_bitmapScrollOnLeftUp( self,event):
- self.panel_pos2 = self.m_bitmapScroll.ScreenToClient(wx.GetMousePosition())
- def OnMouseMove(self, event):
- self.pos = event.GetPosition()
- #self.Refresh()
- print(self.pos)
- #"""
- def m_bitmapScrollOnPaint( self, event ):
- self.pos = wx.GetMousePosition()
- """
- w, h = 100, 100
- bmp = wx.EmptyBitmap(w, h)
- #dc = wx.MemoryDC()
- dc= wx.MemoryDC(self.bitmap_1)
- dc.DrawRectangle(10,10,200,200)
- dc.SelectObject(wx.NullBitmap) #This de-selects the bitmap
- #dc.SelectObject(bmp)
- dc.SelectObjectAsSource(self.m_bitmapScroll)
- dc.Clear()
- text = "whatever"
- """
- app = wx.App(False)
- frame = MainFrame(None)
- frame.Show(True)
- app.MainLoop()
- del app
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement