Hi,
i respond to my self thanks to the solution given in the wxWidgets forum. http://forums.wxwidgets.org/viewtopic.php?f=27&t=37637 The solution is to use the wxST_NO_AUTORESIZE flag described here; http://docs.wxwidgets.org/stable/wx_wxstatictext.html Regards. Javi ----- Mensaje original ----- > De: Javier Mr <javiersdevm...@ymail.com> > Para: "wxlua-users@lists.sourceforge.net" <wxlua-users@lists.sourceforge.net> > CC: > Enviado: Lunes 1 de julio de 2013 14:56 > Asunto: [wxlua-users] wxStaticText alignment reset on text update > > Hi, > > i'm not an expert with wxLua neither with wxWidgets. I think that what > i'm trying to do is quite simple but i can't get it to work. I have a > simple user interface with a label, the label is inside a horizontal sizer, I > want the text to be centered in the label, for accomplish i have done: > > local panel = wx.wxPanel(parent, wx.wxID_ANY); > > local label = wx.wxStaticText(panel, wx.wxID_ANY, "---", > wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxALIGN_CENTER); > > label:SetForegroundColour(wx.wxColour("RED")); > local labelFont = label:GetFont(); > labelFont:SetPointSize(15); > labelFont:SetWeight(wx.wxFONTWEIGHT_BOLD); > label:SetFont(labelFont); > > local vSizer = wx.wxBoxSizer(wx.wxVERTICAL); > local hSizer1 = wx.wxBoxSizer(wx.wxHORIZONTAL); > > hSizer1:Add(label, 1, wx.wxEXPAND + wx.wxTOP + wx.wxBOTTOM + wx.wxRIGHT + > wx.wxLEFT); > > vSizer:Add(hSizer1, 5, wx.wxEXPAND +wx.wxCENTER, 5); > > panel:SetSizer(vSizer); > > > This gets the job done (in the snippet of code i also se the text to red > color > and change the font). However the text needs to change dynamically and when i > try to change is with: > > label:SetForegroundColour(wx.wxColour("GREEN")); > label:SetLabel("+++"); > label:SetWindowStyleFlag(wx.wxALIGN_CENTER); > label:Refresh(); > > The label defaults to left align ( First I tried without the > SetWindowStyleFlag > call, but that didn't work). What i'm doing wrong?, why is the align > reset to left? > Wich one is the correct way to update the text value without changing the > label > aligment? > > TIA. > > Best regards. > Javi. > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Windows: > > Build for Windows Store. > > http://p.sf.net/sfu/windows-dev2dev > _______________________________________________ > wxlua-users mailing list > wxlua-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/wxlua-users > ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ wxlua-users mailing list wxlua-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wxlua-users