omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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.


    Learning about classes

    Pythonista
    2
    10
    3487
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • sendog3c
      sendog3c last edited by

      Am posting this topic because I want to learn more about “classes”. Son specifically how to create a standard class for a hi.view. Maybe what I am doing is a crazy think but better to try than give up. Thanks.

      import ui
      
      equis = 0
      yee = 0
      ancho = 800
      alto = 800
      bgcolor = 'white'
      bordercolor = 'green'
      nameapp = 'HABITFUN'
      
      class mainscreen():
      		ui.View(frame = (equis,yee,ancho,alto))
      		ui.View(background_color = bgcolor)
      		ui.View(border_color = bordercolor)
      		ui.View(name = nameapp)
      		
      vanimation = mainscreen()
      vanimation.present()```
      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @sendog3c last edited by cvp

        @sendog3c hoping that helps, else, sorry, it's time to go to sleep... 2:00 night

        import ui
        
        equis = 0
        yee = 0
        ancho = 800
        alto = 800
        bgcolor = 'white'
        bordercolor = 'green'
        nameapp = 'HABITFUN'
        
        class mainscreen(ui.View):
        	def __init__(self, *args, **kwargs):
        		self.frame = (equis,yee,ancho,alto)
        		self.background_color = bgcolor
        		self.border_color = bordercolor
        		self.name = nameapp
        
        vanimation = mainscreen()
        vanimation.present('sheet')
        
        1 Reply Last reply Reply Quote 0
        • sendog3c
          sendog3c last edited by

          CVP:

          It Works. Thanks

          1 Reply Last reply Reply Quote 0
          • sendog3c
            sendog3c last edited by

            Good morning everyone. I would a help; I trying to change the name of my main view after a certain time from WELCOME TO HABITFUN to HABITFUN. But I want it be after 30 seconds. I am using FOR but look like is not working. The name change but fast.

            import ui
            
            equis = 0
            yee = 0
            ancho = 800
            alto = 800
            bgcolor = 'white'
            bordercolor = 'green'
            borderwide = 5
            nameapp = 'WELCOME TO HABITFUN'
            
            class mainscreen(ui.View):
                def __init__(self, *args, **kwargs):
                    self.frame = (equis,yee,ancho,alto)
                    self.background_color = bgcolor
                    self.border_color = bordercolor
                    self.border_width = borderwide
                    self.name = nameapp
                    
            vanimation = mainscreen()
            vanimation.present('sheet')
            for x in range(100):
            		if x == 100:
            				break
            vanimation.name = 'HABITFUN'
            
            cvp 1 Reply Last reply Reply Quote 0
            • cvp
              cvp @sendog3c last edited by

              @sendog3c 10 seconds here

              vanimation = mainscreen()
              vanimation.present('sheet')
              def chge_name():
              	vanimation.name = 'HABITFUN'
              ui.delay(chge_name,10)
              
              1 Reply Last reply Reply Quote 0
              • sendog3c
                sendog3c last edited by

                Very good. Thank you again.

                1 Reply Last reply Reply Quote 0
                • sendog3c
                  sendog3c last edited by

                  Hi again. It is time include this code in my beta app (jajajaja), but before to do it I would to learn where the database is going to be storage? Can storage it in the iPad? Thank you very much for your help.

                  import ui
                  import console
                  import sqlite3
                  import Image, ImageDraw, ImageFont
                  
                  conn = sqlite3.connect(":memory:"). 
                  c = conn.cursor()
                  
                  # Create table
                  c.execute('''CREATE TABLE IF NOT EXISTS logindata (date_login, user_name, pwd_user)''')
                  c.fetchall()
                  conn.commit()```
                  cvp 1 Reply Last reply Reply Quote 0
                  • cvp
                    cvp @sendog3c last edited by cvp

                    @sendog3c sqlite3.connect('myfile.db') stores your dB in the files system of Pythonista on your iPad.
                    ':memory:' stores the dB in the RAM, temporary memory during the run of your script.

                    1 Reply Last reply Reply Quote 0
                    • sendog3c
                      sendog3c last edited by

                      CVP:

                      Should I close my login database once I have used it?. Where can I find literature about it. Thanks .

                      cvp 1 Reply Last reply Reply Quote 0
                      • cvp
                        cvp @sendog3c last edited by

                        @sendog3c said:

                        Where can I find literature about it

                        In your script, select the word sqlite3, then help

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Powered by NodeBB Forums | Contributors