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 8468289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:53:34+00:00 2026-06-10T15:53:34+00:00

I am working on a simple GUI that outputs a numeric value that is

  • 0

I am working on a simple GUI that outputs a numeric value that is automatically copied to the clipboard. I am trying to get the text “Copied” to flash as soon as this happens, appearing instantly and then disappearing after a second or two.

What happens is the text flashes as I want it to, but the output field that is displayed doesn’t update until after the text disappears, which is not the order I have it scripted. The goal would be to have the output field appear to update at the same instant the text appears.

The way I have the text appearing is rather crude, so I am very open to suggestions. Ideas and comments will be appreciated.

import sys
from win32gui import GetWindowText, EnumWindows, ShowWindow, SetForegroundWindow
import win32clipboard
import win32con
import time
import wx
from wxPython.wx import *
import itertools
from time import sleep


class MainFrame(wx.Frame):
    def __init__(self,title):

        wx.Frame.__init__(self, None, title="RRESI Rounder", pos=(0,0), size=(210,160))
        panel=Panel(self)


class Panel(wx.Panel):

    def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        x1=10; x2=110
        y1=10; dy=30; ddy=-3
        boxlength=80

        self.label1 = wx.StaticText(self, label="Input Number:", pos=(x1,y1+dy*1))
        self.Input = wx.TextCtrl(self, value="100.00001", pos=(x2,ddy+y1+dy*1), size=(boxlength,-1))

        self.button =wx.Button(self, label="GO", pos=(9999,y1+dy*3))
        self.Bind(wx.EVT_BUTTON, self.OnClick,self.button)
        self.button.SetDefault()

        self.label0 = wx.StaticText(self, label="Round to closest:  1/", pos=(x1,y1+dy*0))
        self.Denominator = wx.TextCtrl(self, value="64", pos=(x2,ddy+y1+dy*0), size=(boxlength,-1))

        self.label2 = wx.StaticText(self, label="Output Number:", pos=(x1,y1+dy*2))
        self.display = wx.TextCtrl(self, value="100.00000", pos=(x2,ddy+y1+dy*2), size=(boxlength,-1))
        self.display.SetBackgroundColour(wx.Colour(232, 232, 232))

        self.label3 = wx.StaticText(self, label="          ", pos=(x2+7,y1+dy*2+20)) #Copied

        self.label4 = wx.StaticText(self, label="", pos=(x2+7,y1+dy*2))
        self.label4.SetBackgroundColour(wx.Colour(232, 232, 232))

    def OnClick(self,event):      

        def openClipboard():
            try:
                win32clipboard.OpenClipboard()
            except Exception, e:
                print e
                pass

        def closeClipboard():
            try:
                win32clipboard.CloseClipboard()
            except Exception, e:
                print e
                pass

        def clearClipboard():
            try:
                openClipboard()
                win32clipboard.EmptyClipboard()
                closeClipboard()
            except TypeError:
                pass

        def setText(txt): 
            openClipboard()
            win32clipboard.EmptyClipboard()
            win32clipboard.SetClipboardText(txt) 
            closeClipboard()

        Denominator = float(self.Denominator.GetValue())
        Input=float(self.Input.GetValue())
        Output=round(Input*Denominator,0)/Denominator
        self.display.SetValue(str(Output))
        setText(str(Output))
        self.label4.SetLabel(str(Output)+"")
        self.label3.SetLabel("Copied")
        sleep(.5)
        self.label3.SetLabel("                    ")


if __name__=="__main__":
    app = wx.App(redirect=False)   # Error messages don't go to popup window
    frame = MainFrame("RRESI Rounder")
    frame.Show()
    app.MainLoop()
  • 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-10T15:53:36+00:00Added an answer on June 10, 2026 at 3:53 pm

    you just need to force a redraw otherwise it wont redraw until the next EVT_PAINT is called (after function exits…) by the way sleep is blocking… that means no code is being executed at all while it sleeps

    ...
    self.label3.SetLabel("Copied")
    self.Update()#force redraw
    ....
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a simple text editor with winapi, its working for simple
I am working on a simple GUI app that just draws some graphics on
I am currently working on a simple GUI application that rolls two dice. I
I'm working on a simple GUI Python script to do some simple tasks on
I was working on a simple GUI script yesterday using jdbc in eclipse. When
I'm working on a simple GUI code editor in Python, and I want to
I am working on coding a GUI with C#. I'm following this simple tutorial
Good Day, I have a simple working routine in Perl that swaps two words:
I've been working on a gui app that needs to manage external processes. Working
I'm attempting to build a very simple wxPython GUI that monitors and displays external

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.