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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:13:11+00:00 2026-06-09T19:13:11+00:00

I have a GtkTextView , where I would like to be able to center

  • 0

I have a GtkTextView, where I would like to be able to center the cursor vertically in the center.

If the cursor is moved, the text should scroll up (or down), but the cursor should still stay in center position.

I tried several things: Adding a margin on the first and last character of the textview, but that makes problems when adding text behind the first and last character. Also its not nice if one selects the first line, the selection color expands into the “empty” room.

In short, I need to:

  1. Add a margin before the first line
  2. Add a margin after the last line
  3. Scroll text to center on cursor_move or text_changed (I currently solved this with
cursor_iter = self.TextBuffer.get_iter_at_mark(cursor)
fflines = round(self.window_height/(2*20))
cursor_iter.forward_visible_lines(fflines)
self.TextEditor.scroll_to_iter(cursor_iter, 0.0, True, 0, 0.5)

However, with this approach I would need several newlines at the end of my textview. So if someone knows a better solution to that, I’d be happy to hear it)

I was thinking about doing pixelbased scrolling, but I don’t know how to go about this.

I’d be happy to hear some suggestions!

  • 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-09T19:13:12+00:00Added an answer on June 9, 2026 at 7:13 pm

    Apparently nobody came up with an answer.

    I finally hacked something together that is somehow working.
    It might not be the cleanest code, but who cares?

    Actually, since there is no way to add padding to a textbox, it adds newlines at the beginning and the end of the textfile to get sort of a padding.

    You can find my implementation here: Launchpad project for UberWriter

    If you want to know more, feel free to ask me by mail.

    Cheers, Wolf

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

Sidebar

Related Questions

I would like to have a GtkTextView in my (Python) program which shows text
I would like to make a custom Text Editor for Gtk# (maybe inherited from
Have a recurring situation, petty I know, but I'd like to consolidate the following:
Have a text box which get data for price. If someone enter something like
Have a look at the menu link Produkter on http://marckmann.se/ I would like to
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
Have converted devise new session from erb to Haml but doens't work, this is
Have searched the database but need to specifically sum(of hours flown or days off)in
have a php code like this,going to convert it in to C#. function isValid($n){
Have one Doubt In MVC Architecture we can able to pass data from Controller

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.