pygobject

unresponsive drag and drop in pygobject

百般思念 提交于 2019-12-07 17:43:34
问题 im trying to get drag and drop working well in pygobject, but it is slow and unresponsive, 90% of the time i have to wave the item i am dragging around before i can drop it successfully, can anyone see if i am doing it incorrectly or is this a bug with pygobject? here is my code from gi.repository import Gtk, GdkPixbuf, Gdk import os def got_data_cb(windowid, context, x, y, data, info, time): # Got data. tempArray = data.get_text().splitlines() for i in tempArray: i = i.replace('file://','')

How can I create a GTK ComboBox with images in Python?

被刻印的时光 ゝ 提交于 2019-12-07 15:20:18
问题 How can I create a ComboBox that displays a list of entries, each containing some text and an icon? I'm using Python and GTK3 with GObject introspection. 回答1: Here's an example of how to do that, inspired by this answer for C. from gi.repository import Gtk from gi.repository import GdkPixbuf store = Gtk.ListStore(str, GdkPixbuf.Pixbuf) pb = GdkPixbuf.Pixbuf.new_from_file_at_size("picture.png", 32, 32) store.append(["Test", pb]) combo = Gtk.ComboBox.new_with_model(store) renderer = Gtk

Drag and drop file example in pygobject

核能气质少年 提交于 2019-12-07 12:06:41
问题 I am trying to port sample drag and drop example from pygtk FAQ to pygobject. from gi.repository import Gtk as gtk import urllib import os TARGET_TYPE_URI_LIST = 80 dnd_list = [ ( 'text/uri-list', 0, TARGET_TYPE_URI_LIST ) ] def get_file_path_from_dnd_dropped_uri(uri): # get the path to file path = "" if uri.startswith('file:\\\\\\'): # windows path = uri[8:] # 8 is len('file:///') elif uri.startswith('file://'): # nautilus, rox path = uri[7:] # 7 is len('file://') elif uri.startswith('file:'

How do I raise a window that is minimized or covered with PyGObject?

佐手、 提交于 2019-12-07 04:56:18
问题 I'd been using the answer provided in the PyGTK FAQ, but that doesn't seem to work with PyGObject. For your convenience, here is a test case that works with PyGTK, and then a translated version that doesn't work with PyGObject. PyGTK Version: import gtk def raise_window(widget, w2): w2.window.show() w1 = gtk.Window() w1.set_title('Main window') w2 = gtk.Window() w2.set_title('Other window') b = gtk.Button('Move something on top of the other window.\nOr, minimize the' 'other window.\nThen,

Load GTK-Glade translations in Windows using Python/PyGObject

落爺英雄遲暮 提交于 2019-12-06 11:00:32
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') , the LOCALE_DIR just points at the folder that has the compiled mo-files. Under Windows this makes

Adding an icon to a ToolButton in Gtk 3

蓝咒 提交于 2019-12-06 08:09:13
Is there a way to add an icon to a Gtk.ToolButton (Gtk3 using PyGi for Python) to add to the GTK+3 toolbar ? Below is my code: self.addfile = Gtk.ToolButton() self.addfile.set_label("Add File") self.addfileimg = Gtk.Image() self.addfileimg.show() self.addfileimg.set_from_file(self.get_resource("img/file.png")) self.addfile.set_icon_widget(self.addfileimg) self.addfile.connect("clicked", self.on_open_file) Note: The get_resource() method digs into the local working folder for the resource path and this method is assumed working in this context. I tried the code written above using PyGi. The

How to install PyGObject through PyCharm

笑着哭i 提交于 2019-12-06 06:53:18
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 essential.' ^ SyntaxError: invalid syntax ---------------------------------------- Command "python

Update a Gtk.ProgressBar from another thread or process

你离开我真会死。 提交于 2019-12-06 05:52:59
I have a GUI with a progressbar. It should show the progress of the work a second thread does. I would like to have something like an event the thread can send to the GUIs progressbar immediatly on each step of the work. But I don't see how this could be done. Python itself offers a Event class for threading situations. But it would block the GUI main thread because of the Event.wait() methode. How does it change the situaton and possible solutions if the second thread is a process? My example here is based on PyGObject (Pythons Gtk) but is related to all other GUI libraries, too. The current

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

帅比萌擦擦* 提交于 2019-12-06 04:23:03
问题 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. 回答1: I think you run into two problems here. First of all, I'm not sure that the PyGObject

PyGTK+3 (PyGObject) to create screenshot?

本小妞迷上赌 提交于 2019-12-06 03:40:29
I've spend past 3 days searching in google, how can I create a screenshot with PyGTK+3 ? There are gallizion tutorials about pyqt,pygtk+2,wx and PIL. By the way, I don't need external programs like scrot, imlib2, imagemagick and so on. Since nobody else posted the translation to GTK3, here you go: from gi.repository import Gdk win = Gdk.get_default_root_window() h = win.get_height() w = win.get_width() print ("The size of the window is %d x %d" % (w, h)) pb = Gdk.pixbuf_get_from_window(win, 0, 0, w, h) if (pb != None): pb.savev("screenshot.png","png", (), ()) print("Screenshot saved to