title: set a function as label in a menuitem in python
body: <p>I am trying to set a function as label in a <code>MenuItem</code> in Python(gtk). I want to change the label of <code>MenuItem</code> every time the function is called.</p>
  
  <p>As per the documentation - <a href="https://developer.gnome.org/pygtk/stable/class-gtkmenuitem.html#constructor-gtkmenuitem" rel="nofollow noreferrer">https://developer.gnome.org/pygtk/stable/class-gtkmenuitem.html#constructor-gtkmenuitem</a>, label of a <code>MenuItem</code> must be string. How can I accomplish this?</p>
  
  <pre><code>   item5 = Gtk.MenuItem('Force Quit')
     item5.connect("activate", self.run_command4)
     item6 = Gtk.MenuItem('Sleep')
  </code></pre>
  
  <p>What I want is :</p>
  
  <pre><code>   a = os.path.basename(active_window_name)
     item5 = Gtk.MenuItem('Force Quit' + a)
  </code></pre>
  
  <p>"active_window_name" is the return of a function that is called every time the menu is created.As mentioned above, <code>('Force Quit' + a)</code> is not a valid label for <code>MenuItem</code>.</p>
  
  <p>EDIT</p>
  
  <p><code>print(type(a)</code> gives <code>&lt;type 'str'&gt;</code>.</p>
  
  <p>Also, the  code is  Ubuntu Budgie applet.</p>
  
  <p>In PyCharm I have <code>code 0</code> when I run the applet but the applet does not load in the panel when I add it.</p>
  
  <p>TRACEBACK</p>
  
  <pre><code>/usr/bin/python3.7 "/home/christoforos/Documents/Apple Menu New/applemenunew.py"
  
  (applemenunew.py:5061): Gtk-WARNING **: 19:21:17.967: Theme parsing error: gtk.css:4:11: 'height' is not a valid property name
  
  (applemenunew.py:5061): dbind-WARNING **: 19:21:18.114: Couldn't register with accessibility bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
  
  Process finished with exit code 0
  </code></pre>
  
  <p>Any help will be appreciated. </p>