print '\n\n Highest emotion: ' + highest + '\n\n'
    print 'Accumulated so far: '
    print tweetprocessor.counts
    # logger.logCounts(tweetprocessor.counts)
    
    print '\n\n'
    if (highest == 'happy'):
        gui.setColor('green')
    elif (highest == 'angry'):
        gui.setColor('red')
    elif (highest == 'sad'):
        gui.setColor('blue')
    elif (highest == 'profane'):
        gui.setColor('orange')
    # Do process again after 15 sec
    _job = gui.after(QUERY_FREQ, searchEvent)

def quitCallback():
    print "Exited."
    gui.stopGui()

def get_string():
    search_text = gui.search.get()
    if len(search_text) > 0:
        return search_text

if __name__ == '__main__':
    gui = Gui(quitCallback,get_string)
    _job = gui.after(QUERY_FREQ, searchEvent)
    gui.mainloop()
    countAndColor()

def countAndColor():
    highest = tweetprocessor.calcHighest()
    print '\n\n Highest emotion: ' + highest + '\n\n'
    print 'Accumulated so far: '
    print tweetprocessor.counts
    print '\n\n'
    if (highest == 'happy'):
        gui.setColor('green')
    elif (highest == 'angry'):
        gui.setColor('red')
    elif (highest == 'sad'):
        gui.setColor('blue')
    elif (highest == 'profane'):
        gui.setColor('orange')
    # Do process again after 15 sec
    Timer(15, searchEvent).start()

def startAppThread():
    thread = Thread(target = searchEvent())
    thread.start()
    thread.join()

if __name__ == '__main__':

    gui.after(15000, startAppThread)
    gui.mainloop()
    #TODO logger.readTweetLogs()