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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:14:06+00:00 2026-05-28T05:14:06+00:00

I have a form interface with a large number of horizontal drop down and

  • 0

I have a form interface with a large number of horizontal drop down and text boxes that are inside a GTKscrolledWindow. The form has to be aligned horizontally because there are an unlimited number of forms in the window (think tabel of forms).

Is it (possible/how do I) auto-scroll the GTKScrolledWindow to the right when the operator tabs to the next form control which is off to the right of the screen.?

Related question would be how do I detect if the focused element (button etc) is visible in it’s parent scrolledwindow.

Thanks.

  • 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-05-28T05:14:06+00:00Added an answer on May 28, 2026 at 5:14 am

    Here’s what I did, based on Michy’s answer.

    To make a scrolled window auto-scroll, run in the constructor:

    FocusScroll(scrolledwindow).
    
        class FocusScroll(object):
        """
        Get a gtk.ScrolledWindow which contains a gtk.Viewport.
        Attach event handlers which will scroll it to show the focused widget.
        """
        def __init__(self, scrolledwindow):
            self.scrolledwindow = scrolledwindow
            self.viewport = scrolledwindow.get_child()
            assert isinstance(self.viewport, gtk.Viewport)
            self.main_widget = self.viewport.get_child()
            self.vadj = scrolledwindow.get_vadjustment()
            self.window = self.get_window(scrolledwindow)
    
            self.viewport.connect('set-focus-child', self.on_viewport_set_focus_child)
    
        def get_window(self, widget):
            if isinstance(widget, gtk.Window):
                return widget
            else:
                return self.get_window(widget.get_parent())
    
        def is_child(self, widget, container):
            """
            Go recursively over all children of container, to check if widget is
            a child of it.
            """
            for child in container.get_children():
                if child is widget:
                    return True
                elif isinstance(child, gtk.Container):
                    if self.is_child(widget, child):
                        return True
            else:
                return False
    
        def on_viewport_set_focus_child(self, _viewport, _child):
            idle_add(self.scroll_slide_viewport)
    
        def scroll_slide_viewport(self):
            """Scroll the viewport if needed to see the current focused widget"""
            widget = self.window.get_focus()
            if not self.is_child(widget, self.main_widget):
                return
    
            _wleft, wtop = widget.translate_coordinates(self.main_widget, 0, 0)
            wbottom = wtop + widget.get_allocation().height
    
            top = self.vadj.value
            bottom = top + self.vadj.page_size
    
            if wtop < top:
                self.vadj.value = wtop
            elif wbottom > bottom:
                self.vadj.value = wbottom - self.vadj.page_size
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple form interface set up that send username and password information
I have a fairly large CRUD WinForm app that has numerous objects. Person, Enrollment,
I have an array of JButtons which form a keypad interface. After six numbers
I have form that displays several keywords (standard set of choice lists that changes
I have a data processing system that generates very large reports on the data
I have a zoomable form-interface like MS Word. The form contains +70 controls (Richtextbox,
I have a server written in Erlang with a custom binary interface that gets
My scenario: Windows Forms Application with a base master (mdi) form. An Interface that
I have an interface and these methods: public interface Form { public void setFirstName
I have to interface with a slightly archaic system that doesn't use webservices. In

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.