@technoway, I use a simple trick @ccc mentioned a long time ago. In 'Settings->Keyboards->Text Replacement' use 3 x comas to output 3 x ticks `
Not often you type 3 comas in a normal workflow.
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.
Best posts made by Phuket2
-
RE: Disable stop button (X) in Scene
-
RE: Pythonista 3 suggestions
A setting in the ui.View.present() that allows for the behaviour that if a touch is outside the view, it's the same as hitting the X or close button as many iOS apps do. Maybe only for custom ui.Views, as you can catch will_close
-
RE: Pythonista 2 Release
@omz , congratulations. A big milestone. I know you are a modest guy, but I hope you can appreciate other people's admiration for Pythonista. You should be very proud of yourself. I am one of your groupies 😀👍
-
Latest py3 Beta - Love it
@omz, the latest Pythonista beta 3, is great. The convert tabs , the snippets , the color entry. They can seem like small things. I am sure the functional code is easy, but the interfaces not so much.
But thanks again, I love it. 👍👍👍👍 -
[suggestion] search in Pythonista file navigation view (recursive)
@omz Would be great if there was a switch/activator to make the search in the file nav recursive. Maybe it's there already there. But if it is, please let me know. Would be a great feature
-
[share] Circle view/mask view (food for thought)
In a previous post I asked for help to get a circlular view working. @omz answered it for me. But look I am not a graphics guy, well I am not a really anything guy 😱
But with the simple solution he provided, I can see how it could be extended to do some very nice things. I was thinking of trying to do more with this. But I thought I really should leave it to the experts. I know others here can do a lot better job than me.
My idea is, any number of these mask views could be written using the techniques that @omz shows. Put into custom view classes that have a standard interface , then they could be used like plugins. If the containing class is defined very well, maybe with ABC's then as people write new ones using the base case they could for example be added to a list of view masks in Pythonista Tools.
Just my 2 cents worth. But personally, I think this is how we can leverage people's hard work here.
Ok, the sample code I have listed wants to access your photos. Thought it would give a better example being able to choose your own pics
import ui import photos class ImageMaskCircle(ui.View): def layout(self): self.frame = self.superview.bounds def draw(self): # https://forum.omz-software.com/topic/2902/circle-view-for-ui # @omz solution oval = ui.Path.oval(*self.bounds) rect = ui.Path.rect(*self.bounds) oval.append_path(rect) oval.eo_fill_rule = True oval.add_clip() ui.set_color('white') rect.fill() class TestClass(ui.View): def __init__(self, image_mask = None, *args, **kwargs): ui.View.__init__(self, *args, **kwargs) self.iv = ui.ImageView() self.iv.image = ui.Image.from_data(photos.pick_image(raw_data=True)) self.add_subview(self.iv) self.add_subview(image_mask) def layout(self): self.iv.frame = self.bounds if __name__ == '__main__': f = (0,0, 80, 80) im = ImageMaskCircle() tc = TestClass(im, frame = f) tc.present('sheet')
-
RE: External file access
@Chilibird , have a look at this forum post. I think it answers your question well.
-
RE: Pythonista is now featured on Python.org
In total agreement with everyone here. I love this product. As a retiree that had not programmed for years and years Pythonista was so compelling it got me back into programming as a hobby. The app and Ole deserve all the success in the world. Whatever success means for him.
I think you also should get special credit for putting up with us and our billion requests :) -
[Share]CSS Color Selector/Picker Wrench utility
A very simple utility to select/filter from the 148 CSS color names. Then you can copy the CSS name to the clipboard for pasting into your code. Done as a popover, as it makes sense for what it is. I like using CSS color names. Just makes things easy to read for me rather than seeing a bunch of rgb values. Also in combination with ui.parse_color you can an alpha to achieve a RGBA.
Anyway, here is a gist, I have done as a gist because I want to do more to it . I say in the comments.
But I just wanted to do something. I never finish things because I want it better and better. In this case I have just done what I could do comfortably. I mean the design. I know it's not great, but it could also be worse.Again, it's super basic, but still useful if you use CSS colors.
-
RE: Stash Ssh bug report
@Webmaster4o , I know your heart was in the right place. It just sounded hash.
-
RE: Stash Ssh bug report
@Webmaster4o , take it easy 😱 StaSh has come become synonymous with Pythonista, in my view. I know you mean well, but the guys always answer the questions here, and it's good every sees them. Just saying for this subject in-particular , it's not so cut and dried. 🕊☮☯
-
[Tip] adding screenshots to your code
Maybe not a tip, but more like the obvious. But it's pretty easy to add screenshots to your code via a link. Yeah, it's obvious, but I don't remember seeing anyone doing it except in the forum.
The below is just supposed to be dead simple. Just prints a link to the console, in this case a Dropbox link. If you click the link it the console it's automatically opened up in a panel.
But it could be helpful for people to understand your code. Just an idea.
_link = 'https://www.dropbox.com/s/vm96a9yngt10zx3/File%2010-08-2016%2C%2015%2034%2035.jpeg?dl=0' print(_link)
-
[Share] A unique set of attrs from the combination of all ui Elements
Not ground breaking. But can be nice to see/have a list of every unique attr used across all the ui elements/controls. pprint is used to give a nice print out(sorted). Also, nice to see how easy it is when you get sets to do the heavy work.
Anyway, I wanted this for a lib I am doing, so I thought I would share the portion.
# Phuket2 , Pythonista Forums (Python profiency, not much) # works for python 2 or 3 ''' get_all_attrs_set - the main function of interest iterates over a list of all the ui Elements, and retuns a set of all the unique attrs for all the ui Elements combined. i am sure this could be tighten up more. But imthink the readabilty is ok now. if not for ui.NavigationView, i would have tried to use a list comp rather than the for. I could have tried to special case it, but i think personally this is more clear given what it is. ''' import ui, pprint _ui_controls = \ [ ui.View, ui.Button, ui.ButtonItem, ui.ImageView, ui.Label, ui.NavigationView, ui.ScrollView, ui.SegmentedControl, ui.Slider, ui.Switch, ui.TableView, ui.TextField, ui.TextView, ui.WebView, ui.DatePicker, ui.ActivityIndicator, ui.TableViewCell ] def get_full_dict(obj): # get all the dict attrs for obj, no filter return {k: getattr(obj, k) for k in dir(obj)} def get_all_attrs_set(): # return a set of unique attrs across all ui_elements # sets doing all the hard work with the union operator '|' s = set() for ctl in _ui_controls: try: s = s | set(get_full_dict(ctl())) except: # handle differently for ui.NavigationView, it needs a # ui.View as a param if ctl is ui.NavigationView: s = s | set(get_full_dict(ctl(ui.View()))) else: # print out a control type if an error produced we # do not handle print(ctl) return s if __name__ == '__main__': # pprint prints out a nice easy to view, sorted list of the attrs pp = pprint.PrettyPrinter(indent=5, width=80) attr_set = get_all_attrs_set() pp.pprint(attr_set) print('Number of unique attrs - {}'.format(len(attr_set)))
-
Creation of ui Elements - defaults are strange
@omz, I didn't write this as a bug because maybe you added something I am not aware about.
But if you create a ui.Button without params you get width and height = 0.
If you create a ui.Table without params, you get a width and height of 100.Maybe you added something to set this globally.
But if not, it would seem reasonable to create the objects as you do in the designer. Eg. Ui.Button() w = 80, h = 32. ui.TableView() w = 200, h = 200
From memory in the past you got values if not like this but close to this.
I get the logic, if you don't specify a frame, then there is none. But it is as practical as if you did that in the Designer
As I say, maybe there is a bigger picture going on here.
-
[Work in Progress] Theme Viewer for ui Elements
Ok a quite Friday night on the Forum. So I will share my work in progress. I want to see the flaws in the editor.theme thingy.
Not finished yet. I think it's still interesting though.Here is the gist
Is just one file.But if you are interested in ui and themes, it's worth a quick look.
-
RE: ui.TableViewCell.detail_text_label not working
@Webmaster4o , yeah you are right. @cook is working on something now that will make searching a lot easier in the forum
-
RE: [share code] SliderWithLabel class for ui.Slider() featuring editable label
@cook ,I understand. You of course should leave it as you feels it works. And that's why we edit: ask the more experienced guys in the first place. I think my own limitations/ability frustrates my at times. I do get backed it corners quite often and it frustrates the hell out of me. I can code my way out of the corner, but it seems so ugly to me and it's clear to me my design is just wrong.
When I was younger I had very little practice using OOP. And whilst I really love it in Python, I don't have the object design skills to pull it off. I think I can do simple things. It's just when the project starts to grow, I quickly see my design is does not support what I want to achieve in a elegant way. I this this is another problem for me, if it's not elegant I tend to sort of freeze up. Rather than just code though it and get something working.
Of course impatience is another factor. Trying to go to fast, not thinking things out.
I am thinking the smartest thing for me to do it to give up programming, lol no only joking 😬 I enjoy it to much, but I should take a huge step back and get my head MCV paradigm.But to all, I make my comments in good faith. Even if they are incorrect, at the time of writing I believe in them. And I really appreciate all the help I receive from all of you in this forum. It's invaluable
-
[Share Code] emoji to ui.Image or png file
The function below is pretty trivial. But opens up a door for more built in assets to use. I hadn't thought about it before like this.
Also @Webmaster4o gave me a great web resource to look up / search for emoji's - link
import ui # Forum @Phuket2 # just an example function to turn an emoji char into a ui.Image # with option to save it as a png file, if you pass file_name. # the function is basic. does not try help you with the font_size # just about the idea of doing it, many more assets available to use def emoji_to_image(emoji_char, w =32, h=32, font_name = 'Arial Rounded MT Bold', font_size = 28, file_path = None): r = ui.Rect(0, 0, w, h) with ui.ImageContext(r.width, r.height) as ctx: # just draw the string ui.draw_string(emoji_char, rect=r, font=(font_name, font_size), color='black', alignment=ui.ALIGN_CENTER, line_break_mode=ui.LB_TRUNCATE_TAIL) img = ctx.get_image() # write a file if file_path if file_path: with open(file_path, 'wb') as file: file.write(img.to_png()) return img if __name__ == '__main__': img = emoji_to_image('💋', file_path = 'junk000.png') img.show() # displays in the console img = emoji_to_image('🇹🇭', w = 256, h = 256, font_size = 250, file_path = 'junk001.png') img.show() # displays in the console
-
RE: Woo woo, question number 4! Seems simple.... change a node's (shapenode primarily) size after the fact?
@WTFruit , I have never wired with a node before. But have you tried
= (x, y) , a tuple -
RE: Use a .pyui file in another .pyui file
@Subject22 , below is how I use it.
# coding: utf-8 import ui import os class PYUILoaderStr(ui.View): ''' loads a pyui file into the class, acts as another ui.View class. ** Please note that the pyui class must have its Custom Class attr set to selfwrapper Thanks @JonB ''' def __init__(self, pyui_str, raw = True): # black magic here, for me at least... class selfwrapper(ui.View): def __new__(cls): return self if raw: pyui_str = json.dumps(pyui_str) ui.load_view_str(pyui_str, bindings={'selfwrapper':selfwrapper, 'self':self}) def xx(): print 'hi' return True class PYUILoader(ui.View): ''' loads a pyui file into the class, acts as another ui.View class. ** Please note that the pyui class must have its Custom Class attr set to selfwrapper Thanks @JonB ''' def __init__(self, f_name = None): print 'in PYUILoader init' # black magic here, for me at least... class selfwrapper(ui.View): def __new__(cls): return self if not f_name.endswith('.pyui'): f_name += '.pyui' # make sure the file exists if not os.path.isfile(f_name): raise OSError ui.load_view( f_name , bindings={'selfwrapper':selfwrapper, 'self':self}) class MyClass(PYUILoader): def __init__(self, f_name ): PYUILoader.__init__(self, f_name) self.width = 500 self.height = 500 print 'in Myclass' self['menu'].bg_color = 'red' def xx(self): print 'hello from my class' return True if __name__ == '__main__': mc = MyClass('StdView') mc.present('sheet', animated = False)