@cvp Can you tell me how you opened the menu for the Pythonista buttons? Does it have something to do with the hammer and wrench icon on the top right? If yes, I don’t have that icon. It just shows me the 3 other button next to it.
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.
Latest posts made by Trüff
-
RE: How to change the button image?
-
RE: ui-module: Change view‘s size
Aaaahhhh. Okay. I understand. So then I‘d give the presented view a transparent background and remove its title bar.
Thank you. That really helped me. -
ui-module: Change view‘s size
Hey everyone,
I am currently having some problems with the ui-module in Pythonista.The following code is a representation of the situation I am dealing with in my program:
import ui def sw1_changed(sender): if sender.value == True: # switch has been turned on v.height = 400 else: # switch has been turned off v.height = 200 v = ui.View() v.name = "View" v.width = 200 v.height = 200 v.bg_color = 1.0 v.border_width = 3 v.border_color = (1.0, 0.0, 0.0) sw1 = ui.Switch() sw1.name = "Switch" sw1.action = sw1_changed sw1.center = (v.width/2, v.height/2) v.add_subview(sw1) v.present('sheet')
Briefly explained:
I created aui.View
object that contains aui.Switch
object as a subview. When the switch is pressed the size of the its parent view is supposed to change. If the switch is turned on, it‘s height should increase from 400 to 200 and when it‘s turned off, it should turn back to it‘s original height of 200.My problem:
(Running the code yourself could be helpful to understand what I mean.)
The resizing behaviour of the View does not work out as I want it to. The program does change the View‘s height in some way which is shown by the red border surrounding View. The bottom of the border disappears when the switch is turned on which (I think) means that it expands it‘s space where subviews could be placed onto. However the added space is not visible on the screen.My question is: How can I get the View to change it‘s height so that it covers a bigger part on the screen?
I‘ve already tried out some stuff with the
View.bounds
,View.frame
andView.center
as well as thetype
argument of theView.present
method but none of it fixed my problem.I would be really happy if someone could help me out with my problem. Thanks for every answer in advance. 😁
-
RE: canvas.draw_image() function does not work
@cvp This also doesn‘t work with transparent pictures for me. However, I tried out your previous idea of saving the image into the clipboard and drawing the clipboard but I used the class
Image
from thePIL
module instead of the one from Pythonista‘sui
module and that worked. Thank you! -
RE: canvas.draw_image() function does not work
@ccc Ok thank you. I‘m going to read the documentary on these modules first.
-
RE: canvas.draw_image() function does not work
@cvp Hm… Well, it does draw the image onto the canvas. But the image I want to draw is transparent and apparently it just sets a white background for images that are saved into the clipboard. So when I draw the clipboard with the image inside of it, the picture is not transparent anymore.
-
canvas.draw_image() function does not work
Hey there,
I have a problem with the following code:import canvas as cv # creates canvas w = 200 h = 500 cv.set_size(w, h) # size of the image img_w = 190 img_h = 490 cv.begin_updates() # draws a white rectangle as the canvas background cv.set_fill_color(1, 1, 1) cv.fill_rect(0, 0, w, h) # draws an image onto the canvas cv.draw_image("image.png", 0, 0, img_w, img_h) cv.end_updates()
Whenever is use the canvas.draw_image() function, my Pythonista crashes. This seems to be not because of the image that I‘m trying to draw, since I‘ve tried out other images and even an empty string as the 1. argument too. It didn‘t even give me an error, it just closed the program.
Am I just not using the function correctly or is there something else I need to add?
I would be really happy if someone could help me out.