File: debug_objects.py

package info (click to toggle)
dia 0.98%2Bgit20250126-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 52,072 kB
  • sloc: ansic: 155,381; xml: 14,056; python: 6,250; cpp: 3,598; sh: 439; perl: 137; makefile: 25
file content (36 lines) | stat: -rw-r--r-- 1,102 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import sys, dia

import gettext
_ = gettext.gettext

# sys.path.insert(0, 'd:/graph/dia/dia')

def dia_debug_cb (data, flags) :
	"gets passed in the active diagram, flags are unused at the moment"
	for layer in data.layers :
		print("Layer :", layer.name)
		for o in layer.objects :
			print(str(o), str(o.bounding_box))

def dia_debug_props_cb (data, flags) :
	for layer in data.layers :
		print("Layer :", layer.name)
		for o in layer.objects :
			print(str(o))
			props = o.properties
			for s in list(props.keys()) :
				print(props[s].type + " " + s + " (visible=%d)" % props[s].visible)
				try :
					p = props[s].value
				except :
					p = None
				print("\t" + str(p))

# dia-python keeps a reference to the renderer class and uses it on demand
dia.register_action ("DebugBoundingbox", _("Dia _BoundingBox Debugger"),
                     "/DisplayMenu/Debug/DebugExtensionStart",
                     dia_debug_cb)

dia.register_action ("DebugProperty", _("Dia _Property API Debugger"),
                     "/DisplayMenu/Debug/DebugExtensionStart",
                     dia_debug_props_cb)