Python program is outputting a strange value to my 16x2 Character LCD
Question: I've built a small program with a Tkinter GUI to let me enter 2 lines of text
and make it display it on the character screen. It all works pretty neatly
until I press apply text, because then I just seem to get a weird value on
both lines of the LCD.  
e.g.  
Wanted line 1: "`Test`"  
Wanted line 2: "`Please work`"

Actual result

Line 1: `.3047332040L.304`  
Line 2: `7332320L`

This is my code:

    
    
    __author__ = 'David'
    from Tkinter import *
    from Adafruit_CharLCD import Adafruit_CharLCD
    from time import sleep
    import psutil
    chargui = Tk()
    lcd = Adafruit_CharLCD()
    lcd.begin(16, 1)
    
    
    class FrameWork:
        def __init__(self, master):
            frame = Frame(master)
            frame.pack()
    
    
            # Creation
            self.lbl_enter1 = Label(frame, text="Enter the first line:")
            self.lbl_enter2 = Label(frame, text="Enter the second line:")
    
            self.ent_line1 = Entry(frame)
            self.ent_line2 = Entry(frame)
    
            self.btn_apply = Button(frame, text="Apply Text", command=self.applymessage)
            self.btn_cpum = Button(frame, text="CPUMem", command=self.CPUMem)
            self.btn_quit = Button(frame, text="Quit", command=frame.master.destroy)
    
    
            # Griding
            self.lbl_enter1.grid(row=0, column=0, sticky=E, padx=2)
            self.lbl_enter2.grid(row=1, column=0, sticky=E, padx=2)
    
            self.ent_line1.grid(row=0, column=1, sticky=W)
            self.ent_line2.grid(row=1, column=1, sticky=W)
    
            self.btn_apply.grid(row=2, column=1, sticky=W, padx=24)
            self.btn_cpum.grid(row=2, column=0, columnspan=2, sticky=W, padx=85)
            self.btn_quit.grid(row=2, column=1, sticky=E)
    
        def applymessage(self):
            lcd.clear()
            lcd.message(str(self.ent_line1))
            lcd.message(str(self.ent_line2))
    
    
        def CPUMem(self):
            while 1:
                lcd.clear()
                lcd.message("CPU: " + str(psutil.cpu_percent()) + "%\n")
                lcd.message("MEM: " + str(psutil.virtual_memory().percent) + "%")
                sleep(1)
    
    
    g = FrameWork(chargui)
    chargui.mainloop()
    

Don't mind the `CPUMem` function. This function works nicely. It's just
`applymessage(self):` that gives me trouble. I get no error at all. If I
remove `srt()` from the 2 lcd.message functions though, it says it can't
concatenate a string with an int. Any solutions?

Edit:  
I tried to just print the value to the console instead of putting it onto the
LCD, and it still gives me the weird values (are they memory locations? wild
guess) for both lines  
Line 1: `.3047815368L.3047815608L`  
Line 2: `.3047815368L.3047815648L`


Answer: As you found, the LCD has nothing to do with it. The problem is trying to
convert a Tkinter `Entry` object into a `str`:

    
    
    str(self.ent_line1)
    

calls a [special
method](http://www.rafekettler.com/magicmethods.html#representations),
`self.ent_line1.__str__()` to get the string representation of the object (as
does `print`). There is no expectation that `__str__` is defined to do
something useful.

Actually, investigating using the interactive shell, you can find that this
special method is defined in a parent class, and it's docstring is "Return the
window path name of this widget." That's what you're seeing.

What you actually want, the text typed into the widget as a string, is given
by [`get()`](http://effbot.org/tkinterbook/entry.htm#Tkinter.Entry.get-
method):

    
    
    print self.ent_line1.get()
    

