Hey,

this is not a question about the development of GTK+, but about using GTK+
for app development - gtk-app-devel-list is a better place for this, so
moving there.

On Thu, Jun 1, 2017 at 3:10 PM Karan Ahuja <karan26.ah...@gmail.com> wrote:

>
> I wish to display 3 lines in gtk textview as below
>
> software-lumapix                                  +2000
> software-adigiprints                              +3000
> software-yst                                          +3000
>
> on command line i see the strings as above as required.
>

That is beccause terminals usually use monospace fonts, that is every
character takes up the same width. So using a fixed character could for
alignment works in that context ...



> but when i copy the output from commandline to gtk text view or gmail here
> or use
> set_text method on the text buffer - the alignment is lost and i see this
>
> software-lumapix                                  +2000
> software-adigiprints                              +3000
> software-yst                                      +3000
>


... while it doesn't in contexts where variable-width fonts are used (where
for example "l" and "i" take up less width than "m" and "w").


my simple code is as below in python gtk+
>
> str1 = '{message: <{width}}'.format(message="software-lumapix", width=50)
> str1 = str1+'+2000'
> print str1
> str2 = '{message: <{width}}'.format(message="software-adigiprints",
> width=50)
> str2 = str2+'+3000'
> print str2
> str3 = '{message: <{width}}'.format(message="software-yst", width=50)
> str3 = str3+'+3000'
> print str3
> self.view.get_buffer().set_text(str1+'\n'+str2+'\n'+str3)
>
>
> Please guide - how can i align the numbers right aligned.
>

One option is to set custom tab stops with gtk_text_view_set_tabs(), and
then append '\t' to each string on the left instead of setting a character
width.

Cheers,
Florian
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to