pygtk

GTK::Socket and Gtk::Plug unexpected behaviour under Gnome and FVWM2

不羁的心 提交于 2019-12-23 03:56:13
问题 The following code works fine if run within FVWM2. But if you change desktop to Gnome, then the embedded window is destroyed instead of being embedded. Why is that? What am I missing?... The code follows but basically all it does is fork. In the child, we create a VPython window an let it idle forever. In the parent, we create a GTK window, find out what the window ID of the child window is, and try to embed it vis a GTK::Socket. Note that the VPython part maybe irrelevant to this. #!/usr/bin

Detect ctrl+click on button in pygtk

眉间皱痕 提交于 2019-12-22 18:29:28
问题 I want to detect if ctrl is held down when the user clicks a button. The 'clicked' signal doesn't seem to pass enough information to the callback to work this out. 回答1: If you can connect to either button-press-event or button-release-event instead of clicked , the event passed to the callback can be used to get the modifier state (using get_state) and check if control key is pressed. For ex. def button_release_callback(widget, event, data=None): if event.get_state() & gtk.gdk.CONTROL_MASK:

Python 3.4 / GTK / Async

人走茶凉 提交于 2019-12-22 12:38:31
问题 I use tkinter with a async funktion. Now I will use gtk3 in stead of tkinkter. Is there also a way to run my async function? How should I adapt the code Here are some code fragments: async def _event_loop(app, interval=0.05): try: while True: app.update() await asyncio.sleep(interval) except tkinter.TclError as exc: if "application has been destroyed" not in exc.args[0]: raise class SSHFrame(tkinter.Frame): def __init__(self, parent): super().__init__(parent) ... ... async def _run(self, host

Embed a spreadsheet/table in a PyGTK application?

若如初见. 提交于 2019-12-22 12:29:08
问题 In my application, we want to present the user with a typical spreadsheet/table (OO.O/Excel-style), and then pull out the values and do something with them internally. Is there a preexisting widget for PyGTK that does this? The PyGTK FAQ mentions GtkGrid, but the link is dead and I can't find a tarball anywhere. 回答1: GtkGrid is deprecated in favor of the more powerful and more customizable GtkTreeView. It can display trees and lists. To make it work like a table, you must define a ListStore

Load GTK-Glade translations in Windows using Python/PyGObject

走远了吗. 提交于 2019-12-22 12:19:19
问题 I have a Python script that loads a Glade-GUI that can be translated. Everything works fine under Linux, but I am having a lot of trouble understanding the necessary steps on Windows. All that seems necessary under Linux is: import locale [...] locale.setlocale(locale.LC_ALL, locale.getlocale()) locale.bindtextdomain(APP_NAME, LOCALE_DIR) [...] class SomeClass(): self.builder = Gtk.Builder() self.builder.set_translation_domain(APP_NAME) locale.getlocale() returns for example ('de_DE', 'UTF-8'

Python: Fastest way to take and save screenshots

你离开我真会死。 提交于 2019-12-22 11:27:19
问题 I've been struggling to come up with a script that allows me to take screenshots of my desktop more than once per every second. I'm using Win10. PIL: from PIL import ImageGrab import time while True: im = ImageGrab.grab() fname = "dropfolder/%s.png" %int(time.time()) im.save(fname,'PNG') Results 1.01 seconds per image. PyScreeze (https://github.com/asweigart/pyscreeze): import pyscreeze import time while True: fname = "dropfolder/%s.png" %int(time.time()) x = pyscreeze.screenshot(fname)

python gtk loop ascii spinner

前提是你 提交于 2019-12-22 10:09:20
问题 I am trying (for testing) to have a little ascii spinner object being printed on the screen during a gtk.main() loop. Currently, I have this code which prints a dot every two seconds. gobject.timeout_add(2 * 1000, lambda : (sys.stdout.write('.'), sys.stdout.flush()) ) gtk.main() However, I would like the traditional ascii spinner instead but cannot get a good lambda for it. Any suggestions? Edit : Two good answers but is there a way to do this with a lambda? Just 'cause lambda are cool.

gtk minimum size

倖福魔咒の 提交于 2019-12-22 06:47:31
问题 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? 回答1: 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

Enter-Notify-Event Signal not working on gtk.ToolButton

半腔热情 提交于 2019-12-22 06:01:10
问题 On a happy (if not irrevelent) note, this is the absolute last obstacle in this particular project. If I fix this, I have my first significant dot release (1.0), and the project will be going public. Thanks to everyone here on SO for helping me through this project, and my other two (the answers help across the board, as they should). Now, to the actual question... I have a toolbar in my application (Python 2.7, PyGTK) which has a number of gtk.ToolButton objects on it. These function just

How to work with threads in pygtk

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 05:53:48
问题 I have a problem with threads in pygtk. My application consist of a program that downloads pictures off the internet and then displays it with pygtk. The problem is that in order to do this and keep the GUI responsive, I need to use threads. So I got into a callback after the user clicked on the button "Download pictures" and I call the method to download the pictures that is within that same class. thread.start_new_thread(self.images_download, (path,pages) This won't work. The only way I get