def load(self, persp):
        self.persp = persp
        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.tv = Gtk.TreeView()

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_("Title"), renderer, text=1)
        self.tv.append_column(column)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_("Source"), renderer, text=2)
        self.tv.append_column(column)

        renderer = Gtk.CellRendererProgress()
        column = Gtk.TreeViewColumn(_("Progress"), renderer, text=3, value=4)
        column.set_expand(True)
        self.tv.append_column(column)

        renderer = Gtk.CellRendererPixbuf()
        column = Gtk.TreeViewColumn(_("Reset"), renderer, icon_name=5)
        column.set_name(COLUMN_ROW_RESET)
        self.tv.append_column(column)

        self.tv.connect("row-activated", self.row_activated)

        def on_progress_updated(solving_progress, key, progress):
            for i, row in enumerate(self.store):
                if row[0] == key:
                    progress_ratio_string, percent, reset_icon = self._compute_progress_info(progress)
                    treeiter = self.store.get_iter(Gtk.TreePath(i))
                    self.store[treeiter][3] = progress_ratio_string
                    self.store[treeiter][4] = percent
                    self.store[treeiter][5] = reset_icon
        puzzles_solving_progress.connect("progress_updated", on_progress_updated)

        self.store = Gtk.ListStore(str, str, str, str, int, str)

        @asyncio.coroutine
        def coro():
            for file_name, title, author in PUZZLES:
                progress = puzzles_solving_progress.get(file_name)
                progress_ratio_string, percent, reset_icon = self._compute_progress_info(progress)
                self.store.append([file_name, title, author, progress_ratio_string, percent, reset_icon])
                yield from asyncio.sleep(0)
        create_task(coro())

        self.tv.set_model(self.store)
        self.tv.get_selection().set_mode(Gtk.SelectionMode.BROWSE)
        self.tv.set_cursor(conf.get("learncombo%s" % PUZZLE))

        scrollwin = Gtk.ScrolledWindow()
        scrollwin.add(self.tv)
        scrollwin.show_all()

        self.box.pack_start(scrollwin, True, True, 0)
        self.box.show_all()

        return self.box
Exemple #2
0
    def load(self, persp):
        self.persp = persp
        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.tv = Gtk.TreeView()

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_("Title"), renderer, text=1)
        self.tv.append_column(column)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_("Source"), renderer, text=2)
        self.tv.append_column(column)

        renderer = Gtk.CellRendererProgress()
        column = Gtk.TreeViewColumn(_("Progress"), renderer, text=3, value=4)
        self.tv.append_column(column)

        self.tv.connect("row-activated", self.row_activated)

        def on_progress_updated(solving_progress, key, progress):
            for i, row in enumerate(self.store):
                if row[0] == key:
                    solved = progress.count(1)
                    percent = 0 if not solved else round(
                        (solved * 100.) / len(progress))
                    treeiter = self.store.get_iter(Gtk.TreePath(i))
                    self.store[treeiter][3] = "%s / %s" % (solved,
                                                           len(progress))
                    self.store[treeiter][4] = percent

        puzzles_solving_progress.connect("progress_updated",
                                         on_progress_updated)

        self.store = Gtk.ListStore(str, str, str, str, int)

        for file_name, title, author in PUZZLES:
            progress = puzzles_solving_progress.get(file_name)
            solved = progress.count(1)
            percent = 0 if not solved else round(
                (solved * 100.) / len(progress))
            self.store.append([
                file_name, title, author,
                "%s / %s" % (solved, len(progress)), percent
            ])

        self.tv.set_model(self.store)
        self.tv.get_selection().set_mode(Gtk.SelectionMode.BROWSE)
        self.tv.set_cursor(0)

        scrollwin = Gtk.ScrolledWindow()
        scrollwin.add(self.tv)
        scrollwin.show_all()

        self.box.pack_start(scrollwin, True, True, 0)
        self.box.show_all()

        return self.box
Exemple #3
0
    def load(self, persp):
        self.persp = persp
        self.box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)

        self.tv = Gtk.TreeView()

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_("Title"), renderer, text=1)
        self.tv.append_column(column)

        renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn(_("Source"), renderer, text=2)
        self.tv.append_column(column)

        renderer = Gtk.CellRendererProgress()
        column = Gtk.TreeViewColumn(_("Progress"), renderer, text=3, value=4)
        self.tv.append_column(column)

        self.tv.connect("row-activated", self.row_activated)

        def on_progress_updated(solving_progress, key, progress):
            for i, row in enumerate(self.store):
                if row[0] == key:
                    solved = progress.count(1)
                    percent = 0 if not solved else round((solved * 100.) / len(progress))
                    treeiter = self.store.get_iter(Gtk.TreePath(i))
                    self.store[treeiter][3] = "%s / %s" % (solved, len(progress))
                    self.store[treeiter][4] = percent
        puzzles_solving_progress.connect("progress_updated", on_progress_updated)

        self.store = Gtk.ListStore(str, str, str, str, int)

        @asyncio.coroutine
        def coro():
            for file_name, title, author in PUZZLES:
                progress = puzzles_solving_progress.get(file_name)
                solved = progress.count(1)
                percent = 0 if not solved else round((solved * 100.) / len(progress))
                self.store.append([file_name, title, author, "%s / %s" % (solved, len(progress)), percent])
                yield from asyncio.sleep(0)
        create_task(coro())

        self.tv.set_model(self.store)
        self.tv.get_selection().set_mode(Gtk.SelectionMode.BROWSE)
        self.tv.set_cursor(conf.get("learncombo%s" % PUZZLE))

        scrollwin = Gtk.ScrolledWindow()
        scrollwin.add(self.tv)
        scrollwin.show_all()

        self.box.pack_start(scrollwin, True, True, 0)
        self.box.show_all()

        return self.box