pygtk

How do I make a GTK 2 list with multiple selection?

老子叫甜甜 提交于 2020-06-29 03:33:28
问题 In a GTK 3 release, the ListBox widget added supported for multiple elements being selected from the list: I'd like to achieve the same effect with GTK 2. I'm considering using a ScrolledWindow with a VBox of CheckButton 's. I fear it's not going to look very good though; like this, but with a scrollbar: Does anyone know a good way to emulate the functionality in the first image using GTK 2? 回答1: It turns out there was a method of doing just this buried in the documentation! In fact, you

Ubuntu - Anaconda 2020.02 - Namespace Gtk not available

孤人 提交于 2020-06-28 05:22:15
问题 This is on Ubuntu 16.04 LTS. I've run into the same issue as this question: ValueError: Namespace Gtk not available I've done the following to set things up for gtk3 conda install -c conda-forge pygobject sudo apt-get install libgtk-3-dev sudo apt install python3-gi gobject-introspection gir1.2-gtk-3.0 However, the simple test program at: https://python-gtk-3-tutorial.readthedocs.io/en/latest/introduction.html fails, with the same error: Python 3.7.7 (default, Mar 26 2020, 15:48:22) [GCC 7.3

How to install pygtk 3 on Mac OS X?

我与影子孤独终老i 提交于 2020-05-23 13:12:43
问题 What I tried: brew install pygobject3 --with-python@2 gtk+3 brew install pygtk3 brew install pygobject3 pip install pygobject python -c 'import gi; gi.require_version("Gtk", "3.0")' Result: ValueError: Namespace Gtk not available for version 3.0 Note that I'm running conda, with python 3.6; and Mac OS X High-Sierra I read through the following questions/answers before posting: Easiest way to install pygtk on Mac OS X Python Gtk3 executable https://github.com/neovim/python-gui/issues/33 https:

Glade - Invalid object type 'WebKitWebView' when loading from file. works on Glade Application

怎甘沉沦 提交于 2020-03-25 12:59:46
问题 I am building a python GTK application and I used Glade to define the interface. (using the Glade Interface Designer). Everything look good on Glade but when I try to create the GUI from my Python program it gives a error loading Webkit related views: Glade - Invalid object type 'WebKitWebView' It works fine in Glade Designer and also if I create the widgets manually, but the Builder doesn't like it. I am building the ui like this: GtkBuilder = Gtk.Builder.new_from_file("glade/main.glade")

Issue launching X11 app via NSTask

為{幸葍}努か 提交于 2020-03-05 07:29:17
问题 My app uses NSTask to execute shell scripts, one of those scripts launches an X11 app (specifically meld ). I would have expected this to work: #!/bin/bash source ~/.profile # setup $PATH/etc meld . But it fails with: gtk.icon_theme_get_default().append_search_path(meld.paths.icon_dir()) Traceback (most recent call last): File "/usr/local/bin/meld", line 132, in <module> gtk.icon_theme_get_default().append_search_path(meld.paths.icon_dir()) AttributeError: 'NoneType' object has no attribute

Gtk.ListStore(*datatypes) string error

若如初见. 提交于 2020-03-04 08:31:28
问题 self.ip_liststore = Gtk.ListStore(*datatypes) where datatypes = [str,str,str] I have also tried datatypes = ['gchararray','gchararray'] And the interpreter replies with Traceback (most recent call last): File "./gtktutorial.py", line 128, in <module> main() File "./gtktutorial.py", line 119, in main [str,str,str,str,str,str,str]) File "./gtktutorial.py", line 37, in __init__ self.ip_liststore = Gtk.ListStore(*datatypes) File "/usr/lib/python2.7/dist-packages/gi/overrides/Gtk.py", line 943, in

Python : Get gtk.treeview selection from another widget

不羁岁月 提交于 2020-02-05 15:50:31
问题 It looks like the only way to get the selected item of a gtk.TreeView() is to actually click on it : tree_selection = self.treeview.get_selection() tree_selection.connect('changed', self.my_callback) self.treeview.connect('row-activated', self.my_other_callback) But what if I'm listing files in my treeview, and need a "file properties" menu item? Or a play button, that needs to access selected file to pass the filename to a player class / method ? Bonus question : How to call my_other

Asynchronously updating PyGTK tray icon

假装没事ソ 提交于 2020-02-05 05:57:25
问题 As explained here, I have a simple tray icon using PyGTK. Being very new to GTK, it appears to me that gtk.main() is synchronous, blocking any further processing until the respective UI is closed. So how can I periodically (e.g. every 5 seconds) update/refresh StatusIcon 's icon - do I have to resort to Twisted et al. for this? 回答1: You can use gobject.timeout_add() to add periodical tasks. The first parameter is the interval in seconds, the second parameter is the callback you want to be

Cairo context and persistence?

时光怂恿深爱的人放手 提交于 2020-02-02 06:32:48
问题 I am just getting started using pycairo, and I ran into the following interesting error. The program I write creates a simple gtk window, draws a rectangle on it, and then has a callback to draw a random line on any kind of keyboard input. However, it seems that with each keyboard input, I have to create a new context, or I get an error at the moment the program receives first keyboard input (specifically, on the .stroke() line). Error is as follows, if it matters. 'BadDrawable (invalid

Cairo context and persistence?

不想你离开。 提交于 2020-02-02 06:32:43
问题 I am just getting started using pycairo, and I ran into the following interesting error. The program I write creates a simple gtk window, draws a rectangle on it, and then has a callback to draw a random line on any kind of keyboard input. However, it seems that with each keyboard input, I have to create a new context, or I get an error at the moment the program receives first keyboard input (specifically, on the .stroke() line). Error is as follows, if it matters. 'BadDrawable (invalid