gtk3

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

Gtk+ icon missing when running in MS Windows

孤者浪人 提交于 2019-12-21 05:48:23
问题 I have a C/GTK+ application developed on Ubuntu, and I want to cross-compile it so that it runs on MS Windows. I followed this guide to set up the compiler, and the program was compiled successfully, and it runs on MS Windows. However, the icons on a Search Entry were missing. This is what I get when I'm on Ubuntu: This is what I get when I run the program in MS Windows (or Wine): In addition, the terminal shows the following: (main.exe:8): Gtk-WARNING **: Could not find the icon 'edit-find

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

gtk python grid resize

随声附和 提交于 2019-12-20 04:12:28
问题 Following the official tutorials about containers. I have the follwoing code import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk class MainWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="test") grid = Gtk.Grid() self.add(grid) button1 = Gtk.Button(label="Button 1") button2 = Gtk.Button(label="Button 2") button3 = Gtk.Button(label="Button 3") button4 = Gtk.Button(label="Button 4") button5 = Gtk.Button(label="Button 5") button6 = Gtk.Button(label=

How do I connect a custom function to the clicked action of a GTK Button?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 02:49:10
问题 I am working my way through the Vala GTK+3 tutorial provided by Elementary OS. I understand that this code: var button_hello = new Gtk.Button.with_label ("Click me!"); button_hello.clicked.connect (() => { button_hello.label = "Hello World!"; button_hello.set_sensitive (false); }); uses a Lambda function to change the button's label when it's clicked. What I want to do is call this function instead: void clicked_button(Gtk.Button sender) { sender.label = "Clicked. Yippee!"; sender.set

Get the window handle in PyGI

北慕城南 提交于 2019-12-19 11:28:42
问题 In my program I use PyGObject/PyGI and GStreamer to show a video in my GUI. The video is shown in a Gtk.DrawingArea and therefore I need to get it's window-handle in the realize -signal-handler. On Linux I get that handle using: drawing_area.get_property('window').get_xid() But how do I get the handle on Windows? I searched on the internet but found only examples for PyGtk using window.handle which does not work using PyGI. The GStreamer documentation provides an example which uses the GDK

Show icon or color in Gtk TreeView tree

吃可爱长大的小学妹 提交于 2019-12-19 09:44:29
问题 I am having difficulty loading a file or displaying a colour in one of the columns of a Gtk TreeView (Python binding of GTK3). An example taken from QGIS shows a icon in the first row and a blue circle in the second row. The colour is taken from the layer properties: My code looks like this but does not load the icon.png file in the same directory: #!/usr/bin/python3 from gi.repository import Gtk, Gdk, GdkPixbuf class MyWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self) self

GTK+ Vte.Terminal().fork_command_full removed?

╄→гoц情女王★ 提交于 2019-12-19 09:23:53
问题 I noticed this last week. All my code on ubuntu 15.04 was working fine using Vte.Terminal().fork_command_full Also this documentation site was showing this function as well, but does not now. Has this function been removed? If so, then what is the next simplest alternative to get a virtual terminal widget working. As this answer suggests the use of the above command, what is the next best way to get this widget up and running? NOTE: I am using python3 for this code 回答1: Update: This answer is

How do I change the property of a GTK widget such as a stack?

我的未来我决定 提交于 2019-12-19 09:15:15
问题 I've been taking a quick look at the GTK 3.10 documentation for a GtkStack. https://developer.gnome.org/gtk3/3.10/GtkStack.html It mentions that the child added to a GtkStack is given a property "icon-name". My question is - how can I change the value of this property. The reason - I want to change the GtkStackSwitcher button to be an icon not text but I want to code this - not use a GktBuilder UI. If you look at the gtk3-demo - Stack demo and the UI file you can see the GtkSwitcher has an

How to create a complete menu using GIO Actions in PyGI GTK?

╄→гoц情女王★ 提交于 2019-12-19 06:30:10
问题 I'm trying to convert the menubar in my Gtk app so it will use GActions (from the Gio) as opposed of GtkActions in Python3 using GObject Instrospection. I've been trying to figure it out on my own but so far it seems awfully complicated and I didn't have much luck with it. If someone could please post an example of how to create a simple menu GAction based with A submenu A menu item with a stock ID icon / hotkey A menu item with a non-stock icon / hotkey A checked menu item And radio menu