pygtk

gtk.Builder() and multiple glade files breaks

前提是你 提交于 2020-01-04 08:23:13
问题 I have a glade gui, and I want to insert another object using a glade file as well. When I do it as bellow (this is essentially what I am doing) the whole app hangs and the self.show() and maxes out the CPU at 100%. If I replace the first line of one's init () with self.builder = gtk.Builder() then the app runs, I can set widgets, ie: set contents of entry's, set and change the values of comboboxes. But I cant respond to signals, button clicks never call the handler. In the real code the

How to introspectively connect handlers to signals?

天涯浪子 提交于 2020-01-04 04:39:08
问题 gtk.Builder is capable to identify all signals that a GUI (described in a XML file) can emit and with the method connect_signals() automagically matches signals and handlers. Example: class Gui(gobject.GObject): def __init__(self): self.gui_file = "../data/gui.xml" builder = gtk.Builder() builder.add_from_file(self.gui_file) builder.connect_signals(self) def on_whatever_gui_event(self, widget, data=None): ... In my application I have other signals that are generated by non-GUI objects (it's

Python, thread and gobject

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-03 10:43:08
问题 I am writing a program by a framework using pygtk. The main program doing the following things: Create a watchdog thread to monitor some resource Create a client to receive data from socket call gobject.Mainloop() but it seems after my program enter the Mainloop, the watchdog thread also won't run. My workaround is to use gobject.timeout_add to run the monitor thing. But why does creating another thread not work? Here is my code: import gobject import time from threading import Thread class

Converting PyGTK to exe

回眸只為那壹抹淺笑 提交于 2020-01-03 02:42:31
问题 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

gtk custom spin button

我的未来我决定 提交于 2020-01-02 23:51:12
问题 I want to make a gtk SpinButton, but for inputting dates. Is there an easier way to input dates into GTK? If not, how can I create a SpinButton look-alike, but whose output is text representing dates instead of integers? Ideally I'd re-use the arrows, the clicks, the integration with the adjustment, etc. I really just need the output to look different, as I can even represent dates as integers. 回答1: The calendar is a bit large, but you can find code putting it in a popup. Personally I use a

Custom signal from widget to widget

北城余情 提交于 2020-01-02 07:26:33
问题 try to send signal from one gtk.EventBox child to another. on init HeadMode (line 75) got error: TypeError : unknown signal name: message-send why? #!/usr/bin/env python # -*- coding: utf8 -*- import pygtk pygtk.require('2.0') import gtk import gobject def Destroy(widget): gtk.main_quit() class CustomEventBox(gtk.EventBox): def __init__(self): super(CustomEventBox, self).__init__() self.press_hid = self.connect("button_press_event", self.on_press) self.release_hid = self.connect("button

How does one add an item to GTK's “recently used” file list from Python?

非 Y 不嫁゛ 提交于 2020-01-02 00:27:05
问题 I'm trying to add to the "recently used" files list from Python 3 on Ubuntu. I am able to successfully read the recently used file list like this: from gi.repository import Gtk recent_mgr = Gtk.RecentManager.get_default() for item in recent_mgr.get_items(): print(item.get_uri()) This prints out the same list of files I see when I look at "Recent" in Nautilus, or look at the "Recently Used" place in the file dialog of apps like GIMP. However, when I tried adding an item like this (where /home

Multithreaded Gstreamer w/ PyGTK crashing (xcb_xlib_threads_sequence_lost)

本秂侑毒 提交于 2020-01-01 12:13:06
问题 I understand that one is not supposed to update the UI from other threads in gtk , or face consequences, but I am not sure how I can avoid that while using gstreamer . My application crashes from time to time during video stream initialization with a following complaint: [xcb] Unknown sequence number while processing queue [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called [xcb] Aborting, sorry about that. python: ../../src/xcb_io.c:274: poll_for_event:

Multithreaded Gstreamer w/ PyGTK crashing (xcb_xlib_threads_sequence_lost)

烈酒焚心 提交于 2020-01-01 12:13:04
问题 I understand that one is not supposed to update the UI from other threads in gtk , or face consequences, but I am not sure how I can avoid that while using gstreamer . My application crashes from time to time during video stream initialization with a following complaint: [xcb] Unknown sequence number while processing queue [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called [xcb] Aborting, sorry about that. python: ../../src/xcb_io.c:274: poll_for_event:

Is there a gi.repository documentation for python?

有些话、适合烂在心里 提交于 2019-12-31 09:10:23
问题 I'm looking for a gi.repository module documentation and I can't find anything on the internet. All I found is documentation of new Gtk3 libraries for C, or old PyGtk 2.0 Reference Manual I'm looking for something like PyGtk 2.0 Reference Manual but for Gtk3. Is there something similar for Python? (I'm not looking for dir(Gtk) or help(Gtk) in the Python console.) 回答1: I think you're looking for this. It's a work in progress, but basically is a tutorial for Gtk3 in python. I doesn't really