pygobject

How to limit number of decimal places to be displayed in Gtk CellRendererText

余生长醉 提交于 2019-12-04 19:21:27
I am trying to limit the amount of decimal places shown in a Gtk.CellRendererText. Currently a float number field is shown with 6 decimal places, but I would like to have just 1. This test code should work on Linux: #!/usr/bin/python3 from gi.repository import Gtk class MyWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="Hello World") self.set_default_size(200, 200) self.liststore = Gtk.ListStore(float) treeview = Gtk.TreeView(model=self.liststore) self.liststore.append([9.9]) self.liststore.append([1]) xrenderer = Gtk.CellRendererText() xrenderer.set_property("editable"

Use of the Gtk.GLArea in Pygobject GTK3

允我心安 提交于 2019-12-04 15:02:05
The documentation for use of the python wrappers for GTk3 are somewhat limited. I have found several of the common widget examples. I am trying to use the Gtk.GLArea widget. The API documentation is for C and I have not had much luck guessing the equivalent python calls to use this widget. In the example the widget is created using the following C code: // create a GtkGLArea instance GtkWidget *gl_area = gtk_gl_area_new (); g_signal_connect (gl_area, "render", G_CALLBACK (render), NULL); Then the render function has openGL commands in it: static gboolean render (GtkGLArea *area, GdkGLContext

Editing GtkWidget attributes/properties

左心房为你撑大大i 提交于 2019-12-04 14:01:18
In most pygtk widget pages, they contain sections called 'Attributes', 'Properties', and 'Style Properties'. How can I change these properties and attributes? 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 documentation can be accessed through this attribute. For example, btn1.props.label = 'StackOverflow' and btn1.props

How do I take a screenshot using GdkPixbuf?

时光怂恿深爱的人放手 提交于 2019-12-04 12:51:12
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. 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-screenshot-using-gdkpixbuf

pango attributes with pygobject

亡梦爱人 提交于 2019-12-04 11:55:39
问题 I have the following code, that uses pygtk: attr = pango.AttrList() attr.change(pango.AttrSize(( 50 * window_height / 100) * 1000, 0, -1)) attr.change(pango.AttrFamily("Sans", 0, -1)) attr.change(pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1)) attr.change(pango.AttrForeground(65535, 65535, 65535, 0, -1)) self.label.set_attributes(attr) I'm trying to port it to pygobject, but there is no class Pango.AttrFamily, neither Pango.AttrWeight, neither Pango.AttrForeground (and I can not instantiate a

How to install PyGI (Python Gobject Introspection) on Windows?

和自甴很熟 提交于 2019-12-04 10:34:51
Installing the python interpreter: http://python.org/ftp/python/2.7.2/python-2.7.2.msi and: http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.24/pygtk-all-in-one-2.24.0.win32-py2.7.msi run: python import gtk ...works Is there a PyGI all in one installer? run: python import gi Error: Unable to import module gi ...how to make it work on Windows? On Ubuntu 11.04 runs without installing anything. I think you run into two problems here. First of all, I'm not sure that the PyGObject versions featuring introspection are available for Windows. More importantly, only the GTK 2 libraries are

Create python object from memory address (using gi.repository)

旧街凉风 提交于 2019-12-04 07:18:26
Sometimes I need to call a gtk/gobject function that only exists in C, but returns an object that has a python wrapper. Previously I used a solution based on ctypes that worked well: http://faq.pygtk.org/index.py?req=show&file=faq23.041.htp Now that I swiched from PyGtk ("import gtk") to GObject-introspection ("from gi.repository import Gtk"), what can I use instead? The _PyGObject_API interface has changed at some point. I needed to drop the register_sinkfunc function. The following works: from gi.repository import Gio, GLib import gi import ctypes class _PyGObject_Functions(ctypes.Structure)

Python GTK+ Canvas

无人久伴 提交于 2019-12-04 07:00:57
I'm currently learning GTK+ via PyGobject and need something like a canvas. I already searched the docs and found two widgets that seem likely to do the job: GtkDrawingArea and GtkLayout. I need a few basic functions like fillrect or drawline ... In fact these functions are available from c but I couldn't find directions how to use them from python. Can you recommend a tutorial or manpage that deals with their python equivalents ? If you have a better idea how to get something similar to a canvas every tip would be appreciated. I'm still learning and as long as it can be embedded within my Gtk

How to install PyGObject with Python 3 support

蹲街弑〆低调 提交于 2019-12-04 05:24:20
I've been trying to install PyGObject using a variety of methods. First, using apt-get but that only installs it for Python 2.x. Next I attempted to compile it myself but I have been having problems getting it to compile for Python 3. Does anyone know how to install it? First you need to install python3 and the development headers. Then you need to tell configure to use python3: PYTHON=python3 ./configure Compile and install normally make make install You should then be able to use pygobject from python3. 来源: https://stackoverflow.com/questions/7065310/how-to-install-pygobject-with-python-3

PyGObject and glade send window to the front

假装没事ソ 提交于 2019-12-04 05:19:36
问题 im having some problems to send to the front a GTK window. I have a main window ( window_root ) with a button that launches another window ( window_programs ). with this commands: window_root.hide() window_programs.show() then, in window_programs , i have a button that displays another window ( window_list ) with the command: window_list.show() window_list is modal. The problem was that window_list appeared at the back of window_programs . so i did some research and i found window_list.show()