pygtk

Detect when column in gtk.treeview is resized

自作多情 提交于 2019-12-10 18:56:45
问题 What signal can I catch to detect when a column changes size in a gtk.TreeView ? I can't seem to find it in the docs. 回答1: gtk.TreeViewColumns aren't widgets so they unfortunately don't have a dedicated signal for size changes. But you can register a callback function that receives "width" change notifications: def onColWidthChange(col, width): # Note that "width" is a GParamInt object, not an integer ... col.connect("notify::width", onColWidthChange) In the example, col must be a gtk

How to correctly install pyGTK using macports?

随声附和 提交于 2019-12-10 18:05:35
问题 My python code uses GTK for some GUI and now i need to run some of it on OSX (10.6 Snow Leopard and 10.7 Lion). Unfortunately, unofficial pyGTK build crashes on window GTK windows resize, so i decided to test macports version. I installed python and pygtk via following macports commands: sudo port install python26 sudo port select --set python python26 sudo port install py-gtk2 Running python from console correctly starts macports version of python. But trying to execute import gtk or import

Inserting bold characters in pyGTK's TextView/TextBuffer

不羁岁月 提交于 2019-12-10 15:59:11
问题 I have a TextView and a TextBuffer associated with it. When the user presses Ctrl+b, I would like the text to be start typing in bold until user presses Ctrl+b again. I was trying my own methods, which weren't working, and then I found this post on the mailing list: http://www.daa.com.au/pipermail/pygtk/2009-April/016951.html Same issue as me, and the solution someone gave is Your application will have to handle the bookkeeping required to manage the tags in the TextBuffer. When text is

pygtk glib.timeout_add(): How to tell if timer not being destroyed?

梦想的初衷 提交于 2019-12-10 15:57:35
问题 In my application I use a function to show GtkInfoBars with a timeout (as described https://stackoverflow.com/a/1309257/406281) thanks to glib.timeout_add_seconds(). I understand that glib.timeout_add_seconds() is supposed to set a function to be called at regular intervals until said function returns False. I'm not doing that, but everything works as expected. It's perfectly simple. Here's my code: def infobar(self, message, msgtype=gtk.MESSAGE_INFO, timeout=5): bar = gtk.InfoBar() bar.set

Simple way to toggle fullscreen with F11 in PyGTK

霸气de小男生 提交于 2019-12-10 14:57:41
问题 I am not a professional programmer but am regularly using PyGTK and Cairo for data visualization testing and prototyping. I have a standard template of PyGTK that I took from the web, which does the "standard things" GTK needs to work: import pygtk pygtk.require('2.0') import gtk """ lots of stuff """ if __name__ == "__main__": mainWindow = gtk.Window() mainWindow.set_title(some_title) mainWindow.connect("delete-event", gtk.main_quit) #mainWindow.set_position(gtk.WIN_POS_CENTER) #mainWindow

Error importing gtk with python on OS X

*爱你&永不变心* 提交于 2019-12-10 11:58:57
问题 I've just installed pygtk through Homebrew(awesome tool) as well as its dependences (including gtk+); the thing is when I try to import gtk on the python interpreter it throws an ImportError, which don't happens when importing pygtk or any other module into the interpreter, I can't figure out what's wrong. :S 回答1: After clarification from the OP, the original answer does not describe his problem… although I think it's related, and it may help other people, so I will leave it. But first, the

How to disable the close button in GTK?

被刻印的时光 ゝ 提交于 2019-12-10 11:46:12
问题 I have created a One Time Password mechanism in OpenERP 6.0.3's GTK client. After login the GTK client shows a window to enter the One Time Password as below. Now I want to disable the close button at the top left of the window. How can I do that? I am using python and the code to create the window is: EDIT class sms_auth(gtk.Dialog): def run_thread(self): code=self.textbox_code.get_text() self.result = rpc.session.rpc_exec_auth('/object', 'execute', 'res.users', 'check_code', code) return

drawing a pixbuf onto a drawing area using pygtk and glade

末鹿安然 提交于 2019-12-10 11:31:20
问题 i'm trying to make a GTK application in python where I can just draw a loaded image onto the screen where I click on it. The way I am trying to do this is by loading the image into a pixbuf file, and then drawing that pixbuf onto a drawing area. the main line of code is here: def drawing_refresh(self, widget, event): #clear the screen widget.window.draw_rectangle(widget.get_style().white_gc, True, 0, 0, 400, 400) for n in self.nodes: widget.window.draw_pixbuf(widget.get_style().fg_gc[gtk

GtkWindow can only contain one widget at a time

梦想的初衷 提交于 2019-12-10 11:27:55
问题 I am using this code to retrieve and display an image from the web: class Display(object): def __init__(self): self.window = gtk.Window(gtk.WINDOW_TOPLEVEL) self.window.connect('destroy', self.destroy) self.window.set_border_width(10) self.image = gtk.Image() response = urllib2.urlopen('http://image.url/image.jpg').read() pbuf = gtk.gdk.PixbufLoader() pbuf.write(response) pbuf.close() self.image.set_from_pixbuf(pbuf.get_pixbuf()) self.window.add(self.image) self.image.show() self.window.show(

PyGTK: copy matplotlib figure to clipboard

旧巷老猫 提交于 2019-12-10 10:49:43
问题 I'm working on PyGTK application, that can generate graphs. This achieved by matplotlib. How can I add Copy-To-Clipboard functionality? How to copy figure to clipboard? 回答1: This will do it in Linux (just mouse-click on the image and it is copied to clipboard ready to paste in e.g. GIMP): import matplotlib.pyplot as plt from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas import gtk import numpy as np class W(gtk.Window): def __init__(self): gtk.Window.__init__(self)