• Drizzel

    I assume you’re in the console right now. First of all, there’s a small arrow in the top left corner, or you can alternatively swipe left and/ or right to switch between console and code. Oh, and as long as you’re asking something related to pythonista, there’s no stupid questions, just stupid answers.

    posted in Pythonista read more
  • Drizzel

    import numpy as np
    import sys
    import motion
    import matplotlib.pyplot as plt
    from time import sleep
    import console
    del g
    del ag
    del data
    del data_ag
    def main():
        console.alert('Motion Plot', 'When you tap Continue, accelerometer (motion) data will be recorded for 5 seconds.', 'Continue')
        print('Capturing motion data...')
        num_samples = fs*duration;
        data = []
        data_ag = []
        for i in range(num_samples):
            g = motion.get_gravity();
        print('Capture finished, plotting...')
        x_values = [x/fs for x in range(num_samples)]
        for i, color, label in zip(range(3), 'rgb', 'XYZ'):
            plt.plot(x_values, [g[i] for g in data], color, label=label, lw=2)
        plt.gca().set_ylim([-1.0, 1.0])

    posted in Pythonista read more
  • Drizzel

    your dataset (the variable data) is an array

    data = []

    that contains tuples, which is the variable g.

    data = [()]

    This tuple then contains 3 variables.

    data = [(5.67, 1.87, 3.93)]

    Running this code:

    for g in data:

    will print every tuple in the data array, which is (5.67, 1.87, 3.93).
    If you want to print a single float (the name for a number with decimal places), just use this:


    Replace the 0 with a 1 to print the second float in g, and 2 for the third float in g

    posted in Pythonista read more
  • Drizzel

    Whenever I try to run this basic script, I get the Error [Errno 1] Operation not permitted. It’s some example code of the pylatex module, so it should theoretically work. Or is it IOS that blocks some functions?

    This example shows basic document generation functionality.
    ..  :copyright: (c) 2014 by Jelte Fennema.
        :license: MIT, see License for more details.
    # begin-doc-include
    from pylatex import Document, Section, Subsection, Command
    from pylatex.utils import italic, NoEscape
    def fill_document(doc):
        """Add a section, a subsection and some text to the document.
        :param doc: the document
        :type doc: :class:`pylatex.document.Document` instance
        with doc.create(Section('A section')):
            doc.append('Some regular text and some ')
            doc.append(italic('italic text. '))
            with doc.create(Subsection('A subsection')):
                doc.append('Also some crazy characters: $&#{}')
    if __name__ == '__main__':
        # Basic document
        doc = Document('basic')
        # Document with `\maketitle` command activated
        doc = Document()
        doc.preamble.append(Command('title', 'Awesome Title'))
        doc.preamble.append(Command('author', 'Anonymous author'))
        doc.preamble.append(Command('date', NoEscape(r'\today')))
        doc.generate_pdf('basic_maketitle', clean_tex=False)
        # Add stuff to the document
        with doc.create(Section('A second section')):
            doc.append('Some text.')
        doc.generate_pdf('basic_maketitle2', clean_tex=False)
        tex = doc.dumps()  # The document as string in LaTeX syntax

    posted in Pythonista read more
  • Drizzel

    @BrianAz look at this. This module allows you to create shortcuts for the shortcuts app in pythonista, which is compatible with siri

    posted in General Discussion read more
  • Drizzel

    Sorry for the late reply, your answer was exactly what I needed. I tried things like self.close() and self.hide(), but I just didn’t get to the self.view.close()

    posted in Pythonista read more
  • Drizzel

    @donaldcassey yes it should work with soundcloud. I didn’t test it, but the module contains a file for extracting data from soundcloud. If you want to use this, just copy the code into a new directory and create a file called ‘songs.txt’ . Then paste every link into a new line in the text file. The code does not work if the file contains empty lines, but you can fix that with by replacing



    if not “\n” in song_url: dl.download([song_url])

    posted in Pythonista read more
  • Drizzel

    I don’t want to bore you with a ton of details, so long story short: how do I close a game that has been coded with the scene module? I don’t want to tap the little close button in the top right corner.

    posted in Pythonista read more
  • Drizzel

    @cvp wow, that’s interesting. How do you add another Button to the toolbar?

    posted in Pythonista read more
  • Drizzel

    @JonB Great, i will definitely look into them. For others who might want to know, one interesting module I found is NEAT

    posted in General Discussion read more

Internal error.

Oops! Looks like something went wrong!