I created an window with Python. There are several widgets and especially several FixedTexts.
Once the action is performed, I would like to refresh some of these FixedTexts, so I modify the property “Label” of these widgets. But it doesn’t update the UI. What should I do?
Here is the simplified code:
Code: Select all
class TextFormatter (unohelper.Base, XActionListener, XJobExecutor):
def __init__ (self, ctx):
self.ctx = ctx
self.xSvMgr = self.ctx.ServiceManager
self.container = None
self.dialog = None
def addWidget (self, name, wtype, x, y, w, h, **kwargs):
widget = self.dialog.createInstance('com.sun.star.awt.UnoControl%sModel' % wtype)
widget.Name = name
widget.PositionX = x
widget.PositionY = y
widget.Width = w
widget.Height = h
for k, w in kwargs.items():
setattr(widget, k, w)
self.dialog.insertByName(name, widget)
return widget
def run (self):
# dialog
self.dialog = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialogModel', self.ctx)
self.dialog.Width = 200
self.dialog.Height = 345
self.dialog.Title = self.dUI.get('title', "#title#")
[...]
self.myFixedText = self.addWidget('ssp1_res', 'FixedText', 10, 10, 10, 10, Label = "")
[...]
button = self.addWidget('apply', 'Button', 95, 325, 80, 14, Label = self.dUI.get('apply', "#error#"))
# container
self.container = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.UnoControlDialog', self.ctx)
self.container.setModel(self.dialog)
self.container.getControl('apply').addActionListener(self)
self.container.setVisible(False)
xToolkit = self.xSvMgr.createInstanceWithContext('com.sun.star.awt.ExtToolkit', self.ctx)
self.container.createPeer(xToolkit, None)
self.container.execute()
def actionPerformed (self, actionEvent):
try:
[...]
self.myFixedText.Label = "OK"
self.container.endExecute()
except:
traceback.print_exc()
def trigger (self, args):
try:
dialog = TextFormatter(self.ctx)
dialog.run()
except:
traceback.print_exc()
g_ImplementationHelper = unohelper.ImplementationHelper()
g_ImplementationHelper.addImplementation(TextFormatter, 'dicollecte.TextFormatter', ('com.sun.star.task.Job',))Code: Select all
self.myFixedText.Label = "OK"BUT if I use xRay just after setting a new label, it works:
Code: Select all
self.myFixedText.Label = "OK"
xray(self.myFixedText)