0

I am beginner with PyGObject.

entry = Gtk.Entry()

Is there some method for setting the text alignment for Gtk.Entry in PyGObject ?

Sanjay Prajapat
  • 253
  • 2
  • 13

1 Answers1

1

You need to use Gtk.Entry.set_alignment() and configure xalign to 1 (0 is left, 0.5 is centered, 1 is right).

Here is an MCVE:

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

class EntryWindow(Gtk.Window):

    def __init__(self):
        super().__init__(title='Entry Widget')
        self.set_size_request(200, 100)
        self.entry = Gtk.Entry()
        self.entry.set_text("Hello World")
        self.entry.set_alignment(xalign=1)
        self.add(self.entry)

win = EntryWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()

GUI

adder
  • 3,512
  • 1
  • 16
  • 28