Bugzilla – Attachment 125550 Details for
Bug 100272
LOO Crashed when using Grid at a Dialog
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
Sample Python script
test_grid.py (text/x-python), 5.59 KB, created by
Ronny Kunze
on 2016-06-08 12:19:51 UTC
(
hide
)
Description:
Sample Python script
Filename:
MIME Type:
Creator:
Ronny Kunze
Created:
2016-06-08 12:19:51 UTC
Size:
5.59 KB
patch
obsolete
># -*- coding: utf-8 -*- >""" >Created on Tue Jun 7 14:40:55 2016 > >@author: ronny >""" > >import uno >import unohelper >import logging >import sys >from com.sun.star.awt import XActionListener >#from com.sun.star.awt import XItemListener >#from com.sun.star.awt import XKeyListener >#from com.sun.star.awt import XTextListener >#from com.sun.star.awt import XEventHandler >from com.sun.star.awt.grid import XGridSelectionListener > >class app(XGridSelectionListener, unohelper.Base, XActionListener): > > def __init__(self): > logging.basicConfig(level=logging.DEBUG) > # Die UNO-Komponente Kontext (Context) von der PyUNO-Laufzeitumgebung holen > localContext = uno.getComponentContext() > > # Die UnoUrlResolver erstellen > resolver = localContext.ServiceManager.createInstanceWithContext( \ > "com.sun.star.bridge.UnoUrlResolver", localContext) > > # Zum laufenden Office verbinden > #ctx = resolver.resolve("uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext") > self.ctx = resolver.resolve("uno:pipe,name=abraxas;urp;StarOffice.ComponentContext") > self.smgr = self.ctx.ServiceManager > > # Das zentrale Desktop-Objekt holen > self.desktop = self.smgr.createInstanceWithContext("com.sun.star.frame.Desktop", self.ctx) > > # auf das aktuelle Dokument zugreifen > self.model = self.desktop.getCurrentComponent() > > def appli(self): > dp = self.smgr.createInstance("com.sun.star.awt.DialogProvider") > > # create the dialog model and set the properties > dialogModel = self.smgr.createInstanceWithContext( > "com.sun.star.awt.UnoControlDialogModel", self.ctx) > > dialogModel.PositionX = 100 > dialogModel.PositionY = 100 > dialogModel.Width = 500 > dialogModel.Height = 150 > dialogModel.Title = "Runtime Dialog Demo" > > # create the dialog control and set the model > self.controlContainer = self.smgr.createInstanceWithContext( > "com.sun.star.awt.UnoControlDialog", self.ctx); > self.controlContainer.setModel(dialogModel); > > gridcontrol=self.controlContainer.Model.createInstance("com.sun.star.awt.grid.UnoControlGridModel") > gridcontrol.Height=145 > gridcontrol.Width=420 > gridcontrol.PositionX=13 > gridcontrol.PositionY=19 > gridcontrol.Name="Ergebnisauswahl" > gridcontrol.ShowColumnHeader = True > gridcontrol.ShowRowHeader = True > gridcontrol.GridDataModel = self.smgr.createInstance("com.sun.star.awt.grid.DefaultGridDataModel") > gridcolummodel = self.smgr.createInstance("com.sun.star.awt.grid.DefaultGridColumnModel") > > column1 = gridcolummodel.createColumn() > column2 = gridcolummodel.createColumn() > column1.Title="Type" > column2.Title="Result" > gridcontrol.ColumnModel=gridcolummodel > gridcolummodel.addColumn(column1) > gridcolummodel.addColumn(column2) > > self.controlContainer.Model.insertByName("Grid",gridcontrol) > > self.gridCtrl = self.controlContainer.getControl("Grid") > #self.gridCtrl.Model.GridDataModel.addRows([0,1],[['TestA','TestB'],['Test2A','Test2B']]); > # create a peer > > # create the button model and set the properties > buttonModel = dialogModel.createInstance( > "com.sun.star.awt.UnoControlButtonModel" ) > > buttonModel.PositionX = 435 > buttonModel.PositionY = 30 > buttonModel.Width = 50; > buttonModel.Height = 14; > buttonModel.Name = "myButtonName"; > buttonModel.TabIndex = 0; > buttonModel.Label = "Click Me"; > > self.controlContainer.Model.insertByName("Btn",buttonModel) > > buttonModel2 = dialogModel.createInstance( > "com.sun.star.awt.UnoControlButtonModel" ) > > buttonModel2.PositionX = 435 > buttonModel2.PositionY = 50 > buttonModel2.Width = 50; > buttonModel2.Height = 14; > buttonModel2.Name = "myButtonName2"; > buttonModel2.TabIndex = 0; > buttonModel2.Label = "Clear"; > self.controlContainer.Model.insertByName("Btn2",buttonModel2) > > toolkit = self.smgr.createInstanceWithContext( > "com.sun.star.awt.ExtToolkit", self.ctx); > > self.controlContainer.setVisible(False); > self.controlContainer.createPeer(toolkit, None); > btn = self.controlContainer.getControl("Btn") > btn.setActionCommand('RESET') > btn.addActionListener(self) > btn2 = self.controlContainer.getControl("Btn2") > btn2.setActionCommand('CANCEL') > btn2.addActionListener(self) > self.controlContainer.execute() > print("ende") > self.controlContainer.dispose() > > def actionPerformed(self, actionEvent): > # Doubleclicked is accepted > self.actionEvent = actionEvent > if actionEvent != None : > if actionEvent.typeName == 'com.sun.star.awt.ActionEvent' : > if actionEvent.ActionCommand == 'CANCEL' : > self.gridCtrl.Model.GridDataModel.removeAllRows() > return > elif actionEvent.ActionCommand == 'RESET' : > self.gridCtrl.Model.GridDataModel.addRow( int(self.gridCtrl.Model.GridDataModel.RowCount),['TestA','TestB']); > self.gridCtrl.selectRow(0) > return > else : > self.otherEvent=actionEvent > else : > self.wasNone=True > >if __name__ == "__main__": > application = app() > sys.exit(application.appli())
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 100272
: 125550 |
125551