How to get the text of a widget/window using python-xlib?
Question: I'm trying to find the whole text that is currently being edited in gedit
window. Firstly i tried to find out the current gedit tab that is focused, by
using Xlib.display. Now i got an Xlib.display.window object . Now i want to
find out the text that is in that particular window/widget using this window
object

And my code is like this

    
    
    import gtk, gobject, Xlib.display
    currentFocus=''
    def current_focused:
         global currentFocus
         display = Xlib.display.Display()
         window = display.get_input_focus().focus
         wmname = window.get_wm_name()
         wmclass = window.get_wm_class()
         if wmclass is None and wmname is None:
               window = window.query_tree().parent
               wmname = window.get_wm_name()
               if currentFocused!=wmname:
                       if window.get_wm_class()[0]=='gedit':
                              print "\nNow you are in : < %s >" % (wmname,)
                              # Here i have to find the text of the gedit's widget
          currentFocused=wmname
          return True
    gobject.timeout_add(1000, current_focused)
    gtk.main()
    

is there any API to get the text of a specific widget using
Xlib.display.window Please help me. I'm completely new in this area

Thank you


Answer: WM_CLASS / WM_NAME properties are only used to provide information to a window
manager ( hence WM prefix ) and not usually set on child windows. Check [GTK
source code](https://git.gnome.org/browse/gtk+/) if edit widget sets similar
properties, but in general it is not possible for external process to read
edit control text

