omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Colour/tint built-in Images

    Pythonista
    color tintcolor ui module ui.image imagecontext
    3
    4
    2959
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • m_doyle04
      m_doyle04 last edited by

      Hi All,

      I'm 99.99% sure I've read something about changing the colour/tint of Pythonista's in-built images somewhere in this forum but I've spent a long time searching and can't find it. Hopefully this post will appear more easily in searches in the future with some appropriate tags for the benefit of others.

      I thought changing the colour of the in-built images would be as simple as accessing the "tint" or "tin_color" attributes of the Image object but it isn't. It's actually a real pain in the proverbial. For those interested you can do so by using the ImageContext as follows:

      import ui
      
      with ui.ImageContext(100, 100) as ctx:
      	ui.set_color('red')
      	img = ui.Image('iob:arrow_down_a_256').with_rendering_mode(ui.RENDERING_MODE_TEMPLATE).draw(0,0,100,100)
      	img = ctx.get_image()
      	img.show()
      
      mikael 1 Reply Last reply Reply Quote 0
      • mikael
        mikael @m_doyle04 last edited by

        @m_doyle04, changing the tint works when the image is on a button, but not stand-alone:

        from ui import *
        
        v = Button(image=Image('iob:arrow_down_a_256'))
        v.background_color = 'white'
        v.tint_color = 'red'
        v.present('sheet')
        
        1 Reply Last reply Reply Quote 0
        • enceladus
          enceladus last edited by

          previous discussion here https://forum.omz-software.com/topic/3133/drawing-a-image-with-a-tint_color-in-an-imagecontext

          m_doyle04 1 Reply Last reply Reply Quote 0
          • m_doyle04
            m_doyle04 @enceladus last edited by

            @enceladus thanks, I knew I'd seen that somewhere before!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors