• abcabc

    I will put it in a github repo with MIT license after two/three weeks ( Need to do some cleanup, add some more features, add few more
    examples)

    posted in Pythonista read more
  • abcabc

    Did you try my code on mac or PC? (I have tested on PC ,(windows 10, kivy 1.9.1, python 3.6) it works fine.)

    posted in Pythonista read more
  • abcabc

    I am sorry if I hurt your feelings. I thought that this code will help somebody like me who is familiar with pythonista but not with kivy. I just spent two to three hours to code this. I do not have any projects related to this and I am not associated with any company. I am a retired old man and my only intention is to help others. Once again I am sorry if I hurt your feelings.

    posted in Pythonista read more
  • abcabc

    Nice. Here is a slightly different approach.

    1. Rather than using new set of API, pythonista API is used as standard. For example, "example1.py" (modified example of yours) runs directly in pythonista (currently it requires one line change from kivy code)
    2. In Kivy, you need an extra file "ui.py". All the code is in this file. It is just a wrapper on kivy objects.
    3. This code is not complete and a lot needs to be done.

    example1.py

    import ui
    
    def closepage(sender):
        v.close()
    
    def function_1(sender):
        v['label1'].text = 'Oh! You clicked my button.'
    
    #uncomment or comment lines below based on platform
    #v = ui.MainView(frame=(0, 0, 600, 450)) # kivy
    v = ui.View(frame=(0, 0, 600, 450)) # pythonista
    
    v.add_subview(ui.Label(frame=(80, 10, 240, 20), 
                            name='label1',
                            text='Hey I am just a simple label.'))
    v.add_subview(ui.Button(frame=(40, 40, 100, 40), 
                            title='Click me', 
                            action=function_1))
    v.add_subview(ui.Button(frame=(460, 40, 100, 40),
                            title='Close me', 
                            action=closepage))
    v.add_subview(ui.TextField(frame=(40, 120, 300, 40),
                             name='textfield1',
                             text='I am a text field'))
    v.add_subview(ui.ImageView(frame=(460, 310, 100, 100),
                                image=ui.Image('insidelogo.png')))
                                
    v.present('sheet')
    
    

    ui.py

    from kivy.uix.floatlayout import FloatLayout
    from kivy.core.window import Window
    from kivy.base import runTouchApp
    from kivy.utils import platform as core_platform
    import sys
    
    from kivy.uix.label import Label as KivyLabel
    from kivy.uix.button import Button as KivyButton 
    from kivy.uix.textinput import TextInput
    from kivy.uix.image import Image as KivyImage
       
    from kivy.graphics import Color
    from kivy.graphics import Rectangle
    
    class View(object):
        screen_size = (800, 600)
        xratio = screen_size[0] / 800.0
        yratio = screen_size[1] / 600.0
        def __init__(self, frame=(0,0,100,100),
                    name=''):
            self.frame = frame
            self.name = name
            self.superview = None
            self.uniobject = None
            self.rootdict = {}
    
    class MainView(View):
        def __init__(self, frame=(0,0,100,100), name=''):
            super().__init__(frame=frame, name=name)
            self.root = FloatLayout()
            Window.size = View.screen_size
            self.root.canvas.add(
               Color(1.0, 1.0, 1.0))
            self.root.canvas.add(
              Rectangle(pos = (self.frame[0] * View.xratio,
                    self.frame[1]*View.yratio), 
                    size = (frame[2] * View.xratio, 
                           frame[3] * View.yratio)))
    
        def add_subview(self, v):
            v.superview = self
            if v.name:
                self.rootdict[v.name] = v.kivyobject
            self.root.add_widget(v.kivyobject)
    
        def __getitem__(self, key):
           return self.rootdict[key]
    
        def close(self):
            if core_platform == 'android':
                sys.exit()
            else:
                Window.close()
    
        def present(self, style):
            #todo: screen size, style
            runTouchApp(self.root)
                
    class Button(View):
        def __init__(self, frame=(0,0,100,100),
                        title='',
                        name='',
                        font=('Helvetica', 20),
                        action=None):
            super().__init__(frame=frame, name=name)
            self.kivyobject = (KivyButton(text=title,
                size_hint_y = None,
                size_hint_x = None,
                width = self.frame[2]* View.xratio,
                height = self.frame[3]* View.yratio,
                pos = (self.frame[0] * View.xratio, 
                       self.frame[1] * View.yratio),
                on_press = action))
                             
    class Label(View):
        def __init__(self, frame=(0,0,100,100),
                        text='',
                        alignment='',
                        name='',
                        font=('Helvetica', 20),
                        text_color='blue'):
            super().__init__(frame=frame, name=name)
            label = KivyLabel(text=text,
                id=name,
                size_hint=(1.0, 1.9),
                halign="left", 
                valign="bottom",
                pos = (self.frame[0] * View.xratio,
                       self.frame[1] * View.yratio))
            #label.bind(size=label.setter('text_size'))
            self.kivyobject = (label)
    
    class TextField(View):
        def __init__(self,
              frame=(0,0,100,100),
              text='',
              name='',
              font=('Helvetica', 20),
              alignment='',
              text_color='blue'):
              #action=None):
            super().__init__(frame=frame, name=name)
            self.kivyobject = (TextInput(text=text,
                size_hint_y = None,
                size_hint_x = None,
                height = self.frame[3]* View.yratio,
                width = self.frame[2]* View.xratio,
                multiline = True,
                pos = (self.frame[0] * View.xratio, 
                    self.frame[1] * View.yratio)))
                #on_press = action))
    
      
    class ImageView(View):
        def __init__(self,
               frame=(0,0,100,100),
               name='',
               image=None):
            super().__init__(frame=frame, name=name)
            if image:
                image_source = image.source
            else:
                image_source = None
            self.kivyobject = (
              KivyImage(source=image_source,
                allow_stretch = True,
                size = (self.frame[2]* View.xratio,
                        self.frame[3]* View.yratio),
                pos = (self.frame[0] * View.xratio, 
                        self.frame[1] * View.yratio)))
    
    class Image(object):
        def __init__(self, source):
            self.source = source
    

    Copy of the code in gist.
    https://gist.github.com/balachandrana/4e9accfc894785682f230c54dc5da816#file-ui-py

    posted in Pythonista read more
  • abcabc

    Pythonista does not support modules like subprocess. Hence I think that you may not be able to run this on pythonista.

    I am able to install it but it gives error while running (not able to start the interactive session).

    posted in Pythonista read more
  • abcabc

    Look at this link. I have not tried it.
    https://github.com/secdev/scapy/issues/401

    posted in Pythonista read more
  • abcabc

    1. dropbox sync (look at few posts before) seems to work fine
      https://forum.omz-software.com/topic/3951/sync-to-dropbox

    2. May be "Pythonista find and replace" does not support regular expressions

    3. A simple appex script could be used to save files on pythonista

    4. loading from working copy is another option

    5. Look at this for some more editor options
      https://forum.omz-software.com/topic/3543/share-in-work-side-bar-replacement

    posted in Pythonista read more
  • abcabc

    I am able to reproduce the problem on my ipad ( Pythonista version 3.1.1 (311002) running Python 3.5.1 on iOS 10.1.1 on a 32-bit iPad3,4 with ascreen size of (1024 x 768) * 2) ). It looks like that my ipad is not able to handle large paths and i have done the following modifications to run it on my ipad. I have precomputed the shape nodes and have added a reduction factor. I am able to run with reduction factor 4 and above.
    (I have also created a pretty printed version of pathLists file which can be edited on pythonista IDE
    https://gist.github.com/balachandrana/de8c3a84ad59be90064108b148a8bd21 )

    Other possibility is implementing this in shaders and "2D vector graphics library" in shadertoy could help in this implementation.
    https://www.shadertoy.com/view/lslXW8

    import scene
    from variableTools import glyphsListConstruct
    
    glyphs_list1 = glyphsListConstruct()
    reduction_factor = 4.0
    x_factor = (10.24 / 2)*reduction_factor
    
    
    class MyScene(scene.Scene):
        def setup(self):
            self.glyphs_list = [scene.ShapeNode(i) for i in glyphs_list1[::int(reduction_factor)]]
            self.myPath = self.glyphs_list[0]
            self.myPath.anchor_point = 0, 0
            self.myPath.position = (1024 - self.myPath.bbox.width * 1.75,
                                     768 - self.myPath.bbox.height * 1.3)
            self.add_child(self.myPath)
            self.background_color = 'lightgrey'
            self.touch_moved = self.touch_began
    
        def touch_began(self, touch):
            r = int(touch.location.x / x_factor)%len(self.glyphs_list)
            #print(touch.location.x, r)
            self.myPath.remove_from_parent()
            self.myPath = self.glyphs_list[r]
            self.myPath.anchor_point = 0, 0
            self.myPath.position = (1024 - self.myPath.bbox.width * 1.75,
                                     768 - self.myPath.bbox.height * 1.3)
            self.add_child(self.myPath)
    
    
    scene.run(MyScene(), show_fps=True)
    
    

    posted in Pythonista read more
  • abcabc

    1. A simple way to combine gifs would be to get the image lists of each gif, concatenate these image lists to form a single images list and then generate a new gif from this single list.

    2. It seems to be a documentation error. The second one should be remove_assets. You could file an issue regarding this.
      https://github.com/omz/Pythonista-Issues

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!