title: How to change an image using ids in kivy
body: <p>How do I change the profile icon?
  I want to add a functionality to the app whereby when the profile icon is pressed, a pop up window appears and then you can select other icons of your choice to become the new profile icon. Whenever I select other icons, the get:
  [ERROR ] [Image ] Error reading file &lt;<strong>main</strong>.ImageButton object at 0x000001610E195E48&gt;</p>
  <p>Here is the code:</p>
  <p>main.py</p>
  <pre><code>from kivy.app import App
  from kivy.uix.screenmanager import Screen
  from kivy.uix.button import ButtonBehavior
  from kivy.uix.image import Image
  from kivy.properties import StringProperty, ObjectProperty,NumericProperty
  from kivy.uix.popup import Popup
  from kivy.uix.floatlayout import FloatLayout
  
  
  class MainScreen(Screen, FloatLayout):
      mantra_text = ObjectProperty(None)
  
      def printMantra(self):
          print(self.ids.mantra_text.text)
  
      def icon_popup(self):
          popup = Popup(title=&quot;Profile Icon&quot;, content=Popup_Content(), size_hint=(None, None), size=(300, 200))
          popup.open()
  
  
  class Popup_Content(FloatLayout):
      pass
  
  
  class ImageButton(ButtonBehavior, Image):
      pass
  
  
  class MainApp(App):
      def build(self):
          return MainScreen()
  
      def set_profile_icon(self, image):
          self.root.ids.profile_icon.source = str(image)
          print(image)
          #print(self.root.ids.profile_icon)
  
  
  MainApp().run()
  
  </code></pre>
  <p>main.kv</p>
  <pre><code>#:import utils kivy.utils
  &lt;MainScreen&gt;
      Popup_Content:
          id: popup_content
  
      FloatLayout:
          canvas:
              Color:
                  rgb: utils.get_color_from_hex(&quot;#ffbb99&quot;)
              Rectangle:
                  pos: self.pos
                  size: self.size
  
          GridLayout:
              cols: 2
              pos_hint: {&quot;x&quot;:0.6, &quot;top&quot;:1}
              size_hint: 0.4,0.2
              spacing_horizontal: [0.9*root.width]
              Label:
                  text: &quot;Name&quot;
              ImageButton:
                  id: profile_icon
                  source: &quot;profile_icon&quot;
                  on_release: root.icon_popup()
  
          Label:
              text: mantra_text.text
              pos_hint: {&quot;x&quot;:0, &quot;top&quot;:0.8}
              size_hint: 1, 0.2
              text_size: self.size
              halign: &quot;center&quot;
              font_size: 25
          TextInput:
              id: mantra_text
              pos_hint: {&quot;x&quot;: 0.15, &quot;top&quot;:0.6}
              size_hint: 0.7, 0.1
              #text_size: self.size
  
          Label:
              text: &quot;Time&quot;
              pos_hint: {&quot;x&quot;:0.3, &quot;top&quot;:0.6}
              size_hint: 0.4, 0.2
              text_size: self.size
              halign: &quot;left&quot;
              font_size: 30
  
          Button:
              text: &quot;Time&quot;
              pos_hint: {&quot;x&quot;:0.3, &quot;top&quot;:0.5}
              size_hint: 0.4, 0.2
              on_release: root.printMantra()
  
  &lt;Popup_Content&gt;
  
      #profile_icon: profile_icon
      FloatLayout:
          GridLayout:
              cols: 5
              pos_hint: {&quot;x&quot;:0.95, &quot;y&quot;:1.6}
  
              ImageButton:
                  id: man_01
                  source: &quot;icons/male_icon_01.png&quot;
                  on_release: app.set_profile_icon(man_01)
              ImageButton:
                  id: man_02
                  source: &quot;icons/male_icon_02.png&quot;
                  on_release: app.set_profile_icon(man_02)
              ImageButton:
                  source: &quot;icons/male_icon_01.png&quot;
                  on_release: app.set_profile_icon()
              ImageButton:
                  source: &quot;icons/male_icon_01.png&quot;
                  on_release: app.set_profile_icon() #these are empty because they are stand in for the other icons
              ImageButton:
                  source: &quot;icons/male_icon_01.png&quot;
                  on_release: app.set_profile_icon()
              ImageButton:
                  id: female_01
                  source: &quot;icons/female_icon_01.png&quot;
                  on_release: app.set_profile_icon(female_01)
  
  
  </code></pre>