text: Posts made by Alex210 | omz:forum
  Something is wrong with the scroll position of the actions menu. I spotted it first in landscape mode and with the keyboard visible, but it also happens in portrait mode when the menu contains more items than fit on the screen. The items at the bottom are there but can't be reached.
  This will indent or outdent all selected lines:
  #Indent/Outdent selected lines
  indent_char = '\t'
  selection = editor.get_line_selection()
  indent = console.alert('indent or outdent?', '', '<<', '>>') == 2
  for line in selected_text.splitlines():
  replacement += indent_char + line + '\n'
  replacement += line[line.find(indent_char) + len(indent_char):] + '\n'
  editor.replace_text(selection[0], selection[1], replacement)
  editor.set_selection(selection[0], selection[0] + len(replacement) - 1)
  Most of it is stolen from the (un)comment script. Change the indent_char variable to whatever your preference is, e.g. this could be 2 or 4 spaces. Outdent will only work if all lines use the same indent_char.
  This piece of code hangs after running it:
  self.wfile.write('<body><h2>hello</h2></body>')
  Pythonista keeps displaying the stop button (instead of play) even after tapping "done". I can't run this script again (or any other script) until completely quitting and restarting Pythonista. What could be the problem and what can I do?
  Changing the port helps:
  server = HTTPServer(('', 8001), RequestHandler)
  webbrowser.open('http://localhost:8001', stop_when_done = True)
  This works as I expected: "Done" closes the browser and the server exits. No restart needed.
  Weird: When I omit the stop_when_done parameter, it works with port 80 but hangs with port 8001?! In all cases browser and server start and run fine, only sometimes the server won't quit, "stop" button not working. So it probably has nothing to do with privileged ports, right?
  I'm lost here, can't explain that. Any ideas? I'm an absolute beginner in Python, so am I maybe missing something obvious? E.g. is this behaviour perfectly normal and to be expected from Python?
  Hi, maybe I'm just missing the obvious: How can I get files - like libraries, existing code or text files for analyzing - into Pythonista?
  Is there a way to easily share or sync a piece of code between Pythonista and my desktop computer, so that I can continue coding on either machine?