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.
Untitled
-
I right-clicked the "Textures" folder in XCode, then clicked "Open in finder...", then copied the files I wanted into it.
-
Do any of these help?
import os # replacing / with \\ print(os.path.join(os.path.dirname(__file__), 'Script').replace('/', '\\')) print(os.path.realpath(os.path.abspath(os.path.join(os.path.dirname(__file__), 'Script'))).replace('/', '\\')) # or import sys print(os.path.join(os.path.dirname(sys.argv[0]), 'Script').replace('/', '\\'))
-
@ccc I get EOL while scanning string literal
-
Sorry... I fixed the script above. Please try again with this new formulation (double backslashes).
-
-
Here is a verbose version of
ui.load_view()
that might help.It takes the real, absolute path of this script and adds 'ui' to it.<br>
It prints out what that new filepath is and if that file exists or not.<br>
It tries to ui.load_view() it and if it fails it repeats the process with all / converted to \.def ui_load_view_verbose(pyui_filepath = None): pyui_filepath = pyui_filepath or os.path.realpath(os.path.abspath(__file__)) + 'ui' fmt = 'Attempting to load_view({}) -- File {}found.' print(fmt.format(pyui_filepath, '' if os.path.isfile(pyui_filepath) else 'not ')) try: return ui.load_view(pyui_filepath) except ValueError as e: print(e) return None if '\\' in pyui_filepath else ui_load_view_verbose(pyui_filepath.replace('/', '\\')) # replace your current call to ui.load_view() with the following: v = ui_load_view_verbose() # with no parameters!! if not v: print('Bummer! ui_load_view_verbose() did not work.') sys.exit()
If this fails, please send us the printed output.
-
One problem with using
__file__
is ifos.chdir
has been called.__file__
only has the relative path from the time you import it. If you chdir after import, you can't find it again.
I struggled with this problem when making a plugin for my javascript editor script... The calling script had imported the module, then changed directory. In retrospect, I probably could have done something in init, but here's what I ended up with. So possibly using inspect to locate things might be another route.origPath= os.path.dirname(inspect.stack()[-1][1]) fullScriptPath= os.path.join(origPath,os.path.splitext(__file__)[0])
-
Does
sys.argv[0]
suffer from the same problem as__file__
? -
-
Try this.. Which will display all files ending with pyui...
def findpyui(): import os startingpath = os.path.expanduser('~') # other things to try.... #startingpath = '.' #starting path = '..' # i.e in pythonista, start above documents, to see into library,etc print startingpath for root, dirs, files in os.walk(startingpath): for name in files: if name.endswith('pyui'): print os.path.join(os.path.abspath(root),name) findpyui()
-
The solution above worked. Thanks.
-
What was the path of the .pyiu file??