I may have forgot but I checked through the forum posts and I don't see an answer to the following: What is the suggested way to view a .pyui file (without changing the default ui editor)as plain text rather than use the ui editor?
Forum Archive
How to easily view .pyui file as a text file
Just rename the file to "something.json" or "something.txt".
@omz, thanks, I thought of that workaround as well but wondered if there was anything a little more elegant such as "Open with" to choose the editor to use rather than try to trick it that the .pyui file is either a text file outright or one to be treated as a text file.
@ltddev There isn't really another way, sorry.
Very quick and dirty, a little script you have to define in the share sheet, and thus you can "edit and open with" a .pyui file (or, sorry if I didn't understand your request):
import appex,ui
f = appex.get_file_path()
fil = open(f,'r',encoding='utf-8')
t = ''
for rec in fil:
t = t + rec
fil.close()
cover_image = ui.TextView()
cover_image.text = t
cover_image.present()
Nice one @cvp
import appex
import ui
filename = appex.get_file_path()
assert filename, 'This appex script must be run from a share sheet.'
with open(filename) as in_file:
text = in_file.read()
ui.TextView(name=filename.split('/')[-1], text=text).present()
@cvp Neat idea! Didn't think of that possibility (though I think renaming might be faster).
@ccc Instead of filename.split('/')[-1] you can use os.path.basename(filename).
@ccc I initially splitted into records because my 1st intent was to use a TableView. As I said, it was a really dirty script 😏