omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. Phuket2

    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.


    • Profile
    • Following 12
    • Followers 11
    • Topics 275
    • Posts 2051
    • Best 234
    • Controversial 0
    • Groups 0

    Phuket2

    @Phuket2

    I am an Australian. I am retired and have been living in both Phuket and Pattaya for around 15 years. I have coded in numerous languages, but it's so long ago, hardly worth mentioning.
    I am very new to Python, and not very good. Basically a hobby for me. Mainly use Python on my iPad, almost nothing on my desktop.
    I am using Pythonista 1.6 with an iPad Pro, WiFi/Cellular 128gb

    Yes, my picture is a very ugly one (only one I had dressed up like this). I really like the band SPG (Steam Powered Giraffe), 2 thai friends and myself got a tailor here to make the outfits of certain band members in the band. We go out in them sometimes around pattaya. I am a lot of things, but not shy :)
    If you are interested , look up SPG on YouTube and look at their "Diamonds in the sky" cover. Then look at some of there other work!

    327
    Reputation
    8777
    Profile views
    2051
    Posts
    11
    Followers
    12
    Following
    Joined Last Online
    Website github.com/Phuket2/Pythonista Location Pattaya, Thailand Age 58

    Phuket2 Unfollow Follow

    Best posts made by Phuket2

    • RE: Disable stop button (X) in Scene

      @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.

      posted in Pythonista
      Phuket2
      Phuket2
    • 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

      posted in Pythonista
      Phuket2
      Phuket2
    • 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 πŸ˜€πŸ‘

      posted in Pythonista
      Phuket2
      Phuket2
    • 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. πŸ‘πŸ‘πŸ‘πŸ‘

      posted in Pythonista
      Phuket2
      Phuket2
    • [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

      posted in Pythonista
      Phuket2
      Phuket2
    • [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')
      
      posted in Pythonista
      Phuket2
      Phuket2
    • RE: External file access

      @Chilibird , have a look at this forum post. I think it answers your question well.

      posted in Pythonista
      Phuket2
      Phuket2
    • 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 :)

      posted in Pythonista
      Phuket2
      Phuket2
    • [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.

      posted in Pythonista
      Phuket2
      Phuket2
    • RE: Stash Ssh bug report

      @Webmaster4o , I know your heart was in the right place. It just sounded hash.

      posted in Pythonista
      Phuket2
      Phuket2

    Latest posts made by Phuket2

    • RE: Use scene and ui in the same program

      @pythonista21 , date has a day, month and year property you can access. So date.year, is an int.

      posted in Pythonista
      Phuket2
      Phuket2
    • RE: Lan game communication?

      @Drizzel , i just happened to watch this David Beasley YouTube Video today. If you haven't already watched I think you might find it intesting.

      posted in Pythonista
      Phuket2
      Phuket2
    • RE: Can Someone Turn This Script Into a β€˜Node’ Tutorial, Please?

      @ccc , its the / operator , need the // version in py3.x

      for i, front_image in enumerate(self.front_images):
                  x, y = i%5, i//5
      
      posted in Pythonista
      Phuket2
      Phuket2
    • RE: Stash Install

      @Tiowang, thanks very much. That fixed it. 2 occurrences to replace in the source file.

      posted in Pythonista
      Phuket2
      Phuket2
    • RE: Stash Install

      I am getting the same problem with installing other packages. I thought it might have something to do with the new python warehouse release and not using pip v10.x

      I did selfupdate on stash to make sure it was the latest. Latest version is using pip v9 something.
      I tried to upgrade pip in stash myself once and did something very wrong and had to reinstall stash. So i didn't try upgrading the pip myself this time.

      posted in Pythonista
      Phuket2
      Phuket2
    • RE: Buttons not read from pyui

      @Gadgettyke, looks like you just forgot to put your function name in action property of the button in the ui designer. ie button_action.

      posted in Pythonista
      Phuket2
      Phuket2
    • RE: tkinter on pythonista

      Guys, tkinter can't be used in Pythonistia. Tkinter is for desktop ui's not mobile. Pythonistia comes with a ui module. You use this to make a GUI in Pythonistia. Its very good. There also is a ui designer. If you select 'UIFile' when creating a new file, once its created you will see you are in the UI Designer. You can also do in code, have a look at the UI module in the docs

      posted in Pythonista
      Phuket2
      Phuket2
    • RE: Need UI layout help

      @nerdtron , no problems. I think for this example that flex would be the best and easiest. However, when I tried doing it, I had a brain freeze! Its been a long time since I have done it. Pls dont take that as it is hard to do. Once you have it in your head, normally its simple.
      I am sure someone else here will chime in with the correct way to set the flex settings.

      The example I have put below is still a good a good way to know. Its using a custom view. One of the callbacks you get when you have a Custom View Class is layout. Its called by the ui automatically (if you have a method called layout) when you need to respond to changes in your views height or width. Its worth having a read through the docs about Custom Views.
      They are easy to make and give you a lot more flexibility and some extra functionality.

      Anyway, I hope this also helps

      import ui
      
      class MyClass(ui.View):
          def __init__(self, *args, **kwargs):
              super().__init__(*args, **kwargs)
              # create the field and button
              self.in_fld = ui.TextField()
              self.post_btn = ui.Button(title='Add Item',
                                        bg_color='orange',
                                        corner_radius=6,
                                        action=self.btn_action,
                                        )
                                        
              # do some static adjustments to button and field properites
              # properties that we dont need to calculate in layout
              self.post_btn.size_to_fit()
              self.post_btn.width += 4
              self.post_btn.y = 2
              
              self.in_fld.x = 2
              self.in_fld.y = 2
              self.in_fld.height = self.post_btn.height
              
              self.add_subview(self.in_fld)
              self.add_subview(self.post_btn)
              
          def btn_action(self, sender):
              # just to show its working append '@' to the in_fld text
              self.in_fld.text += '@'
              
          def layout(self):
              '''
              This method is called by the ui automatically when required,
              such as orientation change.
              '''
              
              # only need to adjust the width of the fld and the x pos
              # of the btn for this case
              self.in_fld.width = self.width - self.post_btn.width - 6
              self.post_btn.x = self.in_fld.frame.max_x + 2
              
      if __name__ == '__main__':
          mc = MyClass()
          mc.present()
      
      '''
      This would also work as expected    
      if __name__ == '__main__':
          f=(0, 0, 320, 480)
          mc = MyClass(frame=f)
          mc.present('sheet')
      '''
      
      posted in Pythonista
      Phuket2
      Phuket2
    • RE: Need UI layout help

      @nerdtron, I think the below gives you what you want. I didn't try and get your flex values correct. If you look in the ui.designer, this will help get the settings correct. But you still need to size and position your ui objects for flex to work. Hope it helps.
      Also the + 2 and +4 etc in the code is for some margins between the view frame and the ui objects.

      import ui
      
      view = ui.View()
      view.name = 'test UI'
      view.background_color = 'black'
      
      r = ui.Button(title='Add Item', bg_color='orange',
                    width=100, height=100, corner_radius=6)
      r.size_to_fit()          # resizes the button, but a little tight
      r.width += 4             # add a few extra pixels
      
      # using get_window_size()[0], could use ui.get_screen_size()[0]
      # get_window_size should work on split screens also
      r.x = ui.get_window_size()[0] - r.width - 2 # returns a tuple (w,h)
      r.y = 2
      #r.background_color = 'orange'
      #r.flex = 'BL'
      view.add_subview(r)
      
      s = ui.TextField(width=r.frame.min_x - 4,
                       height=r.height)
      s.x = 2
      s.y = 2
      #s.flex = 'BR'
      view.add_subview(s)
      s.begin_editing()        # This gets the text field ready for input.
                               # You can comment this out, if you dont want
                               # it to behave like this
      view.present('fullscreen')
      
      posted in Pythonista
      Phuket2
      Phuket2
    • RE: safari appex.get_web_page_info

      This is only a stab in the dark. But often when I have had problems with something that works some of the time and not other times. The answer is normally relates to timing, ui/blocking etc.
      So using the @ui.in_background decorator could help with the ui blocking, sometimes calling time.sleep(1) can help. As I say I am guessing, but I recognise the general pattern of sometimes this works other times it does not from the problems I have had. A ui blocking or timing issue. Hope it helps, I know others here could be more concise to the exact problem, maybe this is enough food for thought.

      posted in Pythonista
      Phuket2
      Phuket2