Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8771145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:42:47+00:00 2026-06-13T17:42:47+00:00

I want to achieve a status bar with 2 fields. The first one left-aligned

  • 0

I want to achieve a status bar with 2 fields. The first one left-aligned and the second one right-aligned. Illustration of what I want:

|                                                                               |
|                                                                               |
=================================================================================
| Some status text.                                                   v. 1.0.32 |

My current code:

self.CreateStatusBar(2)
self.SetStatusWidths([-1, -1])

But the right field is left aligned, so it looks like this:

|                                                                               |
|                                                                               |
=================================================================================
| Some status text.                      v. 1.0.32                              |

Is there any way to get text in the right field to align to the right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:42:48+00:00Added an answer on June 13, 2026 at 5:42 pm

    Ok, I’ve solved the problem (even though it feels like a hack.) I created a custom toolbar that defines two fields. The left field can be controlled like normal, and the right field contains a StaticText control, containing the version number, that is manually positioned. The code for positioning the text is platform specific since it looked a tad different on windows. Here are some screenshots:

    Windows 7:

    Windows 7

    OSX 10.8.1 Mountain Lion:

    OSX

    Here is the code for the custom status bar:

    class CustomStatusBar(wx.StatusBar):
        """A custom status bar for displaying the application version in the bottom
        right corner."""
        def __init__(self, parent):
            wx.StatusBar.__init__(self, parent, -1)
    
            self.SetFieldsCount(2)
            self.SetStatusWidths([-1, -1])
    
            # Set up the version label.
            self.version_label = wx.StaticText(self, -1, 'Version: ' + VERSION)
            self.reposition_version_label()
    
            # Listen to the resize event.
            self.Bind(wx.EVT_SIZE, self.on_resize)
    
        def on_resize(self, event):
            self.reposition_version_label()
    
        def reposition_version_label(self):
            # Get the rect of the second field.
            field_rect = self.GetFieldRect(1)
            label_rect = self.version_label.GetRect()
    
            # Reduce the width of the field rect to the width of the label rect and
            # increase it's x value by the same about. This will result in it being
            # right aligned.
            width_diff = field_rect.width - label_rect.width
    
            field_rect.width = label_rect.width
            field_rect.x += width_diff
    
            # On windows, the text is a little too high up, so increase the Y value
            # a little.
            if sys.platform == 'win32':
                field_rect.y += 3
    
            # Set the resulting rect to the label.
            self.version_label.SetRect(field_rect)
    

    This code is in my Frame‘s constructor to create and place the status bar:

    self.statusbar = CustomStatusBar(self)
    self.SetStatusBar(self.statusbar)
    

    And I added this function to my frame for easy status updates:

    def set_status_text(text):
        self.statusbar.SetStatusText(text, 0)
    

    I hope this helps somebody else down the line.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First, what I want to achieve: Let's say I'm doing some stuff in onClick()
I'm want to create a menu for a status bar item like the one
I want to achieve this effect: When the user focus a text area within
First of all, quickly what exactly I want to achieve: translate particular exception into
I want to use clone to log the current status of my program. It
I have some issues with Status Bar Hidden logic. I am having a flash
I have 'StatusBar' with 'StatusBarItem'`s and one of them is current status label. I
I want to achieve the effect that is used on this Header on this
i want to achieve that the user can go through the slices of a
I want to achieve something relatively simple: I want to retrieve all objects from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.