Kodi Community Forum

Full Version: Error Contents: name 'typedinone' is not defined
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Good Evening community,

Could someone please give me a hand with this.
Code:
import os
import xbmc
import xbmcgui
import zipfile
import shutil
import time
import datetime
import smtplib
#IMPORT MODULES


#KEYBOARD TEXT
def nam():
    name = xbmc.Keyboard('', 'Please type in your name')
    name.doModal()
    typedinone = name.getText()

def wd():
    weekday = xbmc.Keyboard('', 'Now type a day of the week')
    weekday.doModal()
    typedintwo = weekday.getText()

def clor():
    colo = xbmc.Keyboard('', 'And Finally type in a colour')
    colo.doModal()
    typedinthree = colo.getText()

#DATE AND TIME
now = datetime.datetime.now()
runtime = now.strftime("%Y-%m-%d %H:%M")

#not sure what to do with these
#content1 = xbmc.executebuiltin('typedinone.getText()')
#content2 = xbmc.executebuiltin('typedintwo.getText()')
#content3 = xbmc.executebuiltin('typedinthree.getText()')


nam() , wd() , clor()

mailserver = smtplib.SMTP("smtp.mail.yyy",587)
mailserver.ehlo()
mailserver.starttls()
mailserver.login('[email protected]','somepwd')
mailserver.sendmail('[email protected]','[email protected]', typedinone + ' on  ', + typedintwo + 'whos favourite colour is', + typedinthree + 'at', + runtime)
mailserver.close()
#Notification Of sent Email
xbmc.executebuiltin("Notification(Thankyou for helping me with this, message sent,()")

I Am aware all the mail stuff is made up, Ill fill in the blanks later on. But Im getting
Code:
typedinone is not defined.
Im guessing that its because its in a function. How would I pull the information out of the function and insert in the message
to be sent to myself.
Code:
def nam():
    keyboard = xbmc.Keyboard('', 'Please type in your name')
    keyboard.doModal()
    if ( keyboard.isConfirmed() ):
        text = keyboard.getText()
        return text

typedinone = nam()
Hi Ronie,

Thanks a lot, All sorted. Nice one.