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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:33:23+00:00 2026-06-11T11:33:23+00:00

I am writing a program with PyGTK for navigating large (>20 MB) text files.

  • 0

I am writing a program with PyGTK for navigating large (>20 MB) text files. I am using a TextViewer widget for this, which handles them quite well except it takes several seconds to finish filling the corresponding TextBuffer. Meanwhile, I also have several dialogs that require filtering on their input (only hexadecimal digits or something). I pass the characters I want to allow and the name of a signal to this function:

def FilterText(self, chars, signal):

    def Filt(entry, text, length, position):
        position = entry.get_position()
        chrs = set(chars)
        realtext = ''.join([c for c in text if c in chrs])
        if len(realtext) > 0:
            entry.handler_block_by_func(Filt)
            entry.insert_text(realtext, position)
            entry.handler_unblock_by_func(Filt)
            newPos = position + len(realtext)
            gobject.idle_add(entry.set_position, newPos)
        entry.stop_emission(signal)
    return Filt

And then connect the result to the Entry widget’s handler for that signal. This works, except that while the TextBuffer is being filled, none of the entry.set_position calls that were queued up get run until it finished. The result is that the cursor is stuck at the beginning of the Entry and everything typed is backwards which is, needless to say, quite annoying. This is presumably because there is no idle time until the TextBuffer is filled. Is there any way to work around this and allow the correct behavior when typing into a filtered Entry widget? (It should be possible, as no such problem is encountered with an unfiltered one) Calling entry.set_position directly doesn’t work for some reason.

  • 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-11T11:33:24+00:00Added an answer on June 11, 2026 at 11:33 am

    Finally figured it out–change the call

    gobject.idle_add(entry.set_position, newPos)
    

    To

    gobject.timeout_add(0, entry.set_position, newPos)
    

    Since entry.set_position returns None, it will call it once immediately, then never again, doing exactly what I wanted.

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

Sidebar

Related Questions

I'm writing a program which creates a large number of large arrays to store
I am writing a program by a framework using pygtk. The main program doing
I am writing a timer program in Python using PyGTK. It is precise to
I'm writing program which captures audio in C# using DirectShow library and writes it
I'm writing a program that handles DBs and writes any changes into ListView for
I am currently writing a program using Weka that builds a model (using one
I'm writing a program that's parsing an XML file to java objects using smooks.
I am writing a program and have some code inside a string. This code
I have been writing a program which asks you to input two integers, which
I am writing a program doing the following works: Run a command using ProcessBuilder

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.