pygobject

Gtk3 | Python: Namespace Gtk not available, Typelib file for namespace 'Gtk' (any version) not found (using macos)

怎甘沉沦 提交于 2019-12-23 19:35:09
问题 I'm trying to start making a little GTK program, and to test GTK installation and config I'm trying to execute a simple helloworld script. Just using a simple example given by pygobject documentation: import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk window = Gtk.Window(title="Hello World") window.show() window.connect("destroy", Gtk.main_quit) Gtk.main() First issue (resolved): from gi.repository import Gtk Gtk not found, but a new autoimport give me this import: from

Parallel drawing with GTK and Cairo in Python 3

℡╲_俬逩灬. 提交于 2019-12-23 17:02:18
问题 I am making a GTK application that will draw complex images that can take long time to finish. Because of that I can't do the drawing in the DrawingArea's 'draw' callback. I decided to use Python's multiprocessing module that allows true parallelism and does not have problems with GTK and thread-safety. Python's multiprocessing module uses Pickle protocol to communicate between processes. GTK and Cairo objects do not implement the protocol. My solution was to convert the Cairo surface to

Overriding virtual methods in PyGObject

懵懂的女人 提交于 2019-12-23 16:12:37
问题 I'm trying to implement the Heigh-for-width Geometry Management in GTK with Python for my custom Widget. My widget is a subclass from Gtk.DrawingArea and draws some parts of an Image. As I understood the GTK Docs (link above) I have to implement the following 4 methods: GtkWidgetClass.get_preferred_width() GtkWidgetClass.get_preferred_height() GtkWidgetClass.get_preferred_height_for_width() GtkWidgetClass.get_preferred_width_for_height() Now wondering where to implement this in Python. I

Python PyGOobject treeview: confirm edit after move between cells with Tab key

时光怂恿深爱的人放手 提交于 2019-12-23 02:19:25
问题 After searching for a long time I found a solution (pretty simple) to move between cells of a treeview grid using Tab key and mantaining cells in edit mode. Now I've got a problem: cell edit confirmation happens only after pressing Enter key. If I press Tab key a editing_canceled event appears to be triggered. How to solve it? How to permit the data confirmation also on tab key press? This is my event handler for treeview key-press-event: def key_tree_Tab(self, treeview, event,namewidget):

How to install PyGObject through PyCharm

瘦欲@ 提交于 2019-12-22 17:04:45
问题 I tried to install PyGobject through PyCharm but when I click on install package i will get this window: This is what the "Command output" is: 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 1, in <module> File "C:\Users\Gebruiker\AppData\Local\Temp\pycharm-packaging0.tmp\PyGObject\setup.py", line 272 raise SystemExit, 'ERROR: Nothing to do, gio could not be found and is

Load GTK-Glade translations in Windows using Python/PyGObject

走远了吗. 提交于 2019-12-22 12:19:19
问题 I have a Python script that loads a Glade-GUI that can be translated. Everything works fine under Linux, but I am having a lot of trouble understanding the necessary steps on Windows. All that seems necessary under Linux is: import locale [...] locale.setlocale(locale.LC_ALL, locale.getlocale()) locale.bindtextdomain(APP_NAME, LOCALE_DIR) [...] class SomeClass(): self.builder = Gtk.Builder() self.builder.set_translation_domain(APP_NAME) locale.getlocale() returns for example ('de_DE', 'UTF-8'

How do I take a screenshot using GdkPixbuf?

﹥>﹥吖頭↗ 提交于 2019-12-21 20:18:27
问题 Using PyGTK, I used to be able to take a screenshot using gtk.gdk.pixbuf.get_from_drawable . I can't seem to figure out how to do that using PyGObject and GdkPixbuf. I've tried get_from_drawable and get_from_window but neither work in PyGObject. Thanks in advance. 回答1: Use Gtk.OffscreenWindow: offscreen_window = Gtk.OffscreenWindow() offscreen_window.add(widget_that_needs_screenshotting) pixbuf = offscreen_window.get_pixbuf() 来源: https://stackoverflow.com/questions/14544500/how-do-i-take-a

Editing GtkWidget attributes/properties

此生再无相见时 提交于 2019-12-21 19:48:27
问题 In most pygtk widget pages, they contain sections called 'Attributes', 'Properties', and 'Style Properties'. How can I change these properties and attributes? 回答1: There are three ways to change properties: As in zheoffec's answer, use the set_property() function (or set_style_property() for style properties.) This function is actually not necessary in Python, but it is there for completeness because it is part of the C API. Use the props attribute. Any property that you find in the

A sorted and filtered treemodel in Python Gtk+3..?

跟風遠走 提交于 2019-12-21 04:46:05
问题 I am trying to get a treemodel (a liststore in fact) that can be filtered and also sorted. I have the following piece of code self.modelfilter = self.liststore.filter_new() self.modelfilter.set_visible_func(\ self._visible_filter_function) self.treeview.set_model(self.modelfilter) where self.liststore and self.treeview are standard Gtk.ListStore and Gtk.TreeView objects that I get from a glade file, and self._visible_filter_function is a filtering function. The problem is that self

cannot import gi module python 3.6 on mac

偶尔善良 提交于 2019-12-20 03:23:28
问题 I am integrating gstreamer and pocketsphinx on mac using python 3.6; however, the first line of code, from gi import pygtkcompat , raises an error. The command: python3 demoapp_chinese.py returns Traceback (most recent call last): File "demoapp_chinese.py", line 1, in from gi import pygtkcompat ModuleNotFoundError: No module named 'gi' Here's how I install pygobject: brew install pygobject3 And when I try to get more info. I execute brew info pygobject3 which returns pygobject3: stable 3.30.4