Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Workshop.activity/TutorialStoreSearch.py
blob: 9007599ef0618f9495b1eb5435bd85f0e4359b02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Copyright (C) 2009, Tutorius.org
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
import sys, os
import gtk

class TutorialStoreSearch(gtk.HBox):

    def __init__(self,controller):
        gtk.HBox.__init__(self,False, 5)
        self.controller = controller
        search_label = gtk.Label('Search :')
        self.search_box = gtk.Entry(400)
        in_label = gtk.Label('in')
        self.search_combobox = gtk.combo_box_new_text()
        self.search_button = gtk.Button('Search')
        
        self.pack_start(search_label, True, True, 5)
        self.pack_start(self.search_box, True, True, 5)
        self.pack_start(in_label, True, True, 5)
        self.pack_start(self.search_combobox, True, True, 5)
        self.pack_start(self.search_button, True, True, 5)
        
        search_label.show()
        self.search_box.show()
        in_label.show()
        self.search_combobox.show()
        self.search_button.show()
        
        self.search_button.connect("clicked",self.controller.search_store,{'keyword':self.search_box,
        'category':self.search_combobox})
        
    def set_categories(self,categories):
        self.search_combobox.set_active(0)
        while self.search_combobox.get_active_text() is not None:
            self.search_combobox.remove_text(0)
            self.search_combobox.set_active(0)
        
        for category in categories:
            self.search_combobox.append_text(category)