pygtk

How do I raise a window that is minimized or covered with PyGObject?

我的未来我决定 提交于 2019-12-05 09:26:46
I'd been using the answer provided in the PyGTK FAQ , but that doesn't seem to work with PyGObject. For your convenience, here is a test case that works with PyGTK, and then a translated version that doesn't work with PyGObject. PyGTK Version: import gtk def raise_window(widget, w2): w2.window.show() w1 = gtk.Window() w1.set_title('Main window') w2 = gtk.Window() w2.set_title('Other window') b = gtk.Button('Move something on top of the other window.\nOr, minimize the' 'other window.\nThen, click this button to raise the other' 'window to the front') b.connect('clicked', raise_window, w2) w1

gtk minimum size

空扰寡人 提交于 2019-12-05 09:24:54
Is there an easy way to request that a GTK widget have a minimum width/height? I know you can do it on the column of a TreeView , but is it available for general widgets? For C/C++: gtk_widget_set_size_request() Sets the minimum size of a widget; that is, the widget's size request will be width by height. PyGTK: def set_size_request(width, height) 来源: https://stackoverflow.com/questions/3916762/gtk-minimum-size

GtkTreeView's row right click

若如初见. 提交于 2019-12-05 09:06:19
How do I do something when user right click in a treeview's row? Johan Dahlin It's really easy, just listen to the "button-press-event" signal and use treeview.get_path_at_pos() to figure the selected row: def button_press_event(treeview, event): if event.button == 3: # right click model, path = treeview.get_path_at_pos(int(event.x), int(event.y)) # do something with the selected path treeview.connect('button-press-event' , button_press_event) 来源: https://stackoverflow.com/questions/4570859/gtktreeviews-row-right-click

Automatic image scaling on resize with (Py)GTK

穿精又带淫゛_ 提交于 2019-12-05 08:01:14
I have a GtkImage widget in a resizable window and a reference GdkPixBuf storing the image I want to fill the GtkImage with. I can scale the GdkPixBuf to fill the GtkImage widget using this method: def update_image(self, widget=None, data=None): # Get the size of the source pixmap src_width, src_height = self.current_image.get_width(), self.current_image.get_height() # Get the size of the widget area widget = self.builder.get_object('image') allocation = widget.get_allocation() dst_width, dst_height = allocation.width, allocation.height # Scale preserving ratio scale = min(float(dst_width)/src

“WindowsError: [Error 2] The system cannot find the file specified” is not resolving

最后都变了- 提交于 2019-12-05 07:10:34
I have created exe file of my python project by py2exe which have number of files. when i run this exe file in my system. it works fine but if i put it in another system then it opens login form, then after it doesn't go to next window which i have written in 2nd python file. it gives me below error in log file. Traceback (most recent call last): File "login.py", line 246, in DataReader File "subprocess.pyo", line 711, in __init__ File "subprocess.pyo", line 948, in _execute_child WindowsError: [Error 2] The system cannot find the file specified I know that it is duplicate question but I have

Webkit threads with PyGObject on Gtk3

北慕城南 提交于 2019-12-05 07:01:00
I am trying to load a webkit view on a different thread than main thread for gtk. I see the example PyGTK, Threads and WebKit I slightly modify for support PyGObject and GTK3: from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GObject from gi.repository import GLib from gi.repository import WebKit import threading import time # Use threads Gdk.threads_init() class App(object): def __init__(self): window = Gtk.Window() webView = WebKit.WebView() window.add(webView) window.show_all() #webView.load_uri('http://www.google.com') # Here it works on main thread self

Gtk* backend requires pygtk to be installed

大憨熊 提交于 2019-12-05 06:15:26
From within a virtual environment, trying to load a script which uses matplotlib 's GTKAgg backend, I fail with the following traceback: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/user/.virtualenvs/venv/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 97, in <module> _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup() File "/home/user/.virtualenvs/venv/local/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup globals(),locals(),[backend_name]) File "/home/user/.virtualenvs/venv/local

pygtk import gtk error

十年热恋 提交于 2019-12-05 06:14:45
问题 I downloaded everything described as in pygtk for installation. Everything went fine until when I tried to type "import gtk" , it threw an ImportError as follows: from gtk import _gtk ImportError: DLL load failed: ...(something unreadable) Then I re-install the pygtk-2.22.0 again, the same problem existed. So what to do please? Thanks in advance! 回答1: The error you describe is usually caused by the python bindings (pygtk/pygobject/pycairo) being unable to load a dll it needs to function

Word Wrap in PyGTK TreeView

匆匆过客 提交于 2019-12-05 02:44:45
问题 How can I word wrap text inside a PyGTK TreeView? 回答1: Text in a gtk.TreeView is rendered using a gtk.CellRendererText, and wrapping text comes down to setting the right properties on your cell renderer. In order to get text to wrap, you need to set the wrap-width property (in pixels) on the cell renderer. You probably also want to set the wrap-mode property to something sensible. For example: renderer.props.wrap_width = 100 renderer.props.wrap_mode = gtk.WRAP_WORD Unfortunately, if you want

GTK: create a colored regular button

三世轮回 提交于 2019-12-05 01:35:28
问题 How do I do it? A lot of sites say I can just call .modify_bg() on the button, but that doesn't do anything. I'm able to add an EventBox to the button, and add a label to that, and then change its colors, but it looks horrendous - there is a ton of gray space between the edge of the button that doesn't change. I just want something that looks like this: (source: kksou.com) The site claims to have just done modify_bg() on the button. But that doesn't work for me. =(. The right answer probably