Skip to content

Commit

Permalink
Write PNGs to the same directory as the dot files.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrfonseca committed Nov 23, 2024
1 parent 9cae853 commit ac613fc
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ def test(arg):

class TestDotWidget(DotWidget):

def __init__(self, name):
def __init__(self, filename):
DotWidget.__init__(self)

self.dirname, basename = os.path.split(filename)

name, ext = os.path.splitext(basename)
self.name = name

def on_draw(self, widget, cr):
Expand Down Expand Up @@ -82,7 +86,7 @@ def on_draw(self, widget, cr):

self.graph.draw(cr, highlight_items=self.highlight)

surface.write_to_png(self.name + '.png')
surface.write_to_png(os.path.join(self.dirname, self.name + '.png'))

if False:
# GTK 3 screenshot
Expand All @@ -94,7 +98,7 @@ def on_draw(self, widget, cr):

pixbuf = Gdk.pixbuf_get_from_window(window, 0, 0, w, h)

pixbuf.savev(self.name + '.png', 'png', (), ())
pixbuf.savev(os.path.join(self.dirname, self.name + '.png'), 'png', (), ())

Gtk.main_quit()

Expand All @@ -105,8 +109,7 @@ def error_dialog(self, message):

result = True

name, ext = os.path.splitext(os.path.basename(arg))
widget = TestDotWidget(name)
widget = TestDotWidget(arg)
window = DotWindow(widget)
window.connect('delete-event', Gtk.main_quit)
try:
Expand Down

0 comments on commit ac613fc

Please sign in to comment.