sendog3c
May 17, 2019 - 11:20
Hello there:
i would to show this image in my main screen, but I do not know how to become it a view. This is the code I found:
img = Image.new('RGBA', (210, 90), 'white')
draw = ImageDraw.Draw(img)
font = ImageFont.truetype('Chalkduster', 72)
draw.text((0, 0), 'Hello', fill='blue', font=font)
img.show()
Thanks
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()
vanimation=ui.View(frame = (0,0,800,800), bg_color = '#1fbad1', name = 'Habitfun Init')
img = Image.new('RGBA', (210, 90), 'white')
draw = ImageDraw.Draw(img)
font = ImageFont.truetype('Chalkduster', 72)
draw.text((0, 0), 'Hello', fill='blue', font=font)
img.show()
#labelmain = ui.Label(alignment=ui.ALIGN_CENTER,bg_color='#fafafa',border_color='black',border_width=1,frame=(100, 150, 300, 40),name='User',text='User Name', text_color = '#0d60fd')
#vanimation.add_subview(labelmain)
vanimation.present('fullscreen')
def button1_tapped(sender):
sender.superview.close()
def button2_tapped(sender):
alert_result = console.alert('Title', 'HOLA MARIANA, BUENOS DIAS', 'Button 1', 'Button 2')
button1 = ui.Button(title = 'SALIR', alignment=ui.ALIGN_CENTER, bg_color = '#ff1a55', font_color = 'black')
button1.frame = (100,400,100,50)
button1.tint_color = 'black'
button1.border_width = 1
button1.action = button1_tapped
button2 = ui.Button(title = 'ACEPTAR', alignment=ui.ALIGN_CENTER, bg_color = '#ff1a55', font_color = 'black')
button2.frame = (300,400,100,50)
button2.tint_color = 'black'
button2.border_width = 1
button2.action = button2_tapped
label1 = ui.Label(alignment=ui.ALIGN_CENTER,bg_color='#fafafa',border_color='black',border_width=1,frame=(100, 150, 300, 40),name='User',text='User Name', text_color = '#0d60fd')
label2 = ui.Label(alignment=ui.ALIGN_CENTER,bg_color='#fafafa',border_color='black',border_width=1,frame=(100, 250, 300, 40),name='Password',text='Password', text_color = '#0d60fd')
t1=ui.TextField(frame=(100,200,300,40))
t2=ui.TextField(frame=(100,300,300,40))
t1.begin_editing()
v=ui.View(name='Habitfun', bg_color='#545fd1',frame=(0,0,500,500))
v.add_subview(label1)
v.add_subview(label2)
v.add_subview(button1)
v.add_subview(button2)
v.add_subview(t1)
v.add_subview(t2)
def tfaction(textfield):
'''when you change the textfield, and press return, this metjod is called'''
print('textfield changed:', textfield.text )
t1.action=tfaction
v.present('sheet')
