0

I have strange behavior with text.ctrl. I would like to have textCtrl to set some text. This is connected to database. When database is empty on this textCtrl I would like to show hint " Place text bla,la ..". But when exists some data I would like to show current data on textCtrl without hint. Here is problem. When data exists current text goes to textCtrl hint. Every works fine with single line text. This behavior appears when I switch textCtrl to Multiline mode.

**WORKS**
self.m_textCtrl5 = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 600,50 ),0 )
self.m_textCtrl5.SetFont( wx.Font( 12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, "Arial" ) )
self.m_textCtrl5.SetHint("Place text bla,bla")
if empty_record==1:
   self.m_textCtrl5.SetLabel(data)

**NOT WORKING**
# self.m_textCtrl5 = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size( 600,50 ), wx.TE_MULTILINE)
self.m_textCtrl5.SetFont( wx.Font( 12, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, "Arial" ) )
self.m_textCtrl5.SetHint("Place text bla,bla")
if empty_record==1:
  self.m_textCtrl5.SetLabel(data)

I would like to have multiline textCtrl with hint

Robert M
  • 21
  • 2

1 Answers1

0

Hints are only supported for multine text controls in some platforms, as noted in the documentation

A solution is to replace this

self.m_textCtrl5.SetHint("Place text bla,bla")
if empty_record==1:
  self.m_textCtrl5.SetLabel(data)

with this

if empty_record==1:
  self.m_textCtrl5.SetLabel(data)
else:
  self.m_textCtrl5.WriteText("Place text bla,bla")
Emanuel P
  • 1,586
  • 1
  • 6
  • 15
  • Yes, but when is multiline mode self.m_textCtrl5.SetLabe(data) displays text as hint. This is strange behavior. Python 3.10.9, wxWidgets 3.2.0 Windows 10 – Robert M Feb 24 '23 at 07:55
  • Ok, replace self.m_textCtrl5.SetHint("Place text bla,bla") with self.m_textCtrl5.WriteText("Place text bla,bla") works fine.Thanks – Robert M Feb 24 '23 at 09:39