• p_atrick

    It works, thanks. Do you know why I needed to restart the app?

    posted in Pythonista read more
  • p_atrick

    Here is the UI file looks like:
    The imageview is above the textview.

    Here is what my output looks like:

    posted in Pythonista read more
  • p_atrick

    Not sure. I commented out the line, but it still does not load for me.

    posted in Pythonista read more
  • p_atrick

    The documentation said that by leaving it blank it will default to the same file name but with 'pyui'. The UI portion will load, and the text appears. However, the imageview is blank. I just took what worked with the text (page_text = v['textview1']) and tried it for the image. I assume the problem is there, but I am not sure what it is.

    posted in Pythonista read more
  • p_atrick

    I am making a dumb little program to learn how to use Pythonista. I am trying to something that changes the text/image when you tap the forward or back buttons. I cannot get the image to view. Does anybody see what I am doing wrong? Thanks.

    import ui
    page_count = 1
    # text for each page
    page1_text = 'This app introduces the game of baseball.\nUse the navigtion arrows to change pages.'
    page2_text = 'Page 2'
    page3_text = 'Page 3'
    # images for each page
    page1_img = 'http://www.talmageboston.com/files/2016/04/Baseball-Grass.jpg'
    def update_page(page_text, page_img):
        if page_count == 1:
            page_text.text = page1_text
    v = ui.load_view()
    page_text = v['textview1']
    page_img = v['imageview1']
    while True:
        update_page(page_text, page_img)

    posted in Pythonista read more
  • p_atrick

    I new to Python/Pythonista, and I am wondering if it would be possible to have a UI to launch something I did in matplotlib. I want to be able to tap a button and launch the scatter plot. The scatter plot works without the UI, but I am having trouble getting the button to work. Here is the code I have so far:

    import ui
    import matplotlib.pyplot as plt
    from random import choice, randint
    v = ui.load_view()
    def button_tapped(sender):
    def fill_x_values(walk_length):
        x_values = [0]
        points = walk_length
        while len(x_values) < points:
            x_direction = choice([1, -1])
            x_distance = choice([1, 2, 3, 4])
            x_step = x_direction * x_distance
            next_x = x_values[-1] + x_step
        return x_values
    def fill_y_values(walk_length):
        y_values = [0]
        points = walk_length
        while len(y_values) < points:
            y_direction = choice([1, -1])
            y_distance = choice([1, 2, 3, 4])
            y_step = y_direction * y_distance
            next_y = y_values[-1] + y_step
        return y_values
    def show_walk():
        walk_length = 50000
        x_values = fill_x_values(walk_length)
        y_values = fill_x_values(walk_length)
        plt.scatter(x_values, y_values,c='red', edgecolor='none', alpha=0.2, s=7)
    button = ui.Button()
    button.action = button_tapped

    Do any of you see what I am doing wrong? If you need any more info from me, please let me know. Thanks in advance.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!