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.


    Custom Button Image Returns White Canvas?

    Pythonista
    3
    5
    1238
    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.
    • RocketBlaster05
      RocketBlaster05 last edited by RocketBlaster05

      Hello! I have a button on my menu that I wish to change the background image of. I have tried several pictures, including one that already works and is presented elsewhere on screen. All pictures return a blank white canvas when presented on screen. Is it possible to make custom button images? Here is the code:

      class Menu(Scene):
      	def __init__(self):
      		self.background_color = '#4fb357'
      		self.mm = ui.load_view('MainMenu')
      		self.mm['imageview1'].image = ui.Image('companylogo.PNG') #works, presents image
      		self.mm['button5'].image = ui.Image('companylogo.PNG')#doesnt work, presents white square
      		self.changetotals() # ignore this 
      		self.mm.present('fullscreen', hide_title_bar=True)
      
      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @RocketBlaster05 last edited by cvp

        @RocketBlaster05 try

         image = ui.Image.named('path').with_rendering_mode(ui.RENDERING_MODE_ORIGINAL)
        
        RocketBlaster05 1 Reply Last reply Reply Quote 0
        • RocketBlaster05
          RocketBlaster05 @cvp last edited by

          @cvp said:

          ui.Image.named('path').with_rendering_mode(ui.RENDERING_MODE_ORIGINAL)

          Worked like a charm lol

          1 Reply Last reply Reply Quote 1
          • lissakathi
            lissakathi last edited by lissakathi

            This post is deleted!
            cvp 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @lissakathi last edited by cvp

              if you want to display an image from an url, try this little script

              import ui
              import requests
              
              v = ui.ImageView()
              url = 'https://upload.wikimedia.org/wikipedia/commons/4/4b/What_Is_URL.jpg'
              v.image = ui.Image.from_data(requests.get(url).content)
              wi,hi = v.image.size
              w = 400
              h = w * hi/wi
              v.frame = (0,0,w,h)
              v.present('sheet')
              
              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB Forums | Contributors