Forum Archive

Learning about classes

sendog3c

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

@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')
sendog3c

CVP:

It Works. Thanks

sendog3c

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

@sendog3c 10 seconds here

vanimation = mainscreen()
vanimation.present('sheet')
def chge_name():
    vanimation.name = 'HABITFUN'
ui.delay(chge_name,10)
sendog3c

Very good. Thank you again.

sendog3c

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

@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.

sendog3c

CVP:

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

cvp

@sendog3c said:

Where can I find literature about it

In your script, select the word sqlite3, then help