[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: python plugin and object properties



At 17:01 30.06.01 +0200, Michael Maluck wrote:
>Hi all,
>
>tried to get some object properties of "UML Class" objects in the
>python dia console.
>
>i comiled dia 0.88.1 from source with the --with-python option.
>dia.active_display().diagram.layers[0].properties.get("obj_pos") returns
>always None.
Doesn't it give a runtime-error AttributeError: properties ?

dia.active_display().diagram.layers[0].objects[0].properties['obj_pos'].value

works:

<DiaPoint object at ...>

[Though there are probably Dia objects, which do not support the property
api yet] 
>The has_key method says that the property exists. It is also listed
>in keys().
The main problem is, that the layer object has no properties, because it
isn't a DiaObject as one may expect. The property api is only supported by
most objects within the diagram, like

dia.active_display().diagram.layers[0].objects[0].type
<DiaObjectType 'Standard - Text'>

>i doesn't matter which property i want to get. it doesn't work for all.
>any ideas?
>
There is probably no senseful way to write Dia Extensions in Python without
being able to read and understand the C-Sources

>are there any docs for the python plugin?
NAFAIK. I've attached a small interface description extracted from the
C-Source, no real documentation :(

>is it possible to use the dia api not only in the python dia console?
>
Yes. There are two examples how to write an export filter in Python, but
again I don't think it would be much fun to write one, without being able
to debug or 'investigate the limitations in' the Python-Plugin as well.

The Plugin will probably remain such limited as it is, at least until it
(and first the Dia Object System) is converted to Gtk+2.0 especially the
GObject system, because the current access does not allow to ref-count the
objects, to easily back-propagate property changes, etc. ...

	Hans
dia.active_display()		DiaDisplay
dia.diagrams()			DiaDiagram[n]
dia.get_object_type(string)	DiaObjectType	'name_of_object_type
dia.load(string)						'filename
dia.register_export(string,string,object)		'name,extension,DiaRenderer
dia.register_callback(string,string,function)	'description,menupath,callback(DiaDiagramData,int)
dia.update_all()

DiaArrow
  type		int
  width		double
  length		double

DiaBezPoint
  p1			DiaPoint
  p2			DiaPoint
  p3			DiaPoint

DiaColor
  red			double
  green		double
  blue		double

DiaConnectionPoint
  connected		DiaObject[n]
  object		DiaObject
  pos			double[n]	'(x,y)

DiaDiagram
  raise_layer()
  lower_layer()
  add_layer(string[,int])	DiaLayer	'name, optional poisition
  set_active_layer(DiaLayer)
  delete_layer(DiaLayer)
  select(DiaObject)
  is_selected(DiaObject)	int
  unselect(DiaObject)
  remove_all_selected()
  update_extents()
  get_sorted_selected()		DiaObject[n]
  get_sorted_selected_remove()
  add_update(double,double,double,double)
  add_update_all()
  flush()
  find_clicked_object((double,double),double)	DiaObject '(x,y), distance
  find_closest_handle(double,double)	DiaHandle
  find_closest_connectionpoint(double,double)		(DiaHandle,DiaObject) 'x,y
  group_selected()
  ungroup_selected()
  save([string])	int	'optional filename

DiaDiagramData
  extents		DiaRectangle
  bg_color		DiaColor
  paper		<not implemented>
  grid.width	double[2]
  grid.visible	int[2]
  hguides		double[n]
  vguides		double[n]
  layers		DiaLayer[n]
  active_layer	DiaLayer
  selected		DiaObject[n]

DiaDisplay
  diagram		DiaDiagram
  origin		double[2]	'todo? DiaPoint
  visible		double[4]	'todo? DiaRectangle
  zoom_factor	double
  add_update_all()
  flush()
  set_origion(double,double)
  zoom(double,double,double)	'pt.x, pt.x, factor
  resize_canvas(int,int)	'width, height
  close()
  set_title(string)
  scroll(double,double)		'delta x,y
  scroll_up()
  scroll_down()
  scroll_left()
  scroll_right()

DiaError
  write(object)	'writes obeject as string

DiaExportFilter
  <see export-object.py or export-render.py or pydia-render.c>

DiaFont
  name	string

DiaHandle
  connect_type	int
  connected_to	DiaConnectionPoint
  id			int
  pos			double[2]	'(x,y)
  type		int

DiaImage
  width		int
  height		int
  rgb_data		char[widht*height*3]
  mask_data		char[widht*height]
  filename		string

DiaLayer
  extents		double[4]		'(top,left,bottom,right)
  name		string
  objects		DiaObject[n]
  visible		int

  destroy()
  object_index()	int
  add_object(DiaObject[,int])		'object, optional index 'at'
  remove_object(DiaObject)
  find_objects_in_rectangle(double,double,double,double)	DiaObject	'top,left,right,bottom
  find_closest_object(double,double,double)	DiaObject	'x,y,maxdist
  find_closest_connection_point(double,double)	(double,DiaConnectionPoint) '(distance, cpoint)
  update_extents()

DiaObject
  bounding_box	DiaRectangle
  connections	DiaConnectionPoint[n]
  handles		DiaHandle[n]
  properties	DiaProperties
  type		DiaObjectType

  destroy()
  distance_from(double,double)	double
  copy()		DiaObject
  move(double,double)			'x,y
  move_handle(DiaHandle,(double,double),int,int)	'handle, (point.x, point.y), reason, modifiers

DiaObjectType
  name		string
  version		int

  create(double,double[,int])		(DiaObject,DiaHandle,DiaHandle)	'x,y,optional user_data pointer

DiaPoint
  x			double
  y			double

DiaProperties
  <dictionary interface>

DiaProperty
  name		string
  type		int			'type enumeration
  value		<object>		'as (Dia)Python object

DiaRectangle
  top			<int|double>
  left		<int|double>
  right		<int|double>
  bottom		<int|double>


-------- Hans "at" Breuer "dot" Org -----------
Tell me what you need, and I'll tell you how to 
get along without it.                -- Dilbert


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK