import sys, os import gtk class TutorialStoreSuggestion(gtk.HBox): def __init__(self,controller): gtk.HBox.__init__(self,homogeneous=True, spacing=5) self.controller = controller self.popular = gtk.VBox(homogeneous=True, spacing=0) self.popular_frame = gtk.Frame('Most Popular') #top_five.pack_start(tutorial1_frame, expand=True, fill=True, padding=0) #top_five.pack_start(tutorial2_frame, expand=True, fill=True, padding=0) #top_five.pack_start(tutorial3_frame, expand=True, fill=True, padding=0) self.also_like = gtk.VBox(homogeneous=True, spacing=0) self.also_like_frame = gtk.Frame('You might also like :') #also_like.pack_start(tutorial4_frame, expand=True, fill=True, padding=0) #also_like.pack_start(tutorial5_frame, expand=True, fill=True, padding=0) #also_like.pack_start(tutorial6_frame, expand=True, fill=True, padding=0) self.popular_frame.add(self.popular) self.also_like_frame.add(self.also_like) self.popular.show() self.popular_frame.show() self.also_like.show() self.also_like_frame.show() self.pack_start(self.popular_frame) self.pack_start(self.also_like_frame) def set_popular(self,tutorials): for child in self.popular.get_children(): self.popular.remove(child) if len(tutorials)> 3: for x in range(0,3): item = SuggestionListItem(self.controller,tutorials[x]) self.popular.pack_start(item) item.show() else: for x in tutorials: item = SuggestionListItem(self.controller,x) self.popular.pack_start(item) item.show() def set_also_like(self,tutorials): for child in self.also_like.get_children(): self.also_like.remove(child) if len(tutorials)> 3: for x in range(0,3): item = SuggestionListItem(self.controller,tutorials[x]) self.also_like.pack_start(item) item.show() else: for x in tutorials: item = SuggestionListItem(self.controller,x) self.also_like.pack_start(item) item.show() class SuggestionListItem(gtk.Frame): def __init__(self,controller,tutorial): gtk.Frame.__init__(self) self.container = gtk.HBox() self.label = gtk.Label(tutorial.name) self.icon = gtk.Image() self.icon.set_from_file('icon.svg') self.button = gtk.Button("More") self.container.pack_start(icon5, expand=True, fill=True, padding=4) self.container.pack_start(label5, expand=True, fill=True, padding=0) self.container.pack_start(more_button5, expand=False, fill=False, padding=5) self.add(self.container) #tutorial5_frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0,0,0)) self.container.show_all()