예제 #1
0
 def _refresh_all(self, silent = True):
     self.todoList = TodoList(self.todoFileLocation);
     self.ind = self._get_indicator()
     self.menu = self._create_menu()
     self.ind.set_menu(self.menu)
     if silent == False:
         self.todoList.print_stats()
예제 #2
0
 def _refresh_all(self, silent = True):
     self.todoList = TodoList(self.todoFileLocation);
     self.ind = self._get_indicator()
     self.menu = self._create_menu()
     self.ind.set_menu(self.menu)
     if silent == False:
         self.todoList.print_stats()
예제 #3
0
def read_data_from_file():
    '''read data file and dispatch into dictionary'''
    todoFile = open(get_todo_path(), 'r')
    allTodos = todoFile.readlines()
    todoFile.close()
    todoList = TodoList(allTodos)
    return todoList
예제 #4
0
    def build(self):
        self.root = Accordion(min_space=30)

        self.overviewItem = AccordionItem(title=unichr(252) + 'bersicht')
        self.overview = Overview()
        self.overviewItem.add_widget(self.overview)
        #self.closeButton = Button(text = 'Beenden', size=(100, 50), size_hint=(None, None), background_color=[1,0,0,1])
        #self.closeButton.bind(on_press=self.closeApp)
        #self.overviewItem.add_widget(self.closeButton)
        self.root.add_widget(self.overviewItem)

        self.scheduleItem = AccordionItem(title='Stundenplan')
        self.schedule = Schedule()
        self.scheduleItem.add_widget(self.schedule)
        self.root.add_widget(self.scheduleItem)

        self.appointmentsItem = AccordionItem(title='Termine')
        self.appointments = Appointments()
        self.appointmentsItem.add_widget(self.appointments)
        self.root.add_widget(self.appointmentsItem)

        self.todoListItem = AccordionItem(title='Haushalts-Abenteuer')
        self.todoList = TodoList()
        self.todoListItem.add_widget(self.todoList)
        self.root.add_widget(self.todoListItem)

        self.newsItem = AccordionItem(title='Nachrichten')
        self.news = Feeds()
        self.newsItem.add_widget(self.news)
        self.root.add_widget(self.newsItem)

        self.pictureItem = AccordionItem(title='Bilder')
        self.pictureFrame = PictureFrame()
        self.pictureItem.add_widget(self.pictureFrame)
        self.root.add_widget(self.pictureItem)

        self.scheduleItem.collapse = False

        self.ledClock = LedMatrix()

        # initial weather data
        self.overview.updateWeather()
        # continuous updates
        EACH_SECOND = 1
        ONE_MINUTE = 60
        FOUR_HOURS = 14400
        Clock.schedule_interval(self.__updateLedClock, EACH_SECOND)
        Clock.schedule_interval(self.__updateItems, ONE_MINUTE)
        Clock.schedule_interval(self.__updateWeather, FOUR_HOURS)

        return self.root
예제 #5
0
def __initList():
    admin = User.query.filter_by(id=1).first()
    todoList = TodoList(name='Test List', user=admin)
    db.session.add(todoList)
    db.session.commit()
예제 #6
0
#/usr/bin/env python
from todo import Todo
from todoList import TodoList
from todoIndicator import TodoIndicator
#import os

todoVar = "TODO_DIR_PYTHON"

def get_todo_path():
    '''todo'''
    # return os.environ['TODO_DIR_PYTHON'] + "/todo.txt"
    # return "files/play.txt"
    return "/data/Dropbox/todo/todo.txt"
    
def read_data_from_file():
    '''read data file and dispatch into dictionary'''
    todoFile = open(get_todo_path(), 'r')
    allTodos = todoFile.readlines()
    todoFile.close()
    todoList = TodoList(allTodos)
    return todoList

if __name__ == "__main__":
    todoList = TodoList(get_todo_path())
    todoList.print_stats()
    todoList.print_as_dictionary()
    app = TodoIndicator(todoList)
    app.main()
예제 #7
0
 def testFilterForNothing(self):
     todoList = TodoList(self.knownValues[0])
     self.assertEqual(len(todoList.getAsDictionary()['new']), self.knownValues[1])
예제 #8
0
class TodoIndicator:
    '''
    GTK indicator that integrates in Unity.

    Example usage: ./todoIndicator.py TODO_FILE_LOCATION

    If no value for TODO_FILE_LOCATION is provided, a file named 'todo.txt' will be
    loaded from the directory specified in the environment variable TODO_DIR. If this
    variable does not exist, the file will be loaded from a hard coded default location.
    '''
    def __init__(self, todoFileLocation):
        self.todoFileLocation = todoFileLocation
        gobject.timeout_add(10, self._refresh_all, False)

    def _refresh_all(self, silent = True):
        self.todoList = TodoList(self.todoFileLocation);
        self.ind = self._get_indicator()
        self.menu = self._create_menu()
        self.ind.set_menu(self.menu)
        if silent == False:
            self.todoList.print_stats()

    def _get_indicator(self):
        result = appindicator.Indicator("todo", "todo", appindicator.CATEGORY_APPLICATION_STATUS)
        result.set_status (appindicator.STATUS_ACTIVE)
        result.set_icon(os.path.dirname(os.path.realpath(__file__)) + os.path.sep + "todo.png")
        return result

    def _create_menu(self):
        menu = gtk.Menu()
        # update
        item = gtk.MenuItem('Update now')
        item.connect("activate", self._update_all, None)
        menu.append(item)
        # open file
        item = gtk.MenuItem('Edit todo.txt')
        item.connect("activate", self._open_file, 1)
        menu.append(item)
        menu.append(gtk.SeparatorMenuItem())
        menu = self._append_overview_menu(menu)
        menu = self._append_project_menu(menu)
        menu = self._append_context_menu(menu)
        menu = self._append_malformed_menu(menu)
        # quit
        item = gtk.MenuItem('Quit')
        item.connect("activate", self._quit, None)
        menu.append(item)
        menu.show_all()
        return menu

    def _append_overview_menu(self, menu):
        dict = self.todoList.get_as_dictionary()
        for category in dict.keys():
            catLength = len(dict[category])
            menuItem = gtk.MenuItem("=== %s === (%s)" % (category, catLength))
            menuItem.set_sensitive(catLength > 0)
            if catLength > 0:
                subMenu = gtk.Menu()
                for item in sorted(dict[category], key=lambda index : index.get_sort_key()):
                    subMenu.append(self._get_menu_item_from_todo(item))
                menuItem.set_submenu(subMenu)
            menu.append(menuItem)
        menu.append(gtk.SeparatorMenuItem())
        return menu

    def _append_project_menu(self, menu):
        for project in sorted(self.todoList.projects, key = self.todoList.openTodosForProject, reverse = True):
            dict = self.todoList.get_as_dictionary(project = project)
            menuItem = gtk.MenuItem("+%s (%s)" % (project, self.todoList.openTodosForProject(project)))
            menuItem.set_submenu(self._create_submenu(dict))
            menu.append(menuItem)
        menu.append(gtk.SeparatorMenuItem())
        return menu

    def _append_context_menu(self, menu):
        for context in sorted(self.todoList.contexts, key = self.todoList.openTodosForContext, reverse = True):
            dict = self.todoList.get_as_dictionary(context = context)
            menuItem = gtk.MenuItem("@%s (%s)" % (context, self.todoList.openTodosForContext(context)))
            menuItem.set_submenu(self._create_submenu(dict))
            menu.append(menuItem)
        menu.append(gtk.SeparatorMenuItem())
        return menu

    def _append_malformed_menu(self, menu):
        malformed = []
        for todo in self.todoList.todos:
            if todo.isMalformed == True:
                malformed.append(gtk.MenuItem("%s - %s" % (todo.index, todo.todoString)))
        if len(malformed) > 0:
            item = gtk.MenuItem("malformed (%s)" % (len(malformed)))
            subMenu = gtk.Menu()
            for malItem in malformed:
                subMenu.append(malItem)
            item.set_submenu(subMenu)
            menu.append(item)
            menu.append(gtk.SeparatorMenuItem())
        return menu

    def _create_submenu(self, dict):
        result = gtk.Menu()
        for category in dict.keys():
            menuItem = gtk.MenuItem("=== %s === (%s)" % (category, len(dict[category])))
            menuItem.set_sensitive(False)
            result.append(menuItem)
            for item in sorted(dict[category], key=lambda index : index.get_sort_key()):
                result.append(self._get_menu_item_from_todo(item))
        return result

    def _get_menu_item_from_todo(self, todo):
        result = gtk.MenuItem(todo.get_print_string())
        result.connect("activate", self._open_file, todo.index)
        return result

    def _update_all(self, *args):
        print "updating..."
        self._refresh_all(False)

    def _open_file(self, *args):
        print "opening editor..."
        Popen(["gvim", "+%s" % (args[1]), self.todoFileLocation], stdin=open(os.devnull, 'r'))

    def _quit(self, *args):
        print "bye..."
        gtk.main_quit()

    def main(self):
        gtk.main()
예제 #9
0
 def testFilterForNothing(self):
     todoList = TodoList(self.knownValues[0])
     self.assertEqual(len(todoList.getAsDictionary()['new']),
                      self.knownValues[1])
예제 #10
0
 def testFilterForNothing(self):
     todoList = TodoList(self.knownValues)
     print todoList.projects
     self.assertEqual(len(todoList.projects), 2)
     self.assertEqual(len(todoList.contexts), 2)
예제 #11
0
class TodoIndicator:
    '''
    GTK indicator that integrates in unity.
    '''
    def __init__(self, todoFileLocation = ""):
        print "initializing..."
        self.todoFileLocation = self._getFileLocation(todoFileLocation)
        gobject.timeout_add(10, self._refresh_all, False)
        
    def _getFileLocation(self, todoFileLocation):
        if todoFileLocation == "":
            todoFileLocation = os.environ['TODO_DIR'] + "/todo.txt"
        return todoFileLocation
        
    def _refresh_all(self, silent = True):
        self.todoList = TodoList(self.todoFileLocation);
        self.ind = self._get_indicator()
        self.menu = self._create_menu()
        self.ind.set_menu(self.menu)
        if silent == False:
            self.todoList.print_stats()
        #gobject.timeout_add(10000, self._refresh_all)
        
    def _get_indicator(self):
        result = appindicator.Indicator("todo", "todo", appindicator.CATEGORY_APPLICATION_STATUS)
        result.set_status (appindicator.STATUS_ACTIVE)
        result.set_icon(os.path.dirname(os.path.realpath(__file__)) + os.path.sep + "todo.png")
        return result
            
    def _create_menu(self):
        menu = gtk.Menu()
        # update 
        item = gtk.MenuItem('Update now')
        item.connect("activate", self._update_all, None)
        menu.append(item)
        # open file
        item = gtk.MenuItem('Edit todo.txt')
        item.connect("activate", self._open_file, None)
        menu.append(item)
        menu.append(gtk.SeparatorMenuItem())
        menu = self._append_overview_menu(menu)
        menu = self._append_project_menu(menu)
        menu = self._append_context_menu(menu)
        menu = self._append_malformed_menu(menu)
        # quit
        item = gtk.MenuItem('Quit')
        item.connect("activate", self._quit, None)
        menu.append(item)
        
        menu.show_all()
        return menu
    
    def _append_overview_menu(self, menu):
        dict = self.todoList.get_as_dictionary()
        for category in dict.keys():
            catLength = len(dict[category])
            menuItem = gtk.MenuItem("=== %s === (%s)" % (category, catLength))
            menuItem.set_sensitive(catLength > 0)
            if catLength > 0: 
                subMenu = gtk.Menu()
                for item in sorted(dict[category], key=lambda index : index.get_sort_key()):
                    subMenu.append(self._get_menu_item_from_todo(item))
                menuItem.set_submenu(subMenu)
            menu.append(menuItem)
        menu.append(gtk.SeparatorMenuItem())
        return menu

    def _append_project_menu(self, menu):
        for project in self.todoList.projects:
            dict = self.todoList.get_as_dictionary(project = project)
            item = gtk.MenuItem("+%s (%s)" % (project, sum(len(dict[lst]) for lst in dict.keys())))
            item.set_submenu(self._create_submenu(dict))
            menu.append(item)
        menu.append(gtk.SeparatorMenuItem())
        return menu
            
    def _append_context_menu(self, menu):
        for context in self.todoList.contexts:
            dict = self.todoList.get_as_dictionary(context = context)
            item = gtk.MenuItem("@%s (%s)" % (context, sum(len(dict[lst]) for lst in dict.keys())))
            item.set_submenu(self._create_submenu(dict))
            menu.append(item)
        menu.append(gtk.SeparatorMenuItem())
        return menu

    def _append_malformed_menu(self, menu):
        malformed = []
        for todo in self.todoList.todos:
            if todo.isMalformed == True:
                malformed.append(gtk.MenuItem("%s - %s" % (todo.index, todo.todoString)))
        if len(malformed) > 0:
            item = gtk.MenuItem("malformed (%s)" % (len(malformed)))
            subMenu = gtk.Menu()
            for malItem in malformed:            
                subMenu.append(malItem)
            item.set_submenu(subMenu)
            menu.append(item)    
            menu.append(gtk.SeparatorMenuItem())
        return menu
    
    def _create_submenu(self, dict):
        result = gtk.Menu()
        for category in dict.keys():
            menuItem = gtk.MenuItem("=== %s === (%s)" % (category, len(dict[category])))
            menuItem.set_sensitive(False)
            result.append(menuItem)
            for item in sorted(dict[category], key=lambda index : index.get_sort_key()):
                result.append(self._get_menu_item_from_todo(item))
        return result
    
    def _get_menu_item_from_todo(self, todo):
        result = gtk.MenuItem(todo.get_print_string())
        result.connect("activate", self._open_file, todo.index)
        return result
    
    def _update_all(self, *args):
        print "updating..."
        self._refresh_all(False)
    
    def _open_file(self, *args):
        print "opening editor..."
        Popen(["gedit", self.todoFileLocation, "+%s" % (args[1])])
    
    def _quit(self, *args):
        print "bye..."
        gtk.main_quit()
        
    def main(self):
        gtk.main()
예제 #12
0
from todo import Todo
from todoList import TodoList
from todoIndicator import TodoIndicator
#import os

todoVar = "TODO_DIR_PYTHON"


def get_todo_path():
    '''todo'''
    # return os.environ['TODO_DIR_PYTHON'] + "/todo.txt"
    # return "files/play.txt"
    return "/data/Dropbox/todo/todo.txt"


def read_data_from_file():
    '''read data file and dispatch into dictionary'''
    todoFile = open(get_todo_path(), 'r')
    allTodos = todoFile.readlines()
    todoFile.close()
    todoList = TodoList(allTodos)
    return todoList


if __name__ == "__main__":
    todoList = TodoList(get_todo_path())
    todoList.print_stats()
    todoList.print_as_dictionary()
    app = TodoIndicator(todoList)
    app.main()