Hi, I am developing an application where I have to show/draw whitespaces, tabs and enter.
To achieve this I am trying to pass Cairo Context to TextView. I am Attaching an example where on the TextView where I want to draw a square over the texts. I am using GTK3.18, Python2.7 and Windows7. Please help me how to draw on textview -- Dhrubajyoti Doley, Mobile: 09220919356 Email: dhruba.do...@gmail.com, Mumbai, India
#!/usr/bin/env python import gi gi.require_version('Gtk', '3.0') gi.require_version('GdkX11', '3.0') from gi.repository import Gtk from gi.repository import Gdk import cairo def draw_cb(widget, cr): width = widget.get_allocated_width() height = widget.get_allocated_height() context = widget.get_style_context() Gtk.render_background(context, cr, 0, 0, width, height) cr.set_source_rgba(0,0,0,0.5) cr.rectangle(10,10, 100, 100) cr.fill() return False window = Gtk.Window() window.set_default_size(200, 200) window.connect("destroy", Gtk.main_quit) textview = Gtk.TextView() textview.set_wrap_mode(Gtk.WrapMode.WORD_CHAR) textbuffer = textview.get_buffer() textbuffer.set_text("Hello world"*18, -1) textview.connect('draw', draw_cb) textview.queue_draw() window.add(textview) window.show_all() Gtk.main()
_______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list