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?
-
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)
-
@RocketBlaster05 try
image = ui.Image.named('path').with_rendering_mode(ui.RENDERING_MODE_ORIGINAL)
-
@cvp said:
ui.Image.named('path').with_rendering_mode(ui.RENDERING_MODE_ORIGINAL)
Worked like a charm lol
-
This post is deleted! -
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')