gtk3

GtkTreeView with multiple columns and GtkListStore with single custom type (in Python)

冷暖自知 提交于 2019-11-30 15:05:37
I'm trying to display properties of an object on different columns of a Gtk.TreeView . Say I have the following: class MyClass(GObject.GObject): def __init__(self, first, last, age): self.first = first self.last = last self.age = age And I want to store instances in a Gtk.ListStore as shown below. store = Gtk.ListStore(MyClass) Now, when creating the Gtk.TreeView , I don't know how to specify that 2 columns must be rendered, one for the first property and the other for the age property. view = Gtk.TreeView(model=store) # Columns for first and age added here ... These posts (1) and (2) somewhat

How to get Gdk window from xid?

自作多情 提交于 2019-11-30 13:26:54
I'm lost in version 3.. in python2+gdk2 is: #!/usr/bin/env python2 import gtk gtk.gdk.window_process_all_updates() window_xid = 54525964 gdk_window = gtk.gdk.window_foreign_new(window_xid) which is pretty much straight forward. But then, the horror: #!/usr/bin/env python3 from gi.repository import xlib from gi.repository import Gdk from gi.repository import GdkX11 Gdk.Window.process_all_updates() xlib_window = "???????" gdk_display = GdkX11.X11Display.get_default() gdk_window = GdkX11.X11Window.foreign_new_for_display(gdk_display, xlib_window) the xlib is killing me.. I'm unable to do anything

How to make buttons different colours in Python GTK3 (using gi)?

為{幸葍}努か 提交于 2019-11-30 10:16:26
My latest head-scratcher is to build a silly little app in Python3 using GTK3, with colours other than fog-grey on the buttons. I have spent the last few days googling for how to do this, and so far everything I have tried has failed. Not just failed, but failed silently , with no error messages to give me any clue as to what is going on. This is my test app: from gi.repository import Gtk, Gdk class ButtonWindow(Gtk.Window): def __init__(self): super().__init__(title="Button Test") self.set_border_width(10) hbox = Gtk.Box(spacing=10) self.add(hbox) hbox.set_homogeneous(False) # make the button

How to style a GtkLabel with CSS?

旧城冷巷雨未停 提交于 2019-11-30 10:03:52
I'm trying to use CSS to style a GtkLabel. I would like to change the color and font size of the label. Here is my C code: #include <gtk/gtk.h> int main(int argc, char *argv[]) { gtk_init(&argc, &argv); GtkWidget *window = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget *label = gtk_label_new("Label"); GtkCssProvider *cssProvider = gtk_css_provider_new(); gtk_css_provider_load_from_path(cssProvider, "theme.css", NULL); gtk_style_context_add_provider(gtk_widget_get_style_context(window), GTK_STYLE_PROVIDER(cssProvider), GTK_STYLE_PROVIDER_PRIORITY_USER); g_signal_connect(window, "destroy", G

Get font color of the current GTK theme

喜欢而已 提交于 2019-11-30 09:17:26
问题 I need to get the font color of the current theme. I found this question that explains it how to do it in C with gtk_style_lookup_color , but it seems that the function is deprecated. Making more researches I found the new function gtk_style_context_lookup_color But I have problems understanding the docs. Also, when I try to call it by using Gtk.style_context_lookup_color( .. ) I get that it doesn't exists! Is it because I need to call it with something like GtkStyleContext.style_context

GtkTreeView with multiple columns and GtkListStore with single custom type (in Python)

◇◆丶佛笑我妖孽 提交于 2019-11-29 22:13:17
问题 I'm trying to display properties of an object on different columns of a Gtk.TreeView . Say I have the following: class MyClass(GObject.GObject): def __init__(self, first, last, age): self.first = first self.last = last self.age = age And I want to store instances in a Gtk.ListStore as shown below. store = Gtk.ListStore(MyClass) Now, when creating the Gtk.TreeView , I don't know how to specify that 2 columns must be rendered, one for the first property and the other for the age property. view

How to remove white border in gVim 8 with gtk 3

泄露秘密 提交于 2019-11-29 16:57:14
问题 I recently updated my gVim to version 8 compiled with gtk 3, and I found there are strange inner borders around the gVim window: This picture may not very clear but if you look carefully you can see the white borders on the right side and the bottom. I have solved this issue by setting a dark color to the border on gtk 2, but on gtk3 it happends again. Any idea of removing this border completely on gtk 3? 回答1: Gtk3 uses css to style applications. To remove the white border from the gVim

How to fix error “GLib-GIO-ERROR**: No GSettings schemas are installed on the system”?

半世苍凉 提交于 2019-11-29 16:44:09
I have to create a one-file (.exe) program with InstallShield2015LimitedEdition that works with GTK3.4.2 and OpenCV 3.0.0 in Windows 7 x64 . In this program the user can choose a directory from their computer. But when I invoke FileChooser (click on executable) I get this error: GLib-GIO-ERROR**: No GSettings schemas are installed on the system and the program terminates. I visited these pages: Glib-GIO-ERROR when opening an file chooser dialog GLib-GIO-ERROR**: No GSettings schemas are installed on the system How deal with FileChooser in GTK with static compilation But I never understood

run part of code as root

时光总嘲笑我的痴心妄想 提交于 2019-11-29 16:24:28
I have a package which runs uses Gtk and written in vala.A dialog box or a gui opens after selecting a file.I want this dialog box or gui to run as root so as to open and read the files which don't open with normal users.I have this code static void open_file(string filename) { selected_file = filename; stdout.printf(selected_file); new ProgressWindow(selected_file, {}); } I want to run ProgressWindow to run as root.Is it possible? No. To run as root, it must be in a separate process and you must run that process using pkexec via PolicyKit. Here's a tutorial on PolicyKit in Vala. 来源: https:/

Can I style GtkBox margin/padding with CSS only?

爷,独闯天下 提交于 2019-11-29 15:31:48
How can i make layout like this using CSS stylesheet for GTK app? Here is example code: #!/usr/bin/python import gi gi.require_version("Gtk", "3.0") gi.require_version("Gdk", "3.0") from gi.repository import Gtk, Gdk # Main application window # ======================= class MainWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self) self.connect("delete-event", Gtk.main_quit) self.set_name("main-window") # load style from file cssProvider = Gtk.CssProvider() cssProvider.load_from_path('style.css') # get the default screen for the default display screen = Gdk.Screen.get_default() #