pygobject

pygobject creating a drag and drop source

非 Y 不嫁゛ 提交于 2020-02-05 07:20:22
问题 from gi.repository import Gtk, Gdk def drag_data_get_cb(widget, drag_context, selection_data, info, time): print selection_data.get_data_type() print widget.get_text() return widget.get_text() def drag_begin_cb(widget, dragcontext): print dragcontext, widget return dragcontext label = Gtk.Label() label.drag_source_set(Gdk.ModifierType.BUTTON1_MASK, [], Gdk.DragAction.COPY) label.set_text("Drag Me!") label.connect("drag_data_get", drag_data_get_cb) label.connect("drag_begin", drag_begin_cb)

Webkit threads with PyGObject on Gtk3

梦想与她 提交于 2020-01-13 09:31:52
问题 I am trying to load a webkit view on a different thread than main thread for gtk. I see the example PyGTK, Threads and WebKit I slightly modify for support PyGObject and GTK3: from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GObject from gi.repository import GLib from gi.repository import WebKit import threading import time # Use threads Gdk.threads_init() class App(object): def __init__(self): window = Gtk.Window() webView = WebKit.WebView() window.add

Drawing in PyGobject (python3)

前提是你 提交于 2020-01-10 04:10:48
问题 I'm trying to write simple graphic editor using PyGObject and python 3. I need to draw lines with different color and width using mouse. I found many examples like this but nothing more complex. How do I save drawn image between 'draw' events? Is there incremental way of drawing or do I have to redraw pane on each 'draw' event? I found out that I can save path but how can I save width and colors of drawn lines? Is there way create image outside 'draw' callback and only apply (draw) it inside

GObject.add_emission_hook usage

怎甘沉沦 提交于 2020-01-06 06:56:20
问题 I was kindly directed to use GObject's "add_emission_hook" following a recent question on SO but I can't seem to find a usage example. Does anyone have one to share, please? 回答1: After a discussion with helpful folks on IRC #pygtk, here is what I came up with: import gobject class Signals(gobject.GObject): __gsignals__ = { "lastfm_username_changed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)) #@UndefinedVariable } def __init__(self): gobject.GObject.__init__(self)

Why can't I have a loop in the onclick function in PyGObject?

丶灬走出姿态 提交于 2020-01-06 05:26:15
问题 I am creating a user interface using PyGObject and I want the program to "run" a loop when a button is clicked and refresh the window accordingly. For example, in the following code, I want the program - on the click of the button - to update the label with a number, sleep for 1 second, increment the number and update the label again with the number, etc. The program currently, however, just shows the changes at the very end (after the loop is finished). How do I make the changes to the label

How can a program that uses GUI be constructed?

末鹿安然 提交于 2020-01-05 06:41:09
问题 I have just started Python, about 2 weeks ago. Now, I am trying to create GUIs with PyGObject using Glade. However, I am puzzled on how the general layout of the program should be. Should I use a class for the main program and the signals or should I separate them? Is there a "best approach" for this? Or as in below humble approach of mine, should I not use classes at all? How do I communicate between functions in the below example? For example, how do I set parent parameter of Gtk

Segmentation fault while drawing frame from webcam to DrawableArea in pygtk3

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-05 04:06:12
问题 As title suggests I am reading frames from my webcam (using openCV, i want to do some follow up feature detection with it) and want to write the result to a pyGTK3 DrawableArea widget. Following this answer, which i will quote for convenience: The following seems to do the job: def draw(self, widget, context): Gdk.cairo_set_source_pixbuf(context, self.pixbuf, 0, 0) context.paint() One question still remains: Is this the preferred way of doing things? So i am now using: def _on_drawablearea

Properly structure and highlight a GtkPopoverMenu using PyGObject

限于喜欢 提交于 2020-01-04 15:26:35
问题 I am trying to make an example of a proper Gtk.HeaderBar with Gtk.PopoverMenus that shows how the different widgets are used. I looked at a lot of examples and code, but can't figure out, how to work the Gtk.ModelButton . Especially this sentence makes no sense to me: When the action is specified via the “action-name” and “action-target” properties, the role of the button (i.e. whether it is a plain, check or radio button) is determined by the type of the action and doesn't have to be

pyGtk: Gtk missing error when get version

ぐ巨炮叔叔 提交于 2020-01-04 11:13:17
问题 When I startup /usr/bin/sniff which is a GUI monitor of dogtail I got below error: Traceback (most recent call last): File "/usr/bin/sniff", line 13, in <module> gi.require_version('Gtk', '3.0') File "/usr/local/lib/python2.7/site-packages/gi/__init__.py", line 48, in require_version raise ValueError('Namespace %s not available' % namespace) ValueError: Namespace Gtk not available And I execute the command python -c 'from gi.repository import Gtk' I got: ERROR:root:Could not find any typelib

pyGtk: Gtk missing error when get version

最后都变了- 提交于 2020-01-04 11:12:40
问题 When I startup /usr/bin/sniff which is a GUI monitor of dogtail I got below error: Traceback (most recent call last): File "/usr/bin/sniff", line 13, in <module> gi.require_version('Gtk', '3.0') File "/usr/local/lib/python2.7/site-packages/gi/__init__.py", line 48, in require_version raise ValueError('Namespace %s not available' % namespace) ValueError: Namespace Gtk not available And I execute the command python -c 'from gi.repository import Gtk' I got: ERROR:root:Could not find any typelib