简体   繁体   中英

pygtk textview tab width?

Is there a way to set the tab width of the pygtk TextView widget to be something other than 8spaces?

Right now I tried textview.set_tabs(pango.TabArray(4, False)) However, it seems like I misunderstood the docs. What the actual way to do it?

Thanks

See the docs for pango.TabArray : your statement pango.Tabarray(4, False) creates a tab array with four tab stops, all at position 0 points. What you want is this:

tabs = pango.TabArray(1, True)
tabs.set_tab(0, pango.TAB_LEFT, desired_tab_width)
textview.set_tab(tabs)

The value of desired_tab_width is not in spaces, however. See the function set_tab_stops_internal() in this code from GtkSourceView to see how they calculate the width of a space.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM