issues with XRC and wxFormBuilder

Possibly these would be better asked at wxformbuilder.org, but that seems to be down this evening, and I'm hoping someone here will happen to know the answer.

I'm still a newbie to wx, but I was able to successfully make a search window that has a right-aligned SearchCtrl at the top, a big stretchy listbox in the middle, and a left-aligned GenButton and a record count at the bottom. Tonight I tried to recreate this layout using XRC and wxFormBuilder, but I've met only mixed success.

First the SearchCtrl: wxFormBuilder doesn't seem to have this in its control palette, so I added a TextCtrl, and then changed the "subclass" name to wxSearchCtrl. This makes it appear like a SearchCtrl, except that peeking out behind the actual search field, there is a boxy border. This doesn't happen when I create the SearchCtrl myself in code, and it looks ugly. What did I do wrong?

Also, there was nothing in the palette for the buttons.GenButton I want at the bottom (to get a square bevel button). I tried adding a generic control and setting the class to buttons,GenButton, but this just generated errors. How would I do that?

Next, I couldn't get the static text at the bottom of the screen to be center-aligned between the button on its left, and the right side of the window. In code, I had to add wx.ST_NO_AUTORESIZE. But this flag doesn't appear to be available in wxFormBuilder. I tried wxFIXED_MINSIZE instead, but it doesn't seem to work.

Finally, a more general wx question: in order to get the search field right-aligned, I added a StaticText to the left of it with no label, wx.EXPAND | wx.RIGHT set, and proportion = 1. The search field has a fixed size and proportion = 0. Using a blank StaticText for this seems hackish, but without it, the search field would appear on the left in its horizontal box sizer, despite having wx.ALIGN_RIGHT | wx.ALL (or any other likely combination of flags). Is there a better way to get a control to "stick" to the right side of the window?

I'm appending the XRC code in case anyone wants to follow along at home. At the moment, I'm about ready to give up on XRC (or at least on wxFormBuilder) and just write my GUIs in code, as in my simple test at least, that went much faster and more successfully. But if anyone here has advice to get me past these initial hurdles, I'd appreciate it.

Thanks,
- Joe

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwindows.org/wxxrc" version="2.3.0.1">
  <object class="wxFrame" name="etown_GUI">
    <style>wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL</style>
    <size>700,400</size>
    <title>eTown Members</title>
    <object class="wxBoxSizer">
      <orient>wxVERTICAL</orient>
      <object class="sizeritem">
        <option>0</option>
        <flag>wxEXPAND|wxLEFT|wxRIGHT</flag>
        <border>5</border>
        <object class="wxBoxSizer">
          <orient>wxHORIZONTAL</orient>
          <object class="sizeritem">
            <option>0</option>
            <flag>wxALIGN_RIGHT|wxRIGHT</flag>
            <border>5</border>
            <object class="wxTextCtrl" name="search" subclass="wxSearchCtrl">
              <size>386,20</size>
              <value></value>
              <maxlength>0</maxlength>
            </object>
          </object>
        </object>
      </object>
      <object class="sizeritem">
        <option>1</option>
        <flag>wxALL|wxEXPAND</flag>
        <border>5</border>
        <object class="wxListCtrl" name="list_CTRL">
          <style>wxLC_REPORT</style>
          <size>700,-1</size>
        </object>
      </object>
      <object class="sizeritem">
        <option>0</option>
        <flag>wxEXPAND|wxLEFT|wxRIGHT</flag>
        <border>5</border>
        <object class="wxBoxSizer">
          <orient>wxHORIZONTAL</orient>
          <object class="sizeritem">
            <option>0</option>
            <flag>wxALIGN_BOTTOM|wxALIGN_LEFT|wxALL</flag>
            <border>5</border>
            <object class="wxButton" name="m_button2">
              <bg>#cccccc</bg>
              <label>+</label>
              <default>0</default>
            </object>
          </object>
          <object class="sizeritem">
            <option>0</option>
            <flag>wxALIGN_CENTER|wxALL|wxFIXED_MINSIZE|wxLEFT|wxRIGHT</flag>
            <border>5</border>
            <object class="wxStaticText" name="m_staticText2">
              <label>0 records</label>
            </object>
          </object>
        </object>
      </object>
    </object>
  </object>
</resource>

For the moment I can only suggest a solution to this problem.

Just try setting these flags to the bSizer2: wxALIGN_RIGHT, wxLEFT, wxRIGHT.

The sizer shouldn't be expanded.

I've tried it myself, and that makes the search field right-aligned
without the need of using a StaticText.

···

On Mon, Nov 17, 2008 at 11:21 AM, Joe Strout <joe@strout.net> wrote:

Finally, a more general wx question: in order to get the search field
right-aligned, I added a StaticText to the left of it with no label,
wx.EXPAND | wx.RIGHT set, and proportion = 1. The search field has a fixed
size and proportion = 0. Using a blank StaticText for this seems hackish,
but without it, the search field would appear on the left in its horizontal
box sizer, despite having wx.ALIGN_RIGHT | wx.ALL (or any other likely
combination of flags). Is there a better way to get a control to "stick" to
the right side of the window?

--
Alexei Vinidiktov

I'm not sure I understand correctly what you are trying to achieve,
but if I do, then you can do the following:

Add a sizer to bSizer3. Place it as the second element right after
m_button2, then drag m_staticText2 to tht newly added sizer. It should
now be center-aligned between the button and the right border.

Here's the XRC code with the fix for the search control and static
text placement. I haven't actually used it in a Python program, but it
looks right in the wxFormBuilder designer window.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwindows.org/wxxrc&quot; version="2.3.0.1">
  <object class="wxFrame" name="etown_GUI">
    <style>wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL</style>
    <size>700,400</size>
    <title>eTown Members</title>
    <object class="wxBoxSizer">
      <orient>wxVERTICAL</orient>
      <object class="sizeritem">
        <option>0</option>
        <flag>wxLEFT|wxRIGHT|wxALIGN_RIGHT</flag>
        <border>5</border>
        <object class="wxBoxSizer">
          <orient>wxHORIZONTAL</orient>
          <object class="sizeritem">
            <option>0</option>
            <flag>wxALIGN_RIGHT|wxRIGHT</flag>
            <border>5</border>
            <object class="wxTextCtrl" name="search" subclass="wxSearchCtrl">
              <size>386,20</size>
              <value></value>
              <maxlength>0</maxlength>
            </object>
          </object>
        </object>
      </object>
      <object class="sizeritem">
        <option>1</option>
        <flag>wxALL|wxEXPAND</flag>
        <border>5</border>
        <object class="wxListCtrl" name="list_CTRL">
          <style>wxLC_REPORT</style>
          <size>700,-1</size>
        </object>
      </object>
      <object class="sizeritem">
        <option>0</option>
        <flag>wxEXPAND|wxLEFT|wxRIGHT</flag>
        <border>5</border>
        <object class="wxBoxSizer">
          <orient>wxHORIZONTAL</orient>
          <object class="sizeritem">
            <option>0</option>
            <flag>wxALIGN_BOTTOM|wxALIGN_LEFT|wxALL</flag>
            <border>5</border>
            <object class="wxButton" name="m_button2">
              <bg>#cccccc</bg>
              <label>+</label>
              <default>0</default>
            </object>
          </object>
          <object class="sizeritem">
            <option>1</option>
            <flag>wxEXPAND</flag>
            <border>5</border>
            <object class="wxBoxSizer">
              <orient>wxVERTICAL</orient>
              <object class="sizeritem">
                <option>0</option>
                <flag>wxALIGN_CENTER|wxALL|wxFIXED_MINSIZE|wxLEFT|wxRIGHT</flag>
                <border>5</border>
                <object class="wxStaticText" name="m_staticText2">
                  <label>0 records</label>
                </object>
              </object>
            </object>
          </object>
        </object>
      </object>
    </object>
  </object>
</resource>

···

On Mon, Nov 17, 2008 at 11:21 AM, Joe Strout <joe@strout.net> wrote:

Next, I couldn't get the static text at the bottom of the screen to be
center-aligned between the button on its left, and the right side of the
window. In code, I had to add wx.ST_NO_AUTORESIZE. But this flag doesn't
appear to be available in wxFormBuilder. I tried wxFIXED_MINSIZE instead,
but it doesn't seem to work.

--
Alexei Vinidiktov

Oh, and I have another solution for that problem.

You can add a spacer before the search field. The XRC should look
something like this:

<object class="wxBoxSizer">
          <orient>wxHORIZONTAL</orient>
          <object class="spacer">
            <option>1</option>
            <flag>wxEXPAND</flag>
            <border>5</border>
            <size>0,0</size>
          </object>
          <object class="sizeritem">
            <option>0</option>
            <flag>wxALIGN_RIGHT|wxRIGHT</flag>
            <border>5</border>
            <object class="wxTextCtrl" name="search" subclass="wxSearchCtrl">
              <size>386,20</size>
              <value></value>
              <maxlength>0</maxlength>
            </object>
          </object>
        </object>

···

On Mon, Nov 17, 2008 at 11:21 AM, Joe Strout <joe@strout.net> wrote:

Finally, a more general wx question: in order to get the search field
right-aligned, I added a StaticText to the left of it with no label,
wx.EXPAND | wx.RIGHT set, and proportion = 1. The search field has a fixed
size and proportion = 0. Using a blank StaticText for this seems hackish,
but without it, the search field would appear on the left in its horizontal
box sizer, despite having wx.ALIGN_RIGHT | wx.ALL (or any other likely
combination of flags). Is there a better way to get a control to "stick" to
the right side of the window?

Thanks, you're right -- I was trying to right-align the search field within the sizer, but I see now that right-aligning the sizer itself works much better.

Thanks,
- Joe

···

On Nov 16, 2008, at 11:47 PM, Alexei Vinidiktov wrote:

On Mon, Nov 17, 2008 at 11:21 AM, Joe Strout <joe@strout.net> wrote:

Finally, a more general wx question: in order to get the search field
right-aligned, I added a StaticText to the left of it with no label,
wx.EXPAND | wx.RIGHT set, and proportion = 1...

For the moment I can only suggest a solution to this problem.

Just try setting these flags to the bSizer2: wxALIGN_RIGHT, wxLEFT, wxRIGHT.

The sizer shouldn't be expanded.