I have the code below.
I am trying to dynamically add the error. I am fetching the error message through an API which might have more characters. My aim is to fit the dynamic error in wx. Dialog in its best size and position depending on the size of dialog. If I am giving wx.ALIGN_CENTER
of wx.ALIGN_CENTER_HORIZONTAL
, text is starting from middle and truncating the full text as seen in capture 1. I want it to fit As of now, I have added some white spaces in order to bring the error in the middle if its short or starting from left leaving some spaces in order to occupy the space if the message is long. I want avoid this manual adding of spaces. How can I achieve this?
Also if message is very long it is getting truncated in one line. How to overcome this? capture 2
class OTPVerificationDialog ( wx.Dialog ):
def __init__( self, parent ):
wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString,pos = wx.DefaultPosition,size = wx.Size( 800,430 ), style = wx.DEFAULT_DIALOG_STYLE )
self.SetSizeHints( wx.Size( 800,430 ), wx.Size( 800,450 ) )
bSizer112 = wx.BoxSizer( wx.VERTICAL )
self.m_staticText85 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText85.Wrap( -1 )
#self.m_staticText85.SetFont( wx.Font( wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, wx.EmptyString ) )
font = wx.Font(wx.FontInfo(12).Family(wx.FONTFAMILY_DEFAULT).Style(wx.FONTSTYLE_NORMAL).Weight(wx.FONTWEIGHT_BOLD))
self.m_staticText85.SetFont(font)
bSizer112.Add( self.m_staticText85, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
bSizer112.Add( ( 0, 0), 1, wx.EXPAND, 5 )
self.m_staticText86 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText86.Wrap( -1 )
bSizer112.Add( self.m_staticText86, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
bSizer112.Add( ( 0, 0), 1, wx.EXPAND, 5 )
self.m_staticText87 = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText87.Wrap( -1 )
bSizer112.Add( self.m_staticText87, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
bSizer112.Add( ( 0, 0), 1, wx.EXPAND, 5 )
self.m_staticTextDynamicError = wx.StaticText( self, wx.ID_ANY, u"", wx.DefaultPosition, wx.DefaultSize, 0 )
# self.m_staticTextDynamicError.Wrap( -1 )
self.m_staticTextDynamicError.Wrap(300)
#self.m_staticTextDynamicError.SetFont( wx.Font( wx.NORMAL_FONT.GetPointSize(), wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD, False, wx.EmptyString ) )
font = wx.Font(wx.FontInfo(12).Family(wx.FONTFAMILY_DEFAULT).Style(wx.FONTSTYLE_NORMAL).Weight(wx.FONTWEIGHT_BOLD))
self.m_staticTextDynamicError.SetFont(font)
#self.m_staticTextDynamicError.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_MENU ) )
bSizer112.Add( self.m_staticTextDynamicError, 0, wx.ALIGN_LEFT|wx.ALL, 0)
bSizer112.Add( ( 0, 0), 1, wx.EXPAND, 5 )
self.m_verfication_code_input = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.Size(100,-1), 0 )
bSizer112.Add( self.m_verfication_code_input, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
bSizer112.Add( ( 0, 0), 1, wx.EXPAND, 5 )
# bSizer112.Add( ( 0, 0), 1, wx.EXPAND, 5 )
self.m_verification_confirm = wx.Button( self, wx.ID_OK ,u"Verify", wx.DefaultPosition, wx.DefaultSize, wx.TE_PROCESS_ENTER )
bSizer112.Add( self.m_verification_confirm, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
self.m_verification_confirm.Disable()
bSizer112.Add( ( 0, 0), 1, wx.EXPAND, 5 )
self.m_button38 = wx.Button( self, wx.ID_ANY, u"Haven't received it? Resend Verification Code", wx.DefaultPosition, wx.DefaultSize, 0 )
bSizer112.Add( self.m_button38, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5 )
bSizer112.Add( ( 0, 0), 1, wx.EXPAND, 5 )
self.SetSizer( bSizer112 )
self.Layout()
self.Centre( wx.BOTH )