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

Reply via email to