omz:forum

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

    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 0
    • Followers 3
    • Topics 14
    • Posts 167
    • Best 23
    • Controversial 0
    • Groups 0

    Cethric

    @Cethric

    27
    Reputation
    2404
    Profile views
    167
    Posts
    3
    Followers
    0
    Following
    Joined Last Online

    Cethric Unfollow Follow

    Best posts made by Cethric

    • RE: How to change a size from a subview

      @RMurtsoo I am going to try an explain why this hasn't worked for you with out actually giving you a direct answer, not because I am trying to be rude/annoying but it is in my honest belief that we don't learn very well when just given an answer. So if this does come across as rude or demeaning I appologise.
      So to pull your code apart

      view = ui.View()  # this is correct however you might want to consider setting a frame size. `view = ui.View(frame=(0,0,width,height))` as the default is less than 200/200 from memory
      view.present('portrait')  # from documentation `ui.View.present(style='default', animated=True, popover_location=None, hide_title_bar=False, title_bar_color=None, title_color=None, orientations=None)` therefore if you want to force a orientation you need to provide values for `orientations` not `style` http://omz-software.com/pythonista/docs/ios/ui.html#ui.View.present
      
      def button():  # `ui.Button` actions require a sender argument, ie `def button(sender):...` where `sender` can be named anything
          ui.Imageview('Image').height = 120  # this creates a new `ui.ImageView` and doesn't actually reference any view from you `view` variable in the global stack. This is why you `ui.ImageView` height is not changing. Consider reading the documentation and examples to see how this is done
      
      img = ui.ImageView()  # this is correct however you might want to set a new frame size here as the default is 0/0. Which cause also be an attributing reason to why you aren't seeing anything. `ui.ImageView(frame=(0,0,200,200)` or you can set it later with `img.width`, `img.height`, `img.x` and `img.y`
      img.name = 'Veer'
      img.heigt = 150  # I'm going to assume that this is just a typo
      view.add_subview(img)
      
      button = ui.Button()  # by naming the variable of this object to `button` you have overrided the method by the same name, thus you will get a `Exception` when tapping the button. Consider renaming either the method name to something else or renaming this variable to something else.
      button.action = button
      view.add_subview(button)
      

      I would highly recommend reading the documentation for Pythonista, and for Python. Out of curiosity which version of Pythonista are you using?

      posted in Pythonista
      Cethric
      Cethric
    • objc_util Documentation

      @omz is it possible now that we have access to objc classes with in Pythonista 2 and 3 that as well as providing documentation for the python modules you could also provide documentation for the internal ObjC classes that pythonista uses? (I understand that this is a closed source project, but now that we can access pretty much any C interface within pythonista, it would help if when we wanted to modify pythonista. Instead of using trial and error to find out about what a method does we could use the documentation (less chance of breaking something))
      I only ask this because I am considering creating a system similar to how InteliJ Idea handles breakpoints and a visual method for showing subclassing and method overriding, and it would help if I knew where to look to be able to change line numbers and what is displayed on them.

      posted in Pythonista
      Cethric
      Cethric
    • RE: IndexError happens in pythonista 3

      Without seeing the data or the complete stack trace I can only guess what the issue is. But two possibilities come to mind:

      1. line is a white space character so there is nothing to split which results in 2).
      2. splitUP has a value of ['xy'] instead of ['x', 'y']
        Either way try printing the value of splitUP Without breaking it first. IE print(splitUP) and see what that gives.
      posted in Pythonista
      Cethric
      Cethric
    • RE: Simple n00b question: Populating TableView from a list

      I assume that you have your data already in a list form and that you have some understanding of how pythonista UI's work, if not let me know and I will try and explain it as best I can.
      The following is a brief outline of what needs to be done:

      import ui
      data = [x for x in range(0, 50)]
      datasource = ui.ListDataSource(data)
      tv = ui.TableView()
      tv.data_source = datasource
      tv.delegate = datasource
      
      def selectitem(*args):
          view = ui.View(title='{}'.format(args[1]))
          label = ui.Label()
          label.text = "{}, {}, {}".format(*args)
          label.size_to_fit()
          view.add_subview(label)
          view.background_color = 'white'
          nav.push_view(view)
      datasource.tableview_did_select = selectitem
      
      nav = ui.NavigationView(tv)
      
      nav.present()
      

      Hope this helps.

      posted in Pythonista
      Cethric
      Cethric
    • RE: Ui.textfield drives slider

      Sometimes our best way of learning is by teaching/supporting/helping others as it forces us to think differently about something that we have learned. Keep teaching/supporting/helping people on here. At the end of the day you might know something that others don't, or can provide a shorted possibly better answer than what others could do.
      If the answer you give doesn't go so well, you have the safety net of everyone else around, so long as you learn from it.

      posted in Pythonista
      Cethric
      Cethric
    • RE: File sharing and storage to OneDrive

      If it was through the share sheet, I cannot say why it does not work anymore (does it work else where?)
      If it was through the share sheet another alternative would be to use the python SDK provided by Microsoft

      posted in Pythonista
      Cethric
      Cethric
    • RE: Crash when using Sleep() in Scene module

      Can you please post your code (preferably on GitHub or other git hosting service) as I can not get enough infomation out of this code to be able to find where the issue occurs.
      Can I also recommend that instead of a try: except: clause you check to see if start_square is in self.green_list

      posted in Pythonista
      Cethric
      Cethric
    • RE: MFi Game Controller Support

      Also isn't there a tag that needs to go in the Application's plist file to say that it is allowed to connect to MFI Controllers? (I can't check this at the moment cause I am not at my computer)

      posted in Pythonista
      Cethric
      Cethric
    • RE: MFi Game Controller Support

      Are you able to test that the controller works in other iOS applications?
      Also try reading through the apple documentation https://developer.apple.com/library/ios/documentation/GameController/Reference/GameController_RefColl/index.html
      You need to call
      startWirelessControllerDiscoveryWithCompletionHandler_
      And then stop the search after you have your controller.

      posted in Pythonista
      Cethric
      Cethric
    • RE: Editor Indenting (blocks of code)

      After highlighting the line is there along with the Cut | Copy | Paste etc context menu a <--- and a Indent ---> button?

      posted in Pythonista
      Cethric
      Cethric

    Latest posts made by Cethric

    • RE: UnicodeDecodeError in _appex.get_input()

      In general the _appex model is not really meant to be used as it is the backend for the appex wrapper module. Try using:

      import appex
      print(appex.get_text())
      print(appex.get_urls()) # or appex.get_url()
      
      posted in Pythonista
      Cethric
      Cethric
    • RE: Header parser

      From memory my OpenGLES library had very rudimentary header parsing (If its not on the github repo its probably on my iPad) if you wanted to have a look at it and use components of it. From memory it was very messy, it did what it needed to do but it wasn't very nice.

      posted in Pythonista
      Cethric
      Cethric
    • RE: Obj_C struct OSType define problem.

      @wolf71 objc_util dynamically creates its own copy of the AudioComponentDescription hence your ArgumentError This can be resolved either by using the objc_util version (can remberer exactly how to do that) or you specify that you want to use your copy. Eg

      from objc_util import *
      import ctypes
      
      AVAudioUnit=ObjCClass('AVAudioUnit')
      AVAudioUnitComponent=ObjCClass('AVAudioUnitComponent')
      AVAudioUnitComponentManager=ObjCClass('AVAudioUnitComponentManager')
      
      #
      # componentType,componentSubType,componentManufacturer is OSType
      #
      # ref:  developer.apple.com/reference/audiotoolbox/audiocomponentdescription
      #
      class AudioComponentDescription(ctypes.Structure):
          _fields_=[('componentType',ctypes.c_char_p),('componentSubType',ctypes.c_char_p),('componentManufacturer',ctypes.c_char_p),('componentFlags',ctypes.c_uint32),('componentFlagsMask',ctypes.c_uint32)]
          
      anyEffect = AudioComponentDescription('aufx','dcmp','appl',0,0)
      availableEffects = AVAudioUnitComponentManager.sharedAudioUnitComponentManager().componentsMatchingDescription_(anyEffect, argtypes=[AudioComponentDescription])
      
      posted in Pythonista
      Cethric
      Cethric
    • RE: Sound effect not stopping

      @starrshaw the sound is being played twice but the call to stop it playing is only made once.

      import sound, time
      y = "room_One.mp3"
      x = sound.play_effect(y)
      sound.play_effect(y)  # <- This call can be removed
      time.sleep(5)
      sound.stop_effect(x)
      
      posted in Pythonista
      Cethric
      Cethric
    • RE: IndexError happens in pythonista 3

      Without seeing the data or the complete stack trace I can only guess what the issue is. But two possibilities come to mind:

      1. line is a white space character so there is nothing to split which results in 2).
      2. splitUP has a value of ['xy'] instead of ['x', 'y']
        Either way try printing the value of splitUP Without breaking it first. IE print(splitUP) and see what that gives.
      posted in Pythonista
      Cethric
      Cethric
    • RE: Simple n00b question: Populating TableView from a list

      I assume that you have your data already in a list form and that you have some understanding of how pythonista UI's work, if not let me know and I will try and explain it as best I can.
      The following is a brief outline of what needs to be done:

      import ui
      data = [x for x in range(0, 50)]
      datasource = ui.ListDataSource(data)
      tv = ui.TableView()
      tv.data_source = datasource
      tv.delegate = datasource
      
      def selectitem(*args):
          view = ui.View(title='{}'.format(args[1]))
          label = ui.Label()
          label.text = "{}, {}, {}".format(*args)
          label.size_to_fit()
          view.add_subview(label)
          view.background_color = 'white'
          nav.push_view(view)
      datasource.tableview_did_select = selectitem
      
      nav = ui.NavigationView(tv)
      
      nav.present()
      

      Hope this helps.

      posted in Pythonista
      Cethric
      Cethric
    • RE: Removing missile, when goes off screen

      If you are really concerned about memory there is a lot more in your code that can be cleaned up, mainly unnecessary variables, etc. But if you need help with that then we can go over it after.
      As to the rockets not deleting correctly, I get an error before it can even delete due to non-existent indecies in the list (due to the list being modified from in the loop that is not really friendly with your code). To resolve that I completely changed your for-loop to the following:

      for i, missile in enumerate(self.missiles):
                  print(i, missile.position)
                  if missile.position.y > self.size_of_screen.y - 100:
                      missile.remove_from_parent()
                      self.missiles.remove(missile)
      

      Also Node.remove_from_parent() needs to be called for the object to be removed from the render list.

      posted in Pythonista
      Cethric
      Cethric
    • RE: Refresh ui

      @mrcoxall: does the last image display once the loop is finished? I just tested it (using different images) and it seemed that the only issue was that the loop was blocking the UI thread, so it couldn't update and render the new information. To fix this just add @ui.in_background above def start_button_touch_up_inside(sender) and it should work fine.

      posted in Pythonista
      Cethric
      Cethric
    • RE: Script to storyboard

      Yes .tmp.html can simply be changed to any value you want. The following code does this automatically for you:

      def createTables(text=None, name=None):
      	if text is None:
      		text = editor.get_text()
      	if name is None:
      		name = '{}.html'.format(os.path.basename(editor.get_path()))
      	path = os.path.join(os.path.expanduser('~/Documents'), name)
      	with open(path, 'wb') as f:
      		f.write(TEMPLATE.format('\n'.join([
      			TEMPLATE_ROW.format(x) for x in text.split('\n') if x != ''
      		])))
      	webbrowser.open("file://{}".format(path))
      

      However I would recommend against this on the basis that, if the .html was not appended to the name (or even just changing the name in any way shape or form) then it will replace the contents of the file you are working on. While this might be decent when rendered out it is not as easy to read as markdown is as plaintext. Hence I have used .tmp.html as only one file can be open at a time and this reduces 'clutter' from your documents folder (instead of dozens of xyz.md.html duplicate files there is just one .tmp.html). .tmp.html can be deleted whenever you want and will not damage you script file. (Also adding the prefix of . means the file will be hidden (reducing visual clutter)). Sorry if this has gone to far off on a wild tangent. Hope it answers your question as well...

      posted in Editorial
      Cethric
      Cethric
    • RE: Split a string

      @procryon: float(second_word) is never stored hence, screen.setBrightness_(second_word) will fail as a str object is being passed as an argument instead of a float or int object.
      Hence: float_value = float(second_word) and changing screen_word to float_value in screen.setBrightness_ should resolve your issue.
      I agree that ctypes/objc_util errors can sometimes be a little hard to read, however the error type (TypeError, ValueError, etc) can be a hint towards what the issue might be. In this instance passing a str argument where a float or int is expected.

      posted in Pythonista
      Cethric
      Cethric