I have just started scripting python
and UNO
components with a long term goal to make LibreOffice
UI Extensions. Creating dialogs seems to work (it appears in LibreOffice).
However, I can’t set position or size or anything for the buttons, labels or other content of the dialog.
I got the error message AttributeError: ### where ### is the aspect I would like to change. This below code would throw AttributeError: PositionX
.
Script Excerpt:
#Creating dialog: This works
control_container = service_manager.createInstanceWithContext(
"com.sun.star.awt.UnoControlDialog", context);
dialog_model = service_manager.createInstanceWithContext(
"com.sun.star.awt.UnoControlDialogModel", context)
dialog_model.PositionX = 100
dialog_model.PositionY = 100
dialog_model.Width = 200
dialog_model.Height = 200
dialog_model.BackgroundColor = 10020050 #rgb=(100,200,50
dialog_model.Title = "Runtime Dialog Demo"
dialog_model.Sizeable = 0
control_container.setModel(dialog_model); #Adds this model to the control container.
control_container.setVisible(False);
control_container.createPeer(toolkit, None);
#Adding button: This does not work
ok_button_container = service_manager.createInstanceWithContext(
"com.sun.star.awt.UnoControlButton", context);
ok_button_model = service_manager.createInstanceWithContext(
"com.sun.star.awt.UnoControlButtonModel", context)
ok_button_model.PositionX = 50 <- THROWS ERROR
#ok_button_model.PositionY = 30
#ok_button_model.Size = [50,14];
#ok_button_model.Size.Height = 14;
#ok_button_model.Name = "button_id";
#ok_button_model.TabIndex = 0;
#ok_button_model.Label = "Ok";
#ok_button_container.setModel(ok_button_model);
#ok_button_container.setVisible(False);