pygtk

Update matplotlib plot with Gtk+ button event

纵饮孤独 提交于 2019-12-13 07:28:35
问题 I've encapsulated a matplotlib plot in a Gtk+ window and I'm trying to update that plot when a button is clicked (it's Gauss' circle problem). Trouble is, I'm not exactly sure how to get the plot to update with an event. So far I have the following. #! /usr/bin/env python3.4 # -*- coding: utf-8 -*- """ Main application--embed Matplotlib figure in window with UI """ import gi gi.require_version('Gtk', '3.0') import numpy as np from gi.repository import Gtk, GObject from matplotlib.figure

convert gtkglade to libglade for a backwards compatibility

和自甴很熟 提交于 2019-12-13 05:16:36
问题 I have a python gtk app that I am porting to an environment that can only use pygtk2.10. pygtk2.10 doesn't not use the gtkbuilder infrastructure but rather the libglade infrastructure I have a 2 goals 1) convert the gtkbuilder glade file format to libglade format. Basically I want to do the opposite of gtk-builder-convert (which converts libglade to gtkbuilder formats as far as I understand it) 2) find a mapping between gtk.builder functions and libglade functions to be functionally the same

GTK TreeView: 20-line minimal script won't show TreeView itself within the window: what's wrong?

余生长醉 提交于 2019-12-13 05:11:55
问题 I've got a simplest TreeView example possible, mostly copied from basictreeview.py, but even simplier, but the TreeView itself won't show inside the toplevel window. What's wrong: import gtk class Application(object): def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.set_title("Alignment Editor") self.window.set_default_size(1024, 768) self.window.connect("delete_event", lambda w,e: gtk.main_quit()) self.row = ["a", "b", "c", "d", "e", "f", "g", "h"] self.store =

How to stop infinite recursion when Python objects trigger each other's updates?

五迷三道 提交于 2019-12-13 02:53:42
问题 I'm using PyGTK and the gtk.Assistant widget. On one page I have six comboboxes, which initially have the same contents (six numbers). When the users selects a number in one of those comboboxes, this number should no longer be available in the other five boxes (unless it's present as a duplicate in the original list). Hence I would like to always update the contents. I have tried the following approach (just a few code snippets here), but (of course...) it just jumps into infinite recursion

PyGobject VTE terminal, command printed twice

夙愿已清 提交于 2019-12-13 01:43:21
问题 I'm writing an application to connect to few Linux server via SSH, which using VTE terminal to make some operation on this server. To connect to this server I'm using bash expect command to provide password. I want to run this command instantly after VTE was run , but here I have some ugly behavior of VTE, command was printed twice to terminal, once before bash prompt, and second normal after bash prompt echo Here command to connesc ssh [drespondek@oc5045316303 ~]$ echo Here command to

Taking a snapshot from webcam monitor in python (pygtk)

亡梦爱人 提交于 2019-12-12 16:41:34
问题 I have this code for monitoring a webcam with python and pygtk. The question is, how I take a snapshot with this code?: #!/usr/bin/env python import sys, os import pygtk, gtk, gobject import pygst pygst.require("0.10") import gst import time class WebCam: def __init__(self): window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_title("Webcam-Viewer") window.set_default_size(1024, 768) window.connect("destroy", gtk.main_quit, "WM destroy") vbox = gtk.VBox() window.add(vbox) self.movie_window =

Running computation in background thread python/pygtk

僤鯓⒐⒋嵵緔 提交于 2019-12-12 11:25:16
问题 Is there a way to run a python thread in the background without locking down the rest of python during time-consuming instructions? I'm trying to do time-consuming calculations in a background thread of a python (pygtk) application. I understand how threads work. The problem is that each time I run an expensive operation in any thread (example: PIL's image.load() for large images), it blocks all python threads until the operation is completed, even though it is in a separate thread. So, is

Python GTK signal handler not working

隐身守侯 提交于 2019-12-12 11:02:19
问题 I am writing a Python application using GTK for the GUI. I noticed that closing it with Ctrl-C from the terminal isn't working and I discovered this is because of a bug, so I tried to manually handle the signal. The problem is that if I set the default behaviour to the default one, the signal is caught and the application is closed correctly, but if I use a custom handler it doesn't work. Here is my (simplified) code: from gi.repository import Gtk import signal class MainWindow(Gtk.Window):

pygtk how to update gtk.Image

痞子三分冷 提交于 2019-12-12 10:19:26
问题 I have very strange problem with gtk.Image(). Simple question; how to update image? On window creation I create image and pack it… On that time I load image from disk. Now I start downloading image from url, and when it's done I just want to replace existing image with new one. I rewrite content of same file on disk and then do: pixbuf = gtk.gdk.pixbuf_new_from_file(image_path) self._user_avatar.set_from_pixbuf(pixbuf) I have tried self._user_avatar.set_from_file(image_path) and self._user

How can I display text on a StatusIcon instead of setting an icon?

随声附和 提交于 2019-12-12 09:40:48
问题 I'm a beginner developer in Gtk and also in Python. I'm trying to create a gtk.StatusIcon displaying a text string in place of a icon. How can I accomplish this with PixBuf, or any other way? Thanks. 回答1: This is possible - two ideas come to mind: a.) Use an offscreen GtkLabel and then call gdk_pixbuf_get_from_drawable (gtk_widget_get_snapshot (label)) (a GdkPixmap is a GdkDrawable.) This will do an XGetImage to get pixels from the X server. b.) Or you could use Cairo to draw text to the