-
AceNinjaFire
DANG NICE!! Thanks I appreciate it. Ima go check it out
-
AceNinjaFire
Thanks for pointing me in the right direction. From what I’ve read it’s not possible unless omz took steps to piece them together in Pythonista. I appreciate the help!
-
AceNinjaFire
I’ve just about learned everything in the ui module that comes Pythonista. Although the only thing giving me trouble is ui.TableView, otherwise I’ve just about got it down.
The only reason I want to install one of these modules is because it’s much easier to work with scripts/programs on Pythonista than my laptop.
-
AceNinjaFire
I hope everyone is having a good day!
Hey all, I’ve been using Pythonista for a good while and wanted to know if it would be possible to install one of the modules above to Pythonista so I could practice using them? I remember omz mentioning that Pythonista is not a pure-python application. So I imagine something like these modules wouldn’t likely work in Pythonista. I appreciate any responses on the topic!!
-
AceNinjaFire
Ah thank you lol, I got as far as image_data = BytesIO(requests.get().content)
I never thought about using the Context Manager and putting the “.getvalue()” on the image_data. Lol I appreciate the help!
-
AceNinjaFire
Shiiiiit sorry lol I had not realized that anyone had replied. I knew I could do that from the beginning, I was just trying to go from jpeg/image object straight to ui.Image/Ui.ImageView.
I ended up just making a list from each requests.get().content and using that.
I was just trying to swim up river to see if I could do it I guess lol. -
AceNinjaFire
Nvm I think I figured it out, it has to be a bytes-like object. I just have to figure out how to get image.tobytes() to byte-like and not bytes
-
AceNinjaFire
Been trying to get an idea of mine working. I made a script to download galleries, and I’m trying to set the image view after the image has been downloaded.
But for some reason what I did below doesn’t do anything. Could someone tell me what I’m doing wrong?import ui,requests,Image from io import BytesIO Image_url =“some image url” image_data = BytesIO(requests.get(image_url).content) image = Image.open(image_data) w,h = ui.get_screen_size() testview = ui.View() testview.frame = (0,0,w,h) Img_view = ui.ImageView() Img_view.frame() = testview.frame() testview.add_subview(img_view) testview.present() Img_view.image= ui.Image.from_data(image.tobytes())
-
-
AceNinjaFire
I’ve gotten that far, but I was trying to shorten what I type even more. As I’ve read in some posts that you can format the init.py file in a way that will completely dump all of the functions of the files into init file. So I wouldn’t have to reference module1 at all and just type from mypackage import some_function.
-
AceNinjaFire
Hey everyone, I just found out about how to make packages in python and thought it was an absolutely good idea especially with how it can get repetitive typing the same code over and over again.
My setup
base folder
main.py/mypackage
init.py
module1.pyBut as I’ve tried to do so in Pythonista it just keeps giving me errors.
I’ve tried it this way#__init__.py from module1 import some_function
And this way
#__init__.py from .module1 import some_function
Excluding and including the period.
As I’ve seen it in many guides of making packages. But I keep getting this message when I try calling it from my main.py .ModuleNotFoundError: No module named 'main.module1'; 'main' is not a package
I’m sure I’ve completely overlooked the answer somewhere. I’ve been on stackoverflow and seen quite a few posts about explicit relative imports but I can’t make heads or tails of what to do to make a package.
I’d appreciate any help I can get!
-
AceNinjaFire
Dang thanks man, and that’s definitely something I’ll look into. I’ve been looking for a reason to delve into js again after my initial dive into it. What types of projects have you done bridging the two together?
-
AceNinjaFire
Yea that was my original question, but after looking at @cvp ‘s code I realized you had to structure it in a way to get the value normally (document.location.href) without assigning it to a value like (var url = document.location.href).
cvp answered my original question and answered a question I didn’t even have yet. So yea I was happy with it lol.
-
AceNinjaFire
You’re good lol. Complex or not I appreciate it, since the only way I’ll learn is by example or experimentation. I’m using the example you gave to reference to the objc_util module and what it does. I’m still far from understanding it but it’ll definitely be useful if it works the way I think it does.
EDIT: also you introduced a few ui functions I was unaware of which helped me solve another problem I was having lol. I really need to read the docs more completely going forward.
-
AceNinjaFire
Damn!!!
Thank you!! I have no experience with using the objc_util module at all😅, but I’ll have to look at it now. You helped me solve a problem I was having lol, I appreciate it.
Would you know of a good tutorial for using the module? I’ve looked at the doc before but it’s not an easy read.
-
AceNinjaFire
Hey everyone I made a ui application that opens uses a custom view with a webview with a few other textviews ,buttons, and etc to run js on the webpage presented on the webview and display the results on a textview.
In the docs it doesn’t explain how the js should be structured in order to get the results from the snippets used. So I was wondering if anyone can tell me how to correctly use the method?
I’m gonna include code from my application (excluding animation functions I use for each separate view) and I’ll wait for responses. I appreciate any help I can get, and thanks in advance!!!
class browser(ui.View): def did_load(self): self.html = 0 html_view = ui.load_view('html_view') self.add_subview(html_view) self['html_view'].x = 400 def go(self): v = self.superview url_bar = v['url input'] webview = v['webview1'] webview.load_url('http://'+url_bar.text) # this is located on a custom view that #is a subview to the view containing the webview class html_view(ui.View): #this is a button located on the subview #that initiates the "webview.evaluate_javascript()" method def runjs(self): #this is the subview v = self.superview #this is the main view bv = v.superview #the textview that the script is entered in script = v['js field'].text #the variable that contains the result of #the method result = bv['webview1'].evaluate_javascript(script) #Printing result for testing purposes print(result) #setting a textview to the result'' v['result'].text = result
-
AceNinjaFire
Btw thank you for pythonista, it was the one thing that actually got me started with programming and made me realize how much I love it. It’s been my hobby for the last 5 months overtaking my love for video games😂
-
AceNinjaFire
Thank you, it seems that worked, I had forgotten to do that😅.