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.
Xcode + UI File Loading (POSSIBLE BUG IN PYTHONISTA)
-
Still does not work with the updated paths.
-
I really need some help with this. I tried using all the file paths from the findpyui script and it still gives me the UI File Could Not Be Loaded.
-
@techteej, I can't really try it out right now (Mac updating), but you could make something like this:
... ui_file = """ {...} """ # I am not very good with tempfile, but I think that's how it works import tempfile with tempfile.NamedTemporaryFile() as fp: fp.write(ui_file) view = ui.load_view(fp.name) ...
-
This still brings up the error.
-
@techteej, well, then I have no ideas... Maybe you can try to write a small script that will convert
.pyui
to Python code? Shouldn't be that hard I think. -
@techteej, or maybe try this one:
... ui_file = """ {...} """ import os full_path = os.path.join(os.getcwd(), "uifile.pyui") with open(full_path, "w") as fp: fp.write(ui_file) view = ui.load_view(full_path) ...
-
This gives me the error invalid UI File.
-
Have you tried going back to basics and stripping everything out of your project, and having the simplest of ui, like a single button? Can you find a minimal example of a pyui and py file that so fails, yet works in pythonista?
Seems like that is the route you need to get help on this. If you can post a repeatable example, then omz or others may be able to help. You said this worked previously, so you need to figure out what changed, it is either your code, pyui file, or something in your particular project setup....
-
@techteej, okay, I am outta ideas... Ask omz, maybe it is some kind of bug in Pythonista or ui module?
-
@JonB Yep. :\
@ShadowSlayer Already tried this, only get no response. :(
Definitely quite frustrating!
-
Tech, what I mean is that you need to post reproducible code, not vague descriptions.
See if others can reproduce it, or not. Given that you, and others, have been able to make Xcode projects that load ui's, it sounds more like a problem with your configuration. -
@JonB See Cacti Killer on GitHub. This is what I'm having problems with.
-
Any chance you're using the iOS 8 beta? The file system structure for apps and their data containers has changed there...
-
Based on previous posts, I believe that he is running iOS 8 beta... Are there any workarounds for iOS 8 users?
-
Okay, this isn't pretty, but it should work on both iOS 7 and 8:
import scene import os def find_bundled_files(file_extension='.pyui', exclude_dirs=('pylib', 'pylib_ext', 'Documentation', 'Textures')): found = [] # Use a built-in image's path as a starting point (use a different one if you've removed this from your project): dummy_img_path = scene.get_image_path('Test_Lenna') bundle_path = os.path.split(os.path.split(dummy_img_path)[0])[0] for path, dirs, files in os.walk(bundle_path): # Remove excluded directory names from the search (not required, but makes it faster): for excluded in exclude_dirs: try: dirs.remove(excluded) except: pass for filename in files: ext = os.path.splitext(filename)[1] if ext == file_extension: full_path = os.path.join(path, filename) found.append(full_path) return found ui_files = find_bundled_files() print ui_files
-
@omz Thanks. I am using the iOS 8 beta, I'll try from a fresh download of the Project Template w/ this.
-
@omz How would I load this?
-
You drag your .pyui file into the Xcode project, build and run... In your script, you can then find the path to your pyui file with the function I posted above – it returns a list of pyui file paths, if you only have one, use
ui.load_view(find_bundled_files()[0])
. -
ui.load_view(find_bundled_files()[0])
was what I needed. Trying now. Runs in iOS 7 Simulator in Xcode. -
I get the following error on iOS 8.
Error (Line 487): List index out of range