title: Understanding wx.EVT_UPDATE_UI
body: <p>I'm trying to follow the below piece of code from a book, but I am having trouble understanding it. I was hoping someone could help clarify the following issues:</p>
  
  <ul>
  <li>When I don't anything in the textctrl, the has_sel is set to false but how does the IF stmt gets executed?</li>
  <li>What is event_id? Is it the event_id for the whole Menubar? </li>
  <li>Why would the event_id change when the items in the txt_ctrl are changed?  </li>
  <li>When event.Enable(has_sel) is true, how are both the buttons enabled/disabled?</li>
  </ul>
  
  <p>Here is the code:</p>
  
  <pre><code>import wx
  
  ID_CHECK_ITEM = wx.NewId()
  
  class TextFrame(wx.Frame):
      def __init__(self, parent, *args, **kwargs):
          super(TextFrame, self).__init__(parent,
                                          *args,
                                          **kwargs)
  
          # Attributes
          self.panel = wx.Panel(self)
          self.txtctrl = wx.TextCtrl(self.panel,
                                     value="Hello World",
                                     style=wx.TE_MULTILINE)
  
          # Layout
          sizer = wx.BoxSizer(wx.HORIZONTAL)
          sizer.Add(self.txtctrl, 1, wx.EXPAND)
          self.panel.SetSizer(sizer)
          self.CreateStatusBar() # For output display
  
          # Menu
          menub = wx.MenuBar()
          editm = wx.Menu()
          editm.Append(wx.ID_COPY, "Copy\tCtrl+C")
          editm.Append(wx.ID_CUT, "Cut\tCtrl+X")
          editm.Append(ID_CHECK_ITEM, "Selection Made?",
                       kind=wx.ITEM_CHECK)
          menub.Append(editm, "Edit")
          self.SetMenuBar(menub)
  
          # Event Handlers
          self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateEditMenu)
  
      def OnUpdateEditMenu(self, event):
          event_id = event.GetId()
          sel = self.txtctrl.GetSelection()
          print("Start")
          print('Sel',sel)
          has_sel = sel[0] != sel[1]
          print('has_sel=',has_sel)
          print('sel[0]=',sel[0])
          print('sel[1]=',sel[1])
          print('event_id=',event_id)
          print('wx.ID_COPY',wx.ID_COPY)
          print('wx.ID_CUT=',wx.ID_CUT)
          print('ID_CHECK_ITEM=',ID_CHECK_ITEM)
          if event_id in (wx.ID_COPY, wx.ID_CUT):
              print("Select option set to true-1")
              event.Enable(has_sel)
          elif event_id == ID_CHECK_ITEM:
              print("Select option set to true-2")
              event.Check(has_sel)
          else:
              event.Skip()
  </code></pre>