def create_combo_entry(self, label_content, entry_content=""): vbox = gtk.VBox() vbox.set_spacing(5) label = Label(label_content) text_entry = TextEntry(entry_content) text_entry.set_size(198, 26) entry_box = set_widget_center(text_entry) vbox.pack_start(label, False, False) vbox.pack_start(entry_box, False, False) return vbox, text_entry
class SongSearchUI(DialogBox): def __init__(self): DialogBox.__init__(self, _("Search"), 460, 300, DIALOG_MASK_SINGLE_PAGE, modal=False, window_hint=None, close_callback=self.hide_all) title_label = Label(_("Title:")) self.title_entry = TextEntry("") self.title_entry.set_size(300, 25) self.search_button = Button(_("Search")) self.search_button.connect("clicked", self.search_song) control_box = gtk.HBox(spacing=5) control_box.pack_start(title_label, False, False) control_box.pack_start(self.title_entry, False, False) control_box.pack_start(self.search_button, False, False) scrolled_window = ScrolledWindow(0, 0) scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.result_view = ListView() self.result_view.connect("double-click-item", self.double_click_cb) self.result_view.draw_mask = self.get_mask_func(self.result_view) self.result_view.add_titles([_("Title"), _("Artist"), _("Album"), _("Type"), _("Size")]) scrolled_window.add_child(self.result_view) self.prompt_label = Label("") download_button = Button(_("Download")) download_button.connect("clicked", self.download_song) cancel_button = Button(_("Close")) cancel_button.connect("clicked", lambda w: self.hide_all()) self.body_box.set_spacing(5) self.body_box.pack_start(control_box, False, False) self.body_box.pack_start(scrolled_window, True, True) self.left_button_box.set_buttons([self.prompt_label]) self.right_button_box.set_buttons([download_button, cancel_button]) def search_song(self, widget): self.result_view.clear() title = self.title_entry.entry.get_text() if not title.strip(): return self.prompt_label.set_text(_("Now searching")) # widget.set_sensitive(False) utils.ThreadRun(multi_ways_query_song, self.render_song_infos, [title]).start() @post_gui def render_song_infos(self, song_infos): if song_infos: try: items = [QueryInfoItem(song_info) for song_info in song_infos] except Exception, e: print e else: self.result_view.add_items(items) self.prompt_label.set_text(_("Finish!"))
def __init__(self): DialogBox.__init__(self, _("Search"), 460, 300, DIALOG_MASK_SINGLE_PAGE, modal=False, window_hint=None, close_callback=self.hide_all) title_label = Label(_("Title:")) self.title_entry = TextEntry("") self.title_entry.set_size(300, 25) self.search_button = Button(_("Search")) self.search_button.connect("clicked", self.search_song) control_box = gtk.HBox(spacing=5) control_box.pack_start(title_label, False, False) control_box.pack_start(self.title_entry, False, False) control_box.pack_start(self.search_button, False, False) scrolled_window = ScrolledWindow(0, 0) scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) self.result_view = ListView() self.result_view.connect("double-click-item", self.double_click_cb) self.result_view.draw_mask = self.get_mask_func(self.result_view) self.result_view.add_titles([_("Title"), _("Artist"), _("Album"), _("Type"), _("Size")]) scrolled_window.add_child(self.result_view) self.prompt_label = Label("") download_button = Button(_("Download")) download_button.connect("clicked", self.download_song) cancel_button = Button(_("Close")) cancel_button.connect("clicked", lambda w: self.hide_all()) self.body_box.set_spacing(5) self.body_box.pack_start(control_box, False, False) self.body_box.pack_start(scrolled_window, True, True) self.left_button_box.set_buttons([self.prompt_label]) self.right_button_box.set_buttons([download_button, cancel_button])