[dia] python: launch generate file in browser
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] python: launch generate file in browser
- Date: Fri, 27 Sep 2019 12:01:13 +0000 (UTC)
commit a6a38b53f876121962e804ff5e6d5efb43f516bb
Author: Zander Brown <zbrown gnome org>
Date: Fri Sep 27 13:01:02 2019 +0100
python: launch generate file in browser
plug-ins/python/allsheets.py | 5 ++++-
plug-ins/python/pydiadoc.py | 26 ++++++++++++++------------
2 files changed, 18 insertions(+), 13 deletions(-)
---
diff --git a/plug-ins/python/allsheets.py b/plug-ins/python/allsheets.py
index a50fcedd..99e3c907 100644
--- a/plug-ins/python/allsheets.py
+++ b/plug-ins/python/allsheets.py
@@ -18,6 +18,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import dia, os, string
+import tempfile
+import webbrowser
# Given a list of "sheet objects" return the common namespace of the object types
def so_get_namespace (sol) :
@@ -59,7 +61,7 @@ def check_objecttype_overlap (sheets) :
def isheets_cb (data, flags) :
sheets = dia.registered_sheets ()
check_objecttype_overlap (sheets)
- path = os.environ["TEMP"] + os.path.sep + "dia-sheets.html"
+ path = tempfile.gettempdir() + os.path.sep + "dia-sheets.html"
f = open (path, "w")
f.write ("""
<html><head><title>Dia Sheets</title></head><body>
@@ -75,6 +77,7 @@ def isheets_cb (data, flags) :
</body></html>
""")
dia.message(0, "'" + path + "' saved.")
+ webbrowser.open('file://' + os.path.realpath(path))
dia.register_action ("HelpInspectSheets", "Dia Sheets Inspection",
"/ToolboxMenu/Help/HelpExtensionStart",
diff --git a/plug-ins/python/pydiadoc.py b/plug-ins/python/pydiadoc.py
index dd2b7e33..565fbf6e 100644
--- a/plug-ins/python/pydiadoc.py
+++ b/plug-ins/python/pydiadoc.py
@@ -28,7 +28,7 @@ def distribute_objects (objs) :
for o in objs :
if width < o.properties["elem_width"].value :
width = o.properties["elem_width"].value
- if height < o.properties["elem_height"].value :
+ if height < o.properties["elem_height"].value :
height = o.properties["elem_height"].value
# add 20 % 'distance'
width *= 1.2
@@ -81,8 +81,8 @@ def autodoc_cb (data, flags, update) :
display = None
layer = data.active_layer
- oType = dia.get_object_type ("UML - Class")
-
+ oType = dia.get_object_type ("UML - Class")
+
theDir = dir(dia)
# for reflection we need some objects ...
theObjects = [data, layer, oType]
@@ -90,14 +90,14 @@ def autodoc_cb (data, flags, update) :
theObjects.append (data.paper)
except AttributeError :
pass # no reason to fail with new bindings
- if diagram :
+ if diagram :
theObjects.append (diagram)
- if display :
+ if display :
theObjects.append (display)
# add some objects with interesting properties
#theObjects.append(dia.DiaImage())
once = 1
- for s in ["Standard - Image", "Standard - BezierLine", "Standard - Text",
+ for s in ["Standard - Image", "Standard - BezierLine", "Standard - Text",
"UML - Class", "UML - Dependency"] :
o, h1, h2 = dia.get_object_type(s).create(0,0)
for p in o.properties.keys() :
@@ -247,6 +247,7 @@ def autodoc_cb (data, flags, update) :
def autodoc_html_cb (data, flags) :
import pydoc
import os
+ import webbrowser
try :
path = os.environ["TEMP"]
except KeyError :
@@ -255,13 +256,14 @@ def autodoc_html_cb (data, flags) :
os.chdir(path)
pydoc.writedoc(dia)
dia.message(0, path + os.path.sep + "dia.html saved.")
+ webbrowser.open('file://' + os.path.realpath(path + os.path.sep + "dia.html"))
-dia.register_action ("HelpPydia2", "PyDia HTML Docs",
- "/ToolboxMenu/Help/HelpExtensionStart",
+dia.register_action ("HelpPydia2", "PyDia HTML Docs",
+ "/ToolboxMenu/Help/HelpExtensionStart",
autodoc_html_cb)
-dia.register_action ("HelpPydia", "PyDia Docs",
- "/ToolboxMenu/Help/HelpExtensionStart",
+dia.register_action ("HelpPydia", "PyDia Docs",
+ "/ToolboxMenu/Help/HelpExtensionStart",
autodoc_fresh_cb)
-dia.register_action ("UpdatePydia", "PyDia Docs Update",
- "/DisplayMenu/Help/HelpExtensionStart",
+dia.register_action ("UpdatePydia", "PyDia Docs Update",
+ "/DisplayMenu/Help/HelpExtensionStart",
autodoc_update_cb)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]