pygtk

gtk TextView widget doesn't update during function

℡╲_俬逩灬. 提交于 2019-12-08 11:46:20
问题 I'm new to GUI programming with python and gtk, so this is a bit of a beginners question. I have a function that is called when a button is pressed which does various tasks, and a TextView widget which I write to after each task is completed. The problem is that the TextView widget doesn't update until the entire function has finished. I need it to update after each task. 回答1: After each update to the TextView call while gtk.events_pending(): gtk.main_iteration() You can do your update

How to override delete-event in pygtk?

一笑奈何 提交于 2019-12-08 09:01:49
问题 I am coding a simple text editor, so I am trying to check unsaved changes before closing the application. Now I know it has to be something with 'delete-event', and by googling around I have found a way, but it gives an error. This is my code: __gsignals__ = { "delete-event" : "override" } def do_delete(self, widget, event): print 'event overriden' tabsNumber = self.handler.tabbar.get_n_pages() #self.handler.tabbar.set_current_page(0) for i in range(tabsNumber, 0): doc = self.handler.tabbar

How to get a PNG (alpha channel) screenshot of Gtk window?

为君一笑 提交于 2019-12-08 06:52:35
问题 Gtk windows support transparency using Cairo. I tried to get a screenshot with the code here. But it prints pure black for windows that use transparency. How can I make a screenshot (PNG) which caputures the alpha channel too? EDIT: I tried with alpha pixbuf, but the output is still with no alpha. Here's my code (sing Gtk#, but it's pretty identical to C): static void GetScreenshot(Gtk.Window win) { var pixbuf = new Gdk.Pixbuf(Gdk.Colorspace.Rgb, true, 8, 500, 500); var pix = pixbuf

Gtk warning after ugrading to yosemite

∥☆過路亽.° 提交于 2019-12-08 03:43:11
问题 I am trying to run a program written in python on my mac (Yosemite). Almost immediately after starting the program it gives me the following error: Gtk-WARNING **: Locale not supported by C library. Using the fallback 'C' locale. [edit] tried to isolate the issue, the error appears upon entering Adriaan$ ipython --gui=gtk Python 2.7.8 (default, Nov 5 2014, 15:41:54) Type "copyright", "credits" or "license" for more information. IPython 2.3.0 -- An enhanced Interactive Python. ? ->

gtk: set active window

不羁岁月 提交于 2019-12-08 02:27:44
问题 I have a gtk.Window . How do I set it to be the active window? I can call is_active() to see whether it already is, but I don't see where to make it active. Bonus points: given a gtk.Widget , how do I make the window it is a part of the active window? 回答1: Ah thanks to this thread, the answer is to call gtk.Window.present() . 回答2: if W is a gtk.Window : import wnck wnck.window_get(W.window.xid).activate() 回答3: Here's what worked for me (thanks Dan D for pointing out wnck) def activate(window)

Converting PyGTK to exe

拟墨画扇 提交于 2019-12-07 22:31:29
I've been looking around for hours now. The only thing that makes sense to me is http://fnch.users.sourceforge.net/portablepygtkwindows.html But it takes up >40MB of space and it is too big for me. Other tutorials are either too complicated for me to go through them or the results I obtained didn't work. I've tried py2exe but the import gtk fails. I've tried pyinstaller. The GTK files were included but not the glade file. I would wish to have it all in a single standalone .exe. But now my priority is to have it properly working in windows without Python. Any effort to help is much appreciated.

PyGTK+3 (PyGObject) to create screenshot?

做~自己de王妃 提交于 2019-12-07 18:01:43
问题 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. 回答1: 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

In-place substitution of PyGTK widgets

守給你的承諾、 提交于 2019-12-07 14:41:17
问题 The code below creates a column of three labels. I would like to take the middle label, and replace it with another widget using the text from the label after the initial creation of the UI . My actual use case is to take a GTKBuilder populated UI, and replace any particular named label with a dynamically wrapped label at run time. (I used a button here because it's simple but distinct.) Then I can still use Glade to set up the UI, including the labels, and not pepper my Python code with

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:'

gtk idle_add not running?

余生颓废 提交于 2019-12-07 11:59:09
问题 I have a two-thread application: GUI, and some background work. I'm trying to send requests to the main thread to do GUI updates (move a progress bar), but it doesn't seem to work. I've boiled it down to a really minimal example: import pygtk pygtk.require('2.0') import glib import gtk import threading import sys import time def idle(): sys.stderr.write('Hello from another world.\n') sys.stderr.flush() gtk.main_quit() def another_thread(): time.sleep(1) glib.idle_add(idle) thread = threading