pygtk

Opencv & PyGi : how to display an image read by opencv

倾然丶 夕夏残阳落幕 提交于 2020-01-06 19:25:29
问题 I want to display an image in PyGi, the image is read first by opencv. But,it fails. from gi.repository import Gtk, GdkPixbuf import cv2 import numpy as np window = Gtk.Window() image = Gtk.Image() image.show() window.add(image) window.show_all() im = cv2.imread("file.bmp") a = np.ndarray.tostring(img) h, w, d = img.shape p = GdkPixbuf.Pixbuf.new_from_data(a,GdkPixbuf.Colorspace.RGB, False, 8, w, h, w*3, None, None) image.set_from_pixbuf(p) Gtk.main() But the result is a black image. Moreover

Opencv & PyGi : how to display an image read by opencv

只愿长相守 提交于 2020-01-06 19:25:02
问题 I want to display an image in PyGi, the image is read first by opencv. But,it fails. from gi.repository import Gtk, GdkPixbuf import cv2 import numpy as np window = Gtk.Window() image = Gtk.Image() image.show() window.add(image) window.show_all() im = cv2.imread("file.bmp") a = np.ndarray.tostring(img) h, w, d = img.shape p = GdkPixbuf.Pixbuf.new_from_data(a,GdkPixbuf.Colorspace.RGB, False, 8, w, h, w*3, None, None) image.set_from_pixbuf(p) Gtk.main() But the result is a black image. Moreover

How to avoid closing of Gtk.Dialog in Python?

与世无争的帅哥 提交于 2020-01-05 15:08:13
问题 I have a form in a Gtk.Dialog which has an "Ok" button and a "Cancel" button. When I click on the Ok button, the dialog returns 1 and when I click on Cancel button, it returns 0. What I want to make is to validate the fields of the form so that if any field has invalid data, like letters in a numeric field or empty fields, the dialog can not be destroyed if Ok button is pressed. 回答1: You could define a custom dialog. Here you can find an example. Make shure to destroy the dialog only if your

Unable to import gtk after installing PyGObject

做~自己de王妃 提交于 2020-01-05 12:55:23
问题 I can import gtk without any problem previously. I made a GUI in glade for GTK+ 3. Then I thought that I would like to try GTK+ 3. So I installed PyGObject. I later found out that PyGObject has little documentation and I'm using Windows (makes things worse I know). The problem is here, I can't use import gtk anymore. Neither can I use from gi.repository import Gtk . I've tried installing PyGTK bundle again but it doesn't help. >>> import gtk Traceback (most recent call last): File "<pyshell#0

PYGTK redirect event to TreeView

杀马特。学长 韩版系。学妹 提交于 2020-01-05 10:04:50
问题 In PyGTK, I have an Entry and a TreeView. When a TreeView is focused, the key events (Up, Down, PageUp, PageDown) move selection in the view in a certain way. I want to intercept these key events when the Entry is focused, and redirect them to the TreeView so that the selection is moved as though the TreeView was focused. I can intercept the key press events on the Entry and determine if it's for the keys I need, but I have trouble with passing it to the TreeView. # In UI initialization self

How to run an infinite while loop in pygtk?

☆樱花仙子☆ 提交于 2020-01-05 07:01:20
问题 I am creating an application in pygtk which involves running an infinite loop. The loop, I think, interferes witk gtk.main() and hence the application does not respond. Actually, I am building a server-type application which continuously listens for client connections.Plzzz help....I am a newbie in this. This is a sample of what I was initially trying to do.(For those who wanted the code) while 1: s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.bind(('',2727)) s.listen(1) c,d=s.accept()

How to run an infinite while loop in pygtk?

梦想的初衷 提交于 2020-01-05 07:01:09
问题 I am creating an application in pygtk which involves running an infinite loop. The loop, I think, interferes witk gtk.main() and hence the application does not respond. Actually, I am building a server-type application which continuously listens for client connections.Plzzz help....I am a newbie in this. This is a sample of what I was initially trying to do.(For those who wanted the code) while 1: s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.bind(('',2727)) s.listen(1) c,d=s.accept()

Segmentation fault while drawing frame from webcam to DrawableArea in pygtk3

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-05 04:06:12
问题 As title suggests I am reading frames from my webcam (using openCV, i want to do some follow up feature detection with it) and want to write the result to a pyGTK3 DrawableArea widget. Following this answer, which i will quote for convenience: The following seems to do the job: def draw(self, widget, context): Gdk.cairo_set_source_pixbuf(context, self.pixbuf, 0, 0) context.paint() One question still remains: Is this the preferred way of doing things? So i am now using: def _on_drawablearea

pyGtk: Gtk missing error when get version

ぐ巨炮叔叔 提交于 2020-01-04 11:13:17
问题 When I startup /usr/bin/sniff which is a GUI monitor of dogtail I got below error: Traceback (most recent call last): File "/usr/bin/sniff", line 13, in <module> gi.require_version('Gtk', '3.0') File "/usr/local/lib/python2.7/site-packages/gi/__init__.py", line 48, in require_version raise ValueError('Namespace %s not available' % namespace) ValueError: Namespace Gtk not available And I execute the command python -c 'from gi.repository import Gtk' I got: ERROR:root:Could not find any typelib

pyGtk: Gtk missing error when get version

最后都变了- 提交于 2020-01-04 11:12:40
问题 When I startup /usr/bin/sniff which is a GUI monitor of dogtail I got below error: Traceback (most recent call last): File "/usr/bin/sniff", line 13, in <module> gi.require_version('Gtk', '3.0') File "/usr/local/lib/python2.7/site-packages/gi/__init__.py", line 48, in require_version raise ValueError('Namespace %s not available' % namespace) ValueError: Namespace Gtk not available And I execute the command python -c 'from gi.repository import Gtk' I got: ERROR:root:Could not find any typelib