title: how to use global variable
body: <p>I'm very new to python and I would like some help with declaring a global widget label.</p>
  <pre><code>def leftClick(event):
      global label1
  
      #the event is called when the 'leftClick' function is used
      #thus, displaying the color of the font
  
      label1=Label(text=event.widget.cget(&quot;fg&quot;),bg=event.widget.cget(&quot;fg&quot;))
      label1.grid(row=0, column=0,sticky=S)
  
  def rightClick(event):
      global label1
      #same goes for 'rightClick' def function but it displays the background of the buttons
  
      label1=Label(text=event.widget.cget(&quot;bg&quot;),bg=event.widget.cget(&quot;bg&quot;))
      label1.grid(row=0, column=0,sticky=S)
  
      #since its outside the class, we refer to widgets inside the class with event.widget
  </code></pre>
  <p>'label1' is not defined in the global scope</p>