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)
-
@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
-
Should I have taken out the textures from exclude_dirs? That's where my one file is located.
-
Yes, if that's where your file is, remove
'Textures'
fromexclude_dirs
.