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

  • Home
  • SEARCH
  • 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 9190761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:32:09+00:00 2026-06-17T20:32:09+00:00

I am trying to get a wxPython TimeCtrl widget to toggle it’s value 12hr

  • 0

I am trying to get a wxPython TimeCtrl widget to toggle it’s value 12hr (AM/PM) format to 24 hour format at the click of a button.

Now I know the TimeCtrl widget 12/24hr formatting is set at initialization by setting the attribute fmt24hr = False/True depending on if you want to display 24hr format or not.

Here’s the API for TimeCtrl::

from wx.lib.masked import TimeCtrl

TimeCtrl(
     parent, id = -1,
     value = '00:00:00',
     pos = wx.DefaultPosition,
     size = wx.DefaultSize,
     style = wxTE_PROCESS_TAB,
     validator = wx.DefaultValidator,
     name = "time",
     format = 'HHMMSS',
     fmt24hr = False,
     displaySeconds = True,
     spinButton = None,
     min = None,
     max = None,
     limited = None,
     oob_color = "Yellow"
    )

Now I want to toggle fmt24hr from True to False when a button is clicked but I cannot find a way! As far as I can see in the docs there is no setter for it.

Any help will be appreciated.

  • 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-17T20:32:11+00:00Added an answer on June 17, 2026 at 8:32 pm

    I am guessing that that is an attribute you cannot change after the widget is created. You have two options:

    1. Create both controls and hide one and when you toggle you hide the first one and show the second
    2. Create the first control and then destroy it when “toggle” it and create the other version in its place.

    Either way, you’ll almost certainly want to use Sizer methods to make it appear and disappear in the right location. If you’re destroying it, then you’ll want Sizer.Remove and Sizer.Insert. If you’re just showing and hiding, then you can use the Sizer’s Show and Hide methods. You may also want to look into the panel’s Freeze and Thaw methods to reduce the amount of flicker.

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

Sidebar

Related Questions

I'm trying get to know decorators, and I have a problem with sharing value,
Trying to get a random string out of ListArray on the button pressed. Always
I've spent a very frustrating evening trying to get wxpython to work on my
I'm trying to pre-populate a wxPython DatePicker with a value using the following code:
I am currently trying to get a grip on wxPython, and I stumbeled over
I'm trying to get a label on a button to be on two or
I am trying get date of call but it's returning value of 1.1.1970(I think
I am trying get this background to fade in on click. I found one
I'm trying to get the wxPython video player described here to work in Windows,
I'm new to Pythong and I have been trying to get a button within

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.