title: How to judge bmp pictures from clipboard whether they are same using wxpython?
body: <p>Function that I want to realize: 
  when the bmp picture get from clipboard is changed, refresh window. If not, nothing will be done.</p>
  
  <p>Question that I meet: 
  every time my program goes into function UpdateMsgShownArea(), self.oldBmp will be diff with self.bmp, but I have already let self.oldBmp = self.bmp if they are different, and it prints "111111". While next time the program goes into UpdateMsgShownArea(), self.oldBmp will be diff with self.bmp again. It confuses me.</p>
  
  <p><a href="https://i.stack.imgur.com/b4j9B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b4j9B.png" alt="my print message image"></a></p>
  
  <p>code as follows:</p>
  
  <pre><code>#!/usr/bin/env python
  
  import wx
  import os, sys
  
  #----------------------------------------------------------------------------
  
  # main window
  class MyFrame(wx.Frame):
      def __init__(self, parent, title):
          wx.Frame.__init__(self, parent, title=title, size=(600,480))
          self.panel = MyPanel(self)
          self.CreateStatusBar() # A StatusBar in the bottom of the window
  
          # Setting up the menu.
          filemenu= wx.Menu()
  
          # wx.ID_ABOUT and wx.ID_EXIT are standard ids provided by wxWidgets.
          menuAbout = filemenu.Append(wx.ID_ABOUT, "&amp;About"," Information about this program")
          menuExit = filemenu.Append(wx.ID_EXIT,"E&amp;xit"," Terminate the program")
  
          # Creating the menubar.
          menuBar = wx.MenuBar()
          menuBar.Append(filemenu,"&amp;File") # Adding the "filemenu" to the MenuBar
          self.SetMenuBar(menuBar)  # Adding the MenuBar to the Frame content.
  
          # Set events.
          self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)
          self.Bind(wx.EVT_MENU, self.OnExit, menuExit)
  
          self.Show(True)
  
      def OnAbout(self,e):
          # A message dialog box with an OK button. wx.OK is a standard ID in wxWidgets.
          dlg = wx.MessageDialog( self, "A small text editor", "About Sample Editor", wx.OK)
          dlg.ShowModal() # Show it
          dlg.Destroy() # finally destroy it when finished.
  
      def OnExit(self,e):
          self.Close(True)  # Close the frame.
  
  #----------------------------------------------------------------------------
  
  # main panel
  class MyPanel(wx.Panel):
      def __init__(self, parent):
          wx.Panel.__init__(self, parent, -1)
  
          # shared path boxsizer, DirPickerCtrl is alternative and better realization for textCtrl + btn
          sharedPathStaticText = wx.StaticText(self, -1, 'Shared Dir:')
          self.sharedPathTextCtrl = wx.TextCtrl(self, -1, 'Please choose a dir', style = wx.TE_READONLY|wx.TE_RICH)
          sharedPathBtn = wx.Button(self, -1, 'Browse', name = 'Shared dir button')
  
  
          box1 = wx.BoxSizer(wx.HORIZONTAL)
          box1.Add(sharedPathStaticText, 0, wx.ALIGN_CENTER)
          box1.Add(self.sharedPathTextCtrl, 1, wx.ALIGN_CENTER|wx.LEFT|wx.RIGHT, 5) # proportion = 1, border = 5
          box1.Add(sharedPathBtn, 0)
  
          self.Bind(wx.EVT_BUTTON, self.OnOpen, sharedPathBtn)
  
          # local path boxsizer
          localPathStaticText = wx.StaticText(self, -1, 'Local Dir:   ')
          self.localPathTextCtrl = wx.TextCtrl(self, -1, 'Please choose a dir', style = wx.TE_READONLY|wx.TE_RICH)
          localPathBtn = wx.Button(self, -1, 'Browse', name = 'local dir button')
  
          box2 = wx.BoxSizer(wx.HORIZONTAL)
          box2.Add(localPathStaticText, 0, wx.ALIGN_CENTER)
          box2.Add(self.localPathTextCtrl, 1, wx.ALIGN_CENTER|wx.LEFT|wx.RIGHT, 5) # proportion = 1, border = 5
          box2.Add(localPathBtn, 0)
  
          self.Bind(wx.EVT_BUTTON, self.OnOpen, localPathBtn)
  
          # message show area
          messageShowStaticText = wx.StaticText(self, -1, 'Sync info shown area:   ')
  
          box5 = wx.BoxSizer(wx.HORIZONTAL)
          box5.Add(messageShowStaticText, 0, wx.ALIGN_LEFT)
  
          # size (200,200) don't take effect
          #msgShowAreaID = wx.NewId()
          #print msgShowAreaID
          self.msgShowArea = wx.ScrolledWindow(self, -1, size = (200,200), style = wx.SIMPLE_BORDER)
  
          box3 = wx.BoxSizer(wx.HORIZONTAL)
          box3.Add(self.msgShowArea, 1, wx.ALIGN_CENTER, 10)
  
          # sync ctrl buttons
          stopSyncBtn = wx.Button(self, -1, 'Stop Sync', name = 'Stop Sync button')
          resumeSyncBtn = wx.Button(self, -1, 'Resume Sync', name = 'Resume Sync button')
  
          box4 = wx.BoxSizer(wx.HORIZONTAL)
          box4.Add(stopSyncBtn, 0, wx.ALIGN_CENTER|wx.RIGHT, 20)
          box4.Add(resumeSyncBtn, 0, wx.ALIGN_CENTER|wx.LEFT, 20)
  
          # sizer
          sizer = wx.BoxSizer(wx.VERTICAL)
          sizer.Add(box1, 0, wx.EXPAND|wx.ALL, 10)
          sizer.Add(box2, 0, wx.EXPAND|wx.ALL, 10)
          sizer.Add(box5, 0, wx.EXPAND|wx.ALL, 10)
          sizer.Add(box3, 0, wx.EXPAND|wx.ALL, 10)
          sizer.Add(box4, 0, wx.ALIGN_CENTER, 10)
  
          self.SetSizer(sizer)
          self.SetAutoLayout(True)
  
          # clipboard
          self.clip = wx.Clipboard()
          self.x = wx.BitmapDataObject()
          self.bmp = None
          self.oldBmp = None
  
          self.msgShowArea.Bind(wx.EVT_IDLE, self.UpdateMsgShownArea)
          self.msgShowArea.Bind(wx.EVT_PAINT, self.OnPaint)
  
      def OnOpen(self, e):
          """ Open a file"""
          button = e.GetEventObject()
          dlg = wx.DirDialog(self, "Choose a dir", "", wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST)
          if dlg.ShowModal() == wx.ID_OK:
              path = dlg.GetPath()
  
              if button.GetName() == 'Shared dir button':
                  self.sharedPathTextCtrl.SetValue(path)
              if  button.GetName() == 'local dir button':
                  self.localPathTextCtrl.SetValue(path)
          dlg.Destroy()
  
      def UpdateMsgShownArea(self, e):
          print "UpdateMsgShownArea"
          self.clip.Open()
          self.clip.GetData(self.x)
          self.clip.Close()
          self.bmp = self.x.GetBitmap()
          if self.oldBmp == self.bmp:
              print "same pic"
              return
          else:
              print "diff pic"
              self.oldBmp = self.bmp
              if  self.oldBmp == self.bmp:
                  print "111111"
              else:
                  print "222222"
  
          print "abcd"
          #self.Refresh()
          #self.msgShowArea.Refresh()
  
      def OnPaint(self, evt):
          if self.bmp:
              dc = wx.PaintDC(self.msgShowArea)
              dc.DrawBitmap(self.bmp, 20, 20, True)
  
  
  #----------------------------------------------------------------------------
  
  if __name__ == '__main__':
      app = wx.App(False)
      frame = MyFrame(None, "EasySync")
      app.MainLoop()
  </code></pre>