pygtk

Installing PyGtk in virtualenv

半世苍凉 提交于 2019-11-28 06:44:56
So I am trying to run a simple matplotlib example in my virtualenv (in the console). Here's the code: import matplotlib matplotlib.use('GTKAgg') import matplotlib.pyplot as plt radius = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] area = [3.14159, 12.56636, 28.27431, 50.26544, 78.53975, 113.09724] plt.plot(radius, area) plt.show() However, when I run this I get: ImportError: Gtk* backend requires pygtk to be installed. And now the fun starts. I tried to pip install pygtk but it throws: ******************************************************************** * Building PyGTK using distutils is only supported on

Is this possible to draw GtkTreeView listed like GtkIconView?

試著忘記壹切 提交于 2019-11-28 06:04:34
问题 I am working on a GTK+ application written in python. I obviously use PyGtk. My application is about collections of videos. It's a kind of F-spot or Picasa, but for video. As you can see in these two apps, you have a central area where you can see all of your photos with tag thumbnails under. In my app, I want to implement the same kinf of view. For now I simply use this: A gtk.Table containing a VBox , inside the VBox a Pixbuf (my video thumbnail) and a HBox , and inside the HBox , as many

Struggling to install pygtk with pip

我的未来我决定 提交于 2019-11-28 05:36:08
问题 I am trying to install pygtk using pip on Windows. Initially i get an error saying "ERROR: Could not import dsextras module: Make sure you have installed pygobject." So when I try installing pygobject I get an error saying "ERROR: Could not find pkg-config: please check your PATH environment variable" Pretty new to Python so could be making a stupid mistake but does anyone have any ideas? Thanks 回答1: I had the same problem on my Window 7 machine, and solved it by installing the prebuilt PyGTK

gtk treeview: place image buttons on rows

≡放荡痞女 提交于 2019-11-28 03:59:54
问题 For each row in my treeview, I want 4 image buttons next to each other. They will act like radio buttons, with only one being activateable at a time. Each button has an 'on' and 'off' image. How do I do this? I figured out how to put images there, and how to put togglebuttons, but this seems to require some more effort as there is no pre-built cellrenderer that does what I want. Basically what'd solve my problem is figuring out how to make an image in a gtk.treeview clickable. any ideas? 回答1:

PyGTK: dynamic label wrapping

人走茶凉 提交于 2019-11-28 00:05:46
问题 It's a known bug/issue that a label in GTK will not dynamically resize when the parent changes. It's one of those really annoying small details, and I want to hack around it if possible. I followed the approach at 16 software, but as per the disclaimer you cannot then resize it smaller. So I attempted a trick mentioned in one of the comments (the set_size_request call in the signal callback), but this results in some sort of infinite loop (try it and see). Does anyone have any other ideas?

Simple, versatile and re-usable entry dialog (sometimes referred to as input dialog) in PyGTK

和自甴很熟 提交于 2019-11-27 19:31:05
问题 I am searching for a simple dialog with a text entry widget asking the user for some input. The dialog should be easy to run (like the gtk.MessageDialog variants) and as flexible. There are of course some examples but they are either not flexible enough or too complicated to construct for my taste. I hate re-inventing the wheel... or a dialog. 回答1: Based on an example I found (thanks Ardoris!), I came up with a dialog subclass... hope it helps someone out there! #!/usr/bin/env python import

How to compile all resources into one executable file?

人盡茶涼 提交于 2019-11-27 19:20:33
问题 I've wrote GTK application with python. All graphical user interface is in glade file, and there are some images used. I wish to compile my application into EXEcutable file. For that I'm using PyInstaller compiler and UPX packer. I've done as manual says: python Configure.py python Makespec.py --onefile --windowed --upx /path/to/yourscript.py python Build.py /path/to/yourscript.spec PyInstaller works perfectly and create one exe file. But to make my application work correctly i have to copy

Getting py2exe to work with zope.interface

跟風遠走 提交于 2019-11-27 18:58:37
问题 I have a Python app based on Twisted and PyGTK. Twisted itself depends on zope.interface, and I don't import it directly. Unfortunately, when I try to run my app, the following error ends up in the error log: Traceback (most recent call last): File "tasks.py", line 4, in <module> File "ui\__init__.pyc", line 14, in <module> File "twisted\python\log.pyc", line 17, in <module> ImportError: No module named zope.interface Traceback (most recent call last): File "tasks.py", line 4, in <module>

Scale an image in GTK

為{幸葍}努か 提交于 2019-11-27 17:27:47
问题 In GTK, how can I scale an image? Right now I load images with PIL and scale them beforehand, but is there a way to do it with GTK? 回答1: Load the image from a file using gtk.gdk.Pixbuf for that: import gtk pixbuf = gtk.gdk.pixbuf_new_from_file('/path/to/the/image.png') then scale it: pixbuf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR) Then, if you want use it in a gtk.Image, crate the widget and set the image from the pixbuf. image = gtk.Image() image.set_from_pixbuf(pixbuf)

authentication in python script to run as root

China☆狼群 提交于 2019-11-27 14:02:03
I am doing a project in Linux at system level in Python. So that, I want to know that if i am running my code as a normal user and if i am accessing system files then it should have root permissions for it, then how can i prompt for root password and run further code as superuser. I want to know that, how to run python script as superuser with password prompt for it.. Any help will be appreciated. Thank you in advance.. The other thing you can do is have your script automatically invoke sudo if it wasn't executed as root: import os import sys euid = os.geteuid() if euid != 0: print "Script not