pygobject

Converting PIL GdkPixbuf

馋奶兔 提交于 2019-11-28 04:11:42
问题 How can I convert PIL Image in pixbuf?. I tried to change many examples but no solution import array from gi.repository import GdkPixbuf def image2pixbuf(self,im): arr = array.array('B', im.tostring()) height, width = im.size return GdkPixbuf.Pixbuf.new_from_data(arr, GdkPixbuf.Colorspace.RGB, True, 8, width, height, width * 4) Error TypeError: new_from_data () takes Exactly 9 arguments (7 given) I use Pygobject https://live.gnome.org/PyGObject 回答1: You are passing less arguments than

Python cannot install PyGObject

五迷三道 提交于 2019-11-28 00:33:16
问题 I try install pygobject by pip pip install --user PyGObject but I doesn't work: Collecting PyGObject Using cached pygobject-2.28.3.tar.bz2 Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 20, in <module> File "C:\Users\A\AppData\Local\Temp\pip-build-phby_jwb\PyGObject\ setup.py", line 272 raise SystemExit, 'ERROR: Nothing to do, gio could not be found and is essential.' ^ SyntaxError: invalid syntax -------------------------------

How to draw a GdkPixbuf using GTK3 and PyGObject

你说的曾经没有我的故事 提交于 2019-11-27 22:16:40
问题 I have a small application that uses a DrawingArea to draw a simple map using PyGObject and GTK3 . I load a Pixbuf using from gi.repository import Gtk, GdkPixbuf pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size("logo.png", 25, 25) and then try to draw it in the DrawingArea 's draw event signal def draw(self, widget, context): window = widget.get_window() ctx = window.cairo_create() ctx.set_source_pixbuf(pixbuf, 0, 0) but I get the error message "AttributeError: 'cairo.Context' object has no

How to bind a text domain to a local folder for gettext under GTK3

南楼画角 提交于 2019-11-27 19:25:41
With gettext you can either use the default system-wide locale directory, or specify one yourself using bindtextdomain . This is useful when running a program directly from source when the compiled .mo translation files are not available in the system's default location. In Python you would do this: import gettext from gettext import gettext as _ gettext.bindtextdomain('nautilus-image-manipulator', '/path/to/mo/folder') gettext.textdomain('nautilus-image-manipulator') where /path/to/mo/folder contains the familiar fr/LC_MESSAGES/nautilus-image-manipulator.mo structure. Calls like this: print _

GtkDialog mapped without a transient parent

落爺英雄遲暮 提交于 2019-11-27 05:21:44
问题 I have a GUI built in Glade (3.18) which is called by a Python 3 program (using PyGObject). I get a lot of warnings when running the program (Fedora 21) that say: Gtk-Message: GtkDialog mapped without a transient parent. This is discouraged. How can I fix this warning? I tried filling in the field Transient for: main_window in Glade for all the dialog windows, but the warnings still appear. 回答1: You fix this warning by giving the GtkDialog a parent to be modal to. The relevant functions are

PyCharm can not resolve PyGObject 3.0, but code runs fine

北城余情 提交于 2019-11-27 01:07:03
问题 I'm using PyCharm 2.5 on Ubuntu 11.10, trying to develop an application using PyGObject 3.0 on Python 3.2.2. I've installed the Ubuntu package python3-gobject, and when I run my code, it works exactly as expected. However, PyCharm can not seem to find any of the PyGObject modules. It says Unresolved refrence: 'Gtk' when I hover over Gtk in my import statement, and of course none of the auto-completion works. This is my code: #!/usr/bin/env python3 from gi.repository import Gtk win = Gtk

How to bind a text domain to a local folder for gettext under GTK3

坚强是说给别人听的谎言 提交于 2019-11-26 19:52:31
问题 With gettext you can either use the default system-wide locale directory, or specify one yourself using bindtextdomain . This is useful when running a program directly from source when the compiled .mo translation files are not available in the system's default location. In Python you would do this: import gettext from gettext import gettext as _ gettext.bindtextdomain('nautilus-image-manipulator', '/path/to/mo/folder') gettext.textdomain('nautilus-image-manipulator') where /path/to/mo/folder