pygobject

DrawingArea Cannot Get XID

社会主义新天地 提交于 2019-11-30 19:39:28
问题 I have the following Python 2.7/PyGObject 3.0/PyGST 0.10 module: from gi.repository import Gtk, Gdk, GdkPixbuf import pango import pygst pygst.require('0.10') import gst import Trailcrest import os, sys import cairo from math import pi class Video: def __init__(self): def on_message(bus, message): if message.type == gst.MESSAGE_EOS: # End of Stream player.seek(1.0, gst.FORMAT_TIME, gst.SEEK_FLAG_FLUSH, gst.SEEK_TYPE_SET, 5000000000, gst.SEEK_TYPE_NONE, 6000000000) elif message.type == gst

Get font color of the current GTK theme

喜欢而已 提交于 2019-11-30 09:17:26
问题 I need to get the font color of the current theme. I found this question that explains it how to do it in C with gtk_style_lookup_color , but it seems that the function is deprecated. Making more researches I found the new function gtk_style_context_lookup_color But I have problems understanding the docs. Also, when I try to call it by using Gtk.style_context_lookup_color( .. ) I get that it doesn't exists! Is it because I need to call it with something like GtkStyleContext.style_context

Drawing in PyGobject (python3)

Deadly 提交于 2019-11-29 11:06:21
I'm trying to write simple graphic editor using PyGObject and python 3. I need to draw lines with different color and width using mouse. I found many examples like this but nothing more complex. How do I save drawn image between 'draw' events? Is there incremental way of drawing or do I have to redraw pane on each 'draw' event? I found out that I can save path but how can I save width and colors of drawn lines? Is there way create image outside 'draw' callback and only apply (draw) it inside callback? Here is what I have for now. #!/usr/bin/env python # -*- coding: utf-8 -*- from gi.repository

Python cannot install PyGObject

南楼画角 提交于 2019-11-29 07:04:21
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 ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in C:\Users\A\AppData\Local\Temp

How to draw a GdkPixbuf using GTK3 and PyGObject

╄→尐↘猪︶ㄣ 提交于 2019-11-29 06:47:17
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 attribute 'set_source_pixbuf'" If I'm reading the Gtk2 to Gtk3 migration guide correctly, this should

Has threading in GTK w/ Python changed in PyGObject introspection?

夙愿已清 提交于 2019-11-29 00:35:42
问题 I'm in the process of converting a program from PyGTK to PyGObject introspection for the first time and I've hit a roadblock with threading. I have a process that takes some time to complete, so I pop up a dialog with a progress bar on it and I use a thread to do the process and to update the progress bar. This worked fine with PyGTK but after converting to PyGObject, I get all the usual improper threading weirdness: the program hangs, but it seems to hang in different parts of the process,

Save the contents of a Gtk.DrawingArea or Cairo pattern to an image on disk

帅比萌擦擦* 提交于 2019-11-28 10:57:26
问题 I've got a small PyGI project which uses a Cairo image surface, which I then scale with a surface pattern and render on a Gtk.DrawingArea. I'd like to write the scaled version to a PNG file. I've tried to write from the original surface with Surface.write_to_png(), but it only writes in the original (i.e. non-scaled) size, so I'm stuck in there. Then I thought I could perhaps fetch the rendered image from the Gtk.DrawingArea and write that to disk, but I haven't found out how to do that in

gi.repository Windows

随声附和 提交于 2019-11-28 08:28:16
I'm developing an app which has to be 100% compatible on windows and on linux. On linux I have no problems, but on windows I came up with this message: from gi.repository import Gtk ImportError: No module named gi I installed pygobject, pygtkallinone, gtk.. what am I missing? gianmt Most of Havok answer is correct, except that documentation has been improved a lot lately, with a Tutorial: http://python-gtk-3-tutorial.readthedocs.org/en/latest/ Including a PDF version for offline reading: http://media.readthedocs.org/pdf/python-gtk-3-tutorial/latest/python-gtk-3-tutorial.pdf And a complete API

PyCharm can not resolve PyGObject 3.0, but code runs fine

和自甴很熟 提交于 2019-11-28 05:55:21
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.Window() win.connect("delete-event", Gtk.main_quit) win.show_all() Gtk.main() I've even tried making a

Error “Could not find any typelib for Gtk” with Python3 and GTK3

不羁岁月 提交于 2019-11-28 05:30:48
问题 I cannot make Python3 work with GTK3. I'm in a cluster context and I had everything recompiled from the sources. When I run a simple example : from gi.repository import Gtk win = Gtk.Window() win.connect("delete-event", Gtk.main_quit) win.show_all() Gtk.main() I have the following error : ERROR:root:Could not find any typelib for Gtk Traceback (most recent call last): File "gtk3_example.py", line 2, in from gi.repository import Gtk ImportError: cannot import name 'Gtk' 回答1: There are