pygtk

GtkTreeView with multiple columns and GtkListStore with single custom type (in Python)

冷暖自知 提交于 2019-11-30 15:05:37
I'm trying to display properties of an object on different columns of a Gtk.TreeView . Say I have the following: class MyClass(GObject.GObject): def __init__(self, first, last, age): self.first = first self.last = last self.age = age And I want to store instances in a Gtk.ListStore as shown below. store = Gtk.ListStore(MyClass) Now, when creating the Gtk.TreeView , I don't know how to specify that 2 columns must be rendered, one for the first property and the other for the age property. view = Gtk.TreeView(model=store) # Columns for first and age added here ... These posts (1) and (2) somewhat

Python package installed globally, but not in a virtualenv (PyGTK)

送分小仙女□ 提交于 2019-11-30 14:19:59
问题 I'm having some strange issues with PyGTK in "virtualenv". gtk does not import in my virtualenv, while it does import in my global python install. (I wasn't having this particular issue last week, guessing some software update upset something.) Is there a good way to resolve this behavior? Shown here: importing gtk globally, tom@zeppelin:~$ python Python 2.7.1+ (r271:86832, Sep 27 2012, 21:12:17) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>

Stock Icons not shown on buttons

六月ゝ 毕业季﹏ 提交于 2019-11-30 13:59:53
问题 self.button = gtk.Button(stock=gtk.STOCK_DELETE) Only Shows: Delete 回答1: This is a recent change in GTK - the developers wanted icons not to appear on buttons. On Linux, this can be changed by editing the gconf key /desktop/gnome/interface/buttons_have_icons On windows, I think (I haven't actually tried this) that you need to set a value in your gtkrc file (for me it's in C:\Program Files\Gtk+\etc\gtkrc ) and use a theme that supports icons (I think the default one doesn't). You can also add

Python classes losing attributes

馋奶兔 提交于 2019-11-30 13:05:18
I have a peculiar python problem. During the course of execution of my gtk python application, some of my class objects mysteriously lose attributes, causing some of the functionality of my program to break. It's hard to give a sense of why this might happen - I never intentionally delete attributes, and the classes in question inherit from a class I wrote myself (and no others). I can trigger the problem by doing a certain action repeatedly (for example generating many calls to the add_card method - either by clicking madly or by opening a file, causing add_card to be called twenty or so

Python + webkit + gtk on windows

与世无争的帅哥 提交于 2019-11-30 09:15:37
I am trying to do this script: PY WYSIWYG And it says I need Gtk and WebKit. I think this is what I need: Gtk WebKit So I downloaded WebKit but I got a folder instead of an installer or install information. Do I move it into the python folder or what do I do? You need PyGTK, here is a link to the download page with install instructions for Windows: http://www.pygtk.org/downloads.html You also need the Python bindings for Webkit, not just Webkit itself. Here is a link to an unofficial Windows binary, with install instructions, and a link to an unofficial Webkit runtime for Windows near the

Run a function every X minutes - Python

亡梦爱人 提交于 2019-11-30 08:48:17
I'm using Python and PyGTK. I'm interested in running a certain function, which gets data from a serial port and saves it, every several minutes. Currently, I'm using the sleep() function in the time library. In order to be able to do processing, I have my system set up like this: import time waittime = 300 # 5 minutes while(1): time1 = time.time() readserial() # Read data from serial port processing() # Do stuff with serial data, including dumping it to a file time2 = time.time() processingtime = time2 - time1 sleeptime = waittime - processingtime time.sleep(sleeptime) This setup allows me to

Stop pygtk GUI from locking up during long-running process

女生的网名这么多〃 提交于 2019-11-30 07:39:10
问题 I have a process that will take a while (maybe a minute or two) to complete. When I call this from my pygtk GUI the window locks up (darkens and prevents user action) after about 10 seconds. I'd like to stop this from happening, but I'm not sure how. I thought multithreading would be the answer, but it doesn't seem to be working. I've tried two different methods I found online. First, I modified this FAQ to take a long running function. Secondly I tried using threading.Thread directly like in

GtkTreeView with multiple columns and GtkListStore with single custom type (in Python)

◇◆丶佛笑我妖孽 提交于 2019-11-29 22:13:17
问题 I'm trying to display properties of an object on different columns of a Gtk.TreeView . Say I have the following: class MyClass(GObject.GObject): def __init__(self, first, last, age): self.first = first self.last = last self.age = age And I want to store instances in a Gtk.ListStore as shown below. store = Gtk.ListStore(MyClass) Now, when creating the Gtk.TreeView , I don't know how to specify that 2 columns must be rendered, one for the first property and the other for the age property. view

Simple pygtk and threads example please

时光怂恿深爱的人放手 提交于 2019-11-29 15:39:09
Can someone give me a simple example involving threads in this manner, please. Problem with my code is that when I click button One, GUI freezes until its finished. I want buttons to stay responsive when def is being executed. How can i fix that? class fun: wTree = None def __init__( self ): self.wTree = gtk.glade.XML( "ui.glade" ) dic = { "on_buttonOne" : self.one, "on_buttonTwo" : self.two, } self.wTree.signal_autoconnect( dic ) gtk.main() def sone(self, widget): time.sleep(1) print "1" time.sleep(1) print "2" time.sleep(1) print "3" def stwo(self, widget): time.sleep(1) print "4" time.sleep

How to get list opened windows in PyGTK or GTK in Ubuntu?

偶尔善良 提交于 2019-11-29 14:21:03
问题 How to get list opened windows in PyGTK or GTK or other programming language? in Ubuntu? edit: i want get list paths opened directories on desktop! 回答1: You probably want to use libwnck: http://library.gnome.org/devel/libwnck/stable/ I believe there are python bindings in python-gnome or some similar package. Once you have the GTK+ mainloop running, you can do the following: import wnck window_list = wnck.screen_get_default().get_windows() Some interesting methods on a window from that list