pygtk

Changing the selected item colour in a GtkTreeview using python

本小妞迷上赌 提交于 2019-12-01 17:11:48
问题 I have a dialog which contains a pygtk.treeview for listing tasks by priority. Each row has the background colour set based on that priority, so for example the highest priority has a light red background. The row selection color is not so easy to change. I can set it using treeview.modify_base(gtk.STATE_SELECTED, "#C4C4C4") , but no colours work well with the colours used to enhance the concept of priority. I had the idea to change the selection colour to be a slightly darker version of the

Setting up developement environment: PyCharm, python-gtk, windows

自作多情 提交于 2019-12-01 16:39:11
I want to develop with these tools: MS-Windows 10 Python3 gtk PyCharm I installed PyCharm, but up to now Python and gtk are not installed up to now. Sub questions: use 32 or 64 Bit version of Python? How to install gtk for python (pip or exe)? Use virtual env in PyCharm or use "Existing Interpreter"? AFAIK you cant install gtk for Python on Windows with pip. Update I follow this guide now: https://pygobject.readthedocs.io/en/latest/getting_started.html#windows-getting-started Update2 gtk on windows seems to be hardly used. There were many strange things, and I use pyside2 (QT) now and I am

Detect user logout / shutdown in Python / GTK under Linux - SIGTERM/HUP not received

眉间皱痕 提交于 2019-12-01 15:53:06
问题 OK this is presumably a hard one, I've got an pyGTK application that has random crashes due to X Window errors that I can't catch/control. So I created a wrapper that restarts the app as soon as it detects a crash, now comes the problem, when the user logs out or shuts down the system, the app exits with status 1. But on some X errors it does so too. So I tried literally anything to catch the shutdown/logout, with no success, here's what I've tried: import pygtk import gtk import sys class

save gtk.DrawingArea to file

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 10:54:11
问题 I want to save gtk.DrawingArea() object contents to jpeg file using PIL. Particularly I want add to this script possibility to make photo. I found how to save image to jpeg. All I need - get pixbuf object from gtk.DrawingArea() object. How can I do this? 回答1: If you're not married to the idea of using gstreamer, you can use OpenCV instead. This post gives a great example using pygame. However, you can get the pixbuf this way (and you don't even need PIL): def get_picture(self, event, data):

How to make GtkListStore store object attribute in a row?

ぐ巨炮叔叔 提交于 2019-12-01 10:49:02
I'w trying to keep at ListStore non-text objects using snippet I found. These are the objects: class Series(gobject.GObject, object): def __init__(self, title): super(Series, self).__init__() self.title = title gobject.type_register(Series) class SeriesListStore(gtk.ListStore): def __init__(self): super(SeriesListStore, self).__init__(Series) self._col_types = [Series] def get_n_columns(self): return len(self._col_types) def get_column_type(self, index): return self._col_types[index] def get_value(self, iter, column): obj = gtk.ListStore.get_value(self, iter, 0) return obj And now I'm trying

GTK window capture: VPython (OpenGL) application

和自甴很熟 提交于 2019-12-01 09:02:38
Having read the documentation for VPython and GTK threading , it seems to me that it would be possible to embed VPython graphics within a gtk GUI. I know that it is possible with wx on Windows but I am on Linux and using PyGTK. Now, I have managed to get part of the way. I can embed a VPython window provided that it is spawned a separate process . What I would like is to embed it as a thread. The latter would make GUI events that control the OpenGL easier to implement -- via a thread instead of a socket and network calls. Edit: Apparently nobody knows anything about this... Meh. Here is the

Get colors of current gtk style

时间秒杀一切 提交于 2019-12-01 08:22:15
I use PyGTK and I want to get colors of a widget (for example bg color), I run such a code: gdkColorToRgb = lambda gc: (gc.red//257, gc.green//257, gc.blue//257) widget = gtk.HBox() ## for example style = widget.get_style() for i in range(5): print i, gdkColorToRgb(style.bg[i]) But it does not give colors of my current gtk theme(style). It seems to be for default gtk theme (my current theme is dark, while this code gives light colors) I use ArchLinux and PyGTK 2.24.0 (GTK 2.24.5) I just stumbled upon the same issue, saw your question and found a solution: You have to wait until the widget is

How to make GtkListStore store object attribute in a row?

♀尐吖头ヾ 提交于 2019-12-01 08:15:51
问题 I'w trying to keep at ListStore non-text objects using snippet I found. These are the objects: class Series(gobject.GObject, object): def __init__(self, title): super(Series, self).__init__() self.title = title gobject.type_register(Series) class SeriesListStore(gtk.ListStore): def __init__(self): super(SeriesListStore, self).__init__(Series) self._col_types = [Series] def get_n_columns(self): return len(self._col_types) def get_column_type(self, index): return self._col_types[index] def get

How to iterate over two lists - python

喜欢而已 提交于 2019-12-01 07:57:04
问题 Hey guys. I'm trying to do something in pyGTk where I build a list of HBoxes: self.keyvalueboxes = [] for keyval in range(1,self.keyvaluelen): self.keyvalueboxes.append(gtk.HBox(False, 5)) But I then want to run over the list and assign A text entry & a label into each one both of which are stored in a list. I'm sorry I'm not being very specific, but if you need more help with what I'm doing I'll help! Thanks! 回答1: If your list are of equal length use zip >>> x = ['a', 'b', 'c', 'd'] >>> y =

How to drag images with pygtk

ⅰ亾dé卋堺 提交于 2019-12-01 05:02:28
问题 How can I drag/move images using pygtk? Here is a video of someone doing it, however the person did not give the source code. 回答1: here's a little demo (i don(t remmeber excatly were it comes from, sorry) which is very similar to the one found here: http://www.pygtk.org/pygtk2tutorial/examples/dragndrop.py import gtk class DragImage(gtk.Image): def __init__(self,image,layout): gtk.Image.__init__(self) self.drag = False self.drag_x = 0 self.drag_y = 0 self.layout = layout self.x = 0 self.y = 0