pygtk

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

Start PyGTK cellrenderer edit from code

与世无争的帅哥 提交于 2019-12-04 10:01:34
问题 I have a treeview with an editable CellRendererText: self.renderer = gtk.CellRendererText() self.renderer.set_property('editable', True) But now I need to launch the edition from code instead from user, this is to focus the user attention in the fact he just created a new row and needs to be named. I tried this but does not work: self.renderer.start_editing( gtk.gdk.Event(gtk.gdk.NOTHING), self.treeview, str(index), gtk.gdk.Rectangle(), gtk.gdk.Rectangle(), 0) Neither does not throw errors,

Showing a gtk.Calendar in a menu?

若如初见. 提交于 2019-12-04 09:44:36
问题 I want to construct a context menu with a menu item for selecting a date. (The use case is selecting a bunch of items in a treeview and then setting a new due date for all the items.) Since a menuitem is a Gtk.Bin, I can specify any widget in place of a label. However, I can't seem to interact with the widget. If I click anywhere on the menu, the menuitem gets the click. So, I can't select a particular date, nor navigate months or years. How can I make the calendar get the mouse activity?

PyGTK/GIO: monitor directory for changes recursively

坚强是说给别人听的谎言 提交于 2019-12-04 08:43:47
问题 Take the following demo code (from the GIO answer to this question), which uses a GIO FileMonitor to monitor a directory for changes: import gio def directory_changed(monitor, file1, file2, evt_type): print "Changed:", file1, file2, evt_type gfile = gio.File(".") monitor = gfile.monitor_directory(gio.FILE_MONITOR_NONE, None) monitor.connect("changed", directory_changed) import glib ml = glib.MainLoop() ml.run() After running this code, I can then create and modify child nodes and be notified

gtk3+ and python rgba convert to hex

南楼画角 提交于 2019-12-04 06:54:24
问题 i using gtk3 i found that it use rgba for representing color, but the (red,green,blue,alpha) are not integer between 0-255 but floating point number between 0-1.0 , so i don't know how to convert from rgba to hex and vice-versa i have tried this code but its seem to not work : def convert_to_hex(rgba_color) : red = str(hex(int(rgba_color.red*255)))[2:].capitalize() green = str(hex(int(rgba_color.green*255)))[2:].capitalize() blue = str(hex(int(rgba_color.blue*255)))[2:].capitalize() return

How to put arbitrary widgets into a gtk.Menu?

浪子不回头ぞ 提交于 2019-12-04 05:20:19
How can any gtk.Widget (eg. a progress bar) be put into a gtk.Menu as one of the menu items? Quoting from the PyGTK documentation : The gtk.MenuItem and its derived widget subclasses are the only valid children of menus. So the answer is: You can't. But: As a gtk.MenuItem is a subclass of gtk.Bin it can hold any valid child widget. If you create a MenuItem without a label: item = gtk.MenuItem() you can add most gtk.Widget subclasses as a child to item . 来源: https://stackoverflow.com/questions/4350470/how-to-put-arbitrary-widgets-into-a-gtk-menu

How to set default button in PyGTK?

断了今生、忘了曾经 提交于 2019-12-04 05:15:41
I have very simple window where I have 2 buttons - one for cancel, one for apply. How to set the button for apply as default one? (When I press enter, "apply" button is pressed) However, I want to set focus to the first input widget (I can't use grab_focus() on the button) Any suggestions? Edit: After wuub 's answer it works visually good. However, when I press the button in different widget, it doesn't run callback of the default button. Example code: import os, sys, pygtk, gtk def run(button, window): dialog = gtk.MessageDialog(window, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_OK, "OK"

Launch default image viewer from pygtk program

可紊 提交于 2019-12-04 01:59:57
问题 I'm writing a PyGTK GUI application in Ubuntu to browse some images, and I'd like to open an image in the default image viewer application when it is double-clicked (like when it is opened in Nautilus). How can I do it? 回答1: I don't know specifically using PyGTK but: xdg-open opens the default app for a file so running something like this should work: import os os.system('xdg-open ./img.jpg') EDIT: I'd suggest using the subprocess module as in the comments. I'm not sure exactly how to use it

Python AppIndicator bindings -> howto check if the menu is open?

江枫思渺然 提交于 2019-12-03 23:11:25
Here is a minimal example of an AppIndicator: #!/usr/bin/python import gobject import gtk import appindicator if __name__ == "__main__": ind = appindicator.Indicator("example-simple-client", "gtk-execute", appindicator.CATEGORY_APPLICATION_STATUS) ind.set_status (appindicator.STATUS_ACTIVE) menu = gtk.Menu() menu_items = gtk.MenuItem('Quit') menu.append(menu_items) menu_items.connect("activate", gtk.main_quit) menu_items.show() ind.set_menu(menu) gtk.main() Unfortunately the documentation on this is very incomplete. What I'm looking for is a way to check if the AppIndicator menu was opend by

Use glade with pygobject Gtk3

ⅰ亾dé卋堺 提交于 2019-12-03 16:32:40
问题 I am converting a script to use Gtk3 using the migration guide (Porting GTK2 to GTK3). I converted my import pygtk to a from gi.repository import Gtk and so on... I'm stuck because the glade module was loaded from module gtk: import gtk import gtk.glade but there's no way now to do that anymore. Note that I would only need a replacement for gtk.glade.XML() ... 回答1: Well, the solution is pretty obvious, after calling to Gtk.Builder() one needs to convert the old glade interface with the gtk