Exemple #1
0
class TaskViewer(gtk.Window):
    def __init__(self):
        gtk.Window.__init__(self)
        self.set_title('Tasks')
        self.search = SearchContainer(self.get_columns())
        self.add(self.search)
        self._setup_searching()
        self._create_filters()

    def _setup_searching(self):
        self.query = SQLAlchemyQueryExecuter(session)
        self.search.set_query_executer(self.query)
        self.query.set_table(Task)

    def _create_filters(self):
        categories = [(c.name, c.id) for c in session.query(Category).select()]
        categories.insert(0, ('Any', None))
        self.category_filter = ComboSearchFilter(
            'Category:', categories)
        self.search.add_filter(
            self.category_filter,
            SearchFilterPosition.TOP, ['id'])

        self.search.set_text_field_columns(['title'])
        self.search.add_filter(DateSearchFilter('Date:'),
                               columns=['date'])

    def get_columns(self):
        return [
            Column('title', data_type=str, title='Title',
                   expand=True),
            Column('category.name', title='Category'),
            Column('date', data_type=datetime.date, width=90)
            ]
Exemple #2
0
 def _setup_searching(self):
     self.query = SQLAlchemyQueryExecuter(session)
     self.search.set_query_executer(self.query)
     self.query.set_table(Task)