gtk3

Package PyGObject Python 3 program with pynsist?

喜夏-厌秋 提交于 2019-12-05 02:28:02
问题 I would like to package a Python3-PyGObject program with pynsist. The repository has an example for PyGTK and it made me think that it shouldn't be too hard to change the example. The example can be found here: https://github.com/takluyver/pynsist/tree/master/examples/pygtk In this file (https://github.com/takluyver/pynsist/blob/master/examples/pygtk/grab_files.sh) I think one just has to grab the files targeting GTK 3 (http://www.gtk.org/download/win32.php): wget -O gtkbundle.zip http:/

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

别等时光非礼了梦想. 提交于 2019-12-04 22:48:23
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/laurence/foo/bar.txt is an existing text file)... recent_mgr.add_item('file:///home/laurence/foo/bar

How to set multiple items into a GtkSelection for Treeview drag and drop

别说谁变了你拦得住时间么 提交于 2019-12-04 20:59:37
My current project uses a Gtk.TreeView to display the contents of a ListView with four fields per row, two strings, an int and a boolean . I'm trying to implement drag and drop rearrangement of rows in the TreeView. I don't want simply to use TreeView.set_reorderable(True) for the built-in drag and drop because I want to have some control over the insertion and deletion of data from the model as well as to be able to implement undo/redo of drag and drop operations. I'm using Python 3.2 and PyGObject 3. The problem I'm now having is figuring out how in my drag_data_get method to set the

Gtk3 label line spacing

ε祈祈猫儿з 提交于 2019-12-04 19:32:12
Is there any way to specify spacing between lines of text in multiline Gtk3 Label, as with CSS line-height property? This CSS property does not work and I can't google out anything else. user1150388 I found the solution using Pangoattribute on label <br>PangoAttrList *attr_list;</br> <br>PangoAttribute *attr;</br> <br> attr_list=pango_attr_list_new();</br> <br>attr=pango_attr_rise_new (20000);</br> <br>pango_attr_list_insert(attr_list,attr);</br> <br>gtk_label_set_attributes(GTK_LABEL(label),attr_list);</br> 来源: https://stackoverflow.com/questions/25139645/gtk3-label-line-spacing

How to limit number of decimal places to be displayed in Gtk CellRendererText

余生长醉 提交于 2019-12-04 19:21:27
I am trying to limit the amount of decimal places shown in a Gtk.CellRendererText. Currently a float number field is shown with 6 decimal places, but I would like to have just 1. This test code should work on Linux: #!/usr/bin/python3 from gi.repository import Gtk class MyWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="Hello World") self.set_default_size(200, 200) self.liststore = Gtk.ListStore(float) treeview = Gtk.TreeView(model=self.liststore) self.liststore.append([9.9]) self.liststore.append([1]) xrenderer = Gtk.CellRendererText() xrenderer.set_property("editable"

Set the hover background color of a Gtk3 MenuItem

瘦欲@ 提交于 2019-12-04 13:47:58
I have a tray icon with a popup menu. I am trying to set the background color of the menu items in this popup. I am able to set the text color but not the background color of the menu item. The background that appears is the default Ubuntu orange, and I can't override it. I've created a sample application that demonstrates this problem. Just copy-paste it into a .py file and it should run. from gi.repository import Gtk, Gdk import sys class TrayIcon: def __init__(self): self.statusicon = Gtk.StatusIcon() self.statusicon.set_from_stock(Gtk.STOCK_MEDIA_PLAY) self.statusicon.connect("popup-menu",

How to use a custom font in a GTK app

孤街醉人 提交于 2019-12-04 13:00:26
I have a font file /path/to/app/fonts/custom-font.ttf and I want to use it. How do you import a custom TTF for use in a GTK+3.0 app? from gi.repository import Gtk, Pango # ... lbl = Gtk.Label() lbl.modify_font(Pango.FontDescription("sans 48")) # lbl.modify_font(Pango.FontDescription("custom-font 48")) If you want to using it as a preview to your own app, install the font and uncomment the last line (provide the right name). If you want to use it as custom font for final release, i suggest you package with the font and make a script to install it. A little note, (in C), ".modify_font"

How do I take a screenshot using GdkPixbuf?

时光怂恿深爱的人放手 提交于 2019-12-04 12:51:12
Using PyGTK, I used to be able to take a screenshot using gtk.gdk.pixbuf.get_from_drawable . I can't seem to figure out how to do that using PyGObject and GdkPixbuf. I've tried get_from_drawable and get_from_window but neither work in PyGObject. Thanks in advance. Use Gtk.OffscreenWindow : offscreen_window = Gtk.OffscreenWindow() offscreen_window.add(widget_that_needs_screenshotting) pixbuf = offscreen_window.get_pixbuf() 来源: https://stackoverflow.com/questions/14544500/how-do-i-take-a-screenshot-using-gdkpixbuf

pango attributes with pygobject

亡梦爱人 提交于 2019-12-04 11:55:39
问题 I have the following code, that uses pygtk: attr = pango.AttrList() attr.change(pango.AttrSize(( 50 * window_height / 100) * 1000, 0, -1)) attr.change(pango.AttrFamily("Sans", 0, -1)) attr.change(pango.AttrWeight(pango.WEIGHT_BOLD, 0, -1)) attr.change(pango.AttrForeground(65535, 65535, 65535, 0, -1)) self.label.set_attributes(attr) I'm trying to port it to pygobject, but there is no class Pango.AttrFamily, neither Pango.AttrWeight, neither Pango.AttrForeground (and I can not instantiate a

gtk3+ and python rgba convert to hex

南楼画角 提交于 2019-12-04 06:54:24
问题 i using gtk3 i found that it use rgba for representing color, but the (red,green,blue,alpha) are not integer between 0-255 but floating point number between 0-1.0 , so i don't know how to convert from rgba to hex and vice-versa i have tried this code but its seem to not work : def convert_to_hex(rgba_color) : red = str(hex(int(rgba_color.red*255)))[2:].capitalize() green = str(hex(int(rgba_color.green*255)))[2:].capitalize() blue = str(hex(int(rgba_color.blue*255)))[2:].capitalize() return