Issue 35199 - Dialog creation with python
Summary: Dialog creation with python
Status: ACCEPTED
Alias: None
Product: udk
Classification: Code
Component: code (show other issues)
Version: OOo 1.1.3
Hardware: All All
: P3 Trivial (vote)
Target Milestone: AOO PleaseHelp
Assignee: AOO issues mailing list
QA Contact:
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-08 13:23 UTC by maison.godard
Modified: 2013-02-07 22:16 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description maison.godard 2004-10-08 13:23:53 UTC
Hi, 
 
as suggested by Joerg B., i open an issue to enable using OOo graphical UI 
dialog outside OOo with python 
 
as stated by Joerg 
"you are trying to execute this code from python executable itself, I guess. I 
just tried this code vs. a 680, it crashes with the below stacktrace, because 
toolkit tries to access some data (here 
::comphelper::getProcessServiceFactory() ), which is only available within the 
office process itself. 
I think, there once was a time, where the toolkit should be useable outside 
the office, then you should write an issue therefor." 
 
at the end, the code that shows tthe problem 
trying to insert a button on a window. The script segfaults. If i comment the 
line,  
oDialogModel.insertByName( "bouton", oButtonModel )  
the dialog is opened but the button (obviously is not ther) 
 
Thansk a lot 
 
Laurent 
 
# <ooo>/program/python myScript.py  
#myTest.py 
import uno 
import unohelper 
import pyuno 
 
ctx = uno.getComponentContext() 
smgr = ctx.ServiceManager 
 
oDialogModel = ctx.ServiceManager.createInstanceWithContext( 
"com.sun.star.awt.UnoControlDialogModel", ctx ) 
# Initialize the dialog model's properties. 
oDialogModel.PositionX = 200 
oDialogModel.PositionY = 200 
oDialogModel.Width = 200 
oDialogModel.Height = 200 
oDialogModel.Title = "titre" 
oDialogControl = ctx.ServiceManager.createInstanceWithContext( 
"com.sun.star.awt.UnoControlDialog", ctx ) 
oDialogControl.setModel( oDialogModel ) 
 
oButtonModel = oDialogModel.createInstance( 
"com.sun.star.awt.UnoControlButtonModel" ) 
#Initialize the button model's properties. 
oButtonModel.PositionX = 50 
oButtonModel.PositionY = 30 
oButtonModel.Width = 50 
oButtonModel.Height = 14 
oButtonModel.Name = "bouton" 
oButtonModel.TabIndex = 1 
oButtonModel.Label = "caption" 
print "before inserting button" 
oDialogModel.insertByName( "bouton", oButtonModel ) 
print "after inserting button" 
 
oButtonControl = oDialogControl.getControl( "bouton" ) 
 
oDialogControl.setVisible( False ) 
 
toolkit = ctx.ServiceManager.createInstanceWithContext ( 
"com.sun.star.awt.Toolkit", ctx ) 
parent = None 
oDialogControl.createPeer(toolkit,parent ) 
 
oDialogControl.setVisible( True ) 
oDialogControl.execute()
Comment 1 Frank Schönheit 2004-10-11 11:57:03 UTC
In general, toolkit contains UNO components only (well, mostly), and should,
IMO, adhere to the rules: UNO components should use the factory/context which
was used to create them. I suppose every use of getProcessServiceFactory in
toolkit is a bug, then (I stumbled upon this, too, as our form controls make
heavy use of the toolkit controls).
Comment 2 kay.ramme 2004-10-11 16:50:03 UTC
Frank, your are right, components should use the componenContext they received
via the factory method, which offers access to the to be used ServiceManager.
So, this is a bug in the UNO AWT, I forward it to Malte. 
Comment 3 malte_timmermann 2004-10-12 10:59:09 UTC
VCL itself relies on getProcessServiceFactory in some functions...
Comment 4 malte_timmermann 2006-09-18 11:16:46 UTC
Time for some cleanups here...
Comment 5 carsten.driesner 2006-10-04 17:26:19 UTC
cd: Accepted.