Beispiel #1
0
    def create_snippet_list(self):
        sw = Gtk.ScrolledWindow()
        sw.set_property('shadow-type', Gtk.ShadowType.IN)
        sw.set_policy(hscrollbar_policy=Gtk.PolicyType.NEVER,
                      vscrollbar_policy=Gtk.PolicyType.AUTOMATIC)

        snippets = get_snippets()
        model = Gtk.ListStore(str, object)
        for name, s in snippets.items():
            model.append(row=(name, s))

        tree_view = Gtk.TreeView(model)
        sw.add(tree_view)
        tree_view.set_property('headers-visible', False)
        tree_view.set_property('search-column', 0)
        tree_view.set_property('rules-hint', False)

        tselection = tree_view.get_selection()
        tselection.connect("changed", self.cb_selection_changed)
        tselection.set_mode(Gtk.SelectionMode.BROWSE)

        cr = Gtk.CellRendererText()
        tvc = Gtk.TreeViewColumn(None, cr, text=0)
        tree_view.append_column(tvc)

        tselection.select_path(0, )  # select first item

        return sw
Beispiel #2
0
    surface = cairo.PSSurface(filename, width_in_points, height_in_points)
    cr = cairo.Context(surface)

    cr.save()
    snippet.draw_func(cr, width, height)
    cr.restore()
    cr.show_page()
    surface.finish()


if __name__ == '__main__':
    if not cairo.HAS_PS_SURFACE:
        raise SystemExit('cairo was not compiled with PS support')

    verbose_mode = True
    if len(sys.argv) > 1 and sys.argv[1] == '-s':
        verbose_mode = False
        del sys.argv[1]

    snippets = get_snippets()

    if len(sys.argv) > 1:
        # do specified snippets
        selected = [snippets[n] for n in sys.argv[1:]]
    else:
        # do all snippets
        selected = snippets.values()

    for s in selected:
        do_snippet(s)
    surface = cairo.SVGSurface(filename, width_in_points, height_in_points)
    cr = cairo.Context(surface)

    cr.save()
    snippet.draw_func(cr, width, height)
    cr.restore()
    cr.show_page()
    surface.finish()


if __name__ == '__main__':
    if not cairo.HAS_SVG_SURFACE:
        raise SystemExit('cairo was not compiled with SVG support')

    verbose_mode = True
    if len(sys.argv) > 1 and sys.argv[1] == '-s':
        verbose_mode = False
        del sys.argv[1]

    snippets = get_snippets()

    if len(sys.argv) > 1:
        # do specified snippets
        selected = [snippets[n] for n in sys.argv[1:]]
    else:
        # do all snippets
        selected = snippets.values()

    for s in selected:
        do_snippet(s)