gtk

In PyGTK, what is a simple way to show a PNG file?

夙愿已清 提交于 2020-01-14 13:32:13
问题 The following PyGTK code displays a PNG file in a window. Is there a simpler or better way of displaying the PNG file, like, by using a gtk.DrawingArea? For example, how do you resize the file? import gtk import pygtk pygtk.require('2.0') class Gui: def __init__(self): # Create an Image object for a PNG file. file_name = "file.png" pixbuf = gtk.gdk.pixbuf_new_from_file(file_name) pixmap, mask = pixbuf.render_pixmap_and_mask() image = gtk.Image() image.set_from_pixmap(pixmap, mask) # Create a

c - Passing multiple arguments to a callback function in GTK

吃可爱长大的小学妹 提交于 2020-01-14 13:07:04
问题 So, I'm trying to achieve the following: The user shall be able to fill out multiple gtk_entry 's and click Apply after that, on being clicked I want the Apply button to emit a signal, something like this: g_signal_connect (G_OBJECT (Apply), "clicked", G_CALLBACK(apply_clicked), # an argument #); Afterwards, in apply_clicked() , I want the entered text to be saved. My question is: How do I pass those gtk_entry 's to my callback function apply_clicked ? If it were only one I'd just set it as #

c - Passing multiple arguments to a callback function in GTK

谁说我不能喝 提交于 2020-01-14 13:06:24
问题 So, I'm trying to achieve the following: The user shall be able to fill out multiple gtk_entry 's and click Apply after that, on being clicked I want the Apply button to emit a signal, something like this: g_signal_connect (G_OBJECT (Apply), "clicked", G_CALLBACK(apply_clicked), # an argument #); Afterwards, in apply_clicked() , I want the entered text to be saved. My question is: How do I pass those gtk_entry 's to my callback function apply_clicked ? If it were only one I'd just set it as #

gtk styles not behaving properly

南笙酒味 提交于 2020-01-14 04:42:27
问题 I was attempting to mess with the style of a Button , and noticed that my changes were making the button look strange. To make sure I was doing the right thing, I tried doing what I thought would be semantically a no-op: button.set_style(button.get_style()) However, the button style changes dramatically after this line. I'm on Windows 7. Without this line, it looks like a regular windows 7 button - rounded, nice gradient, light-blue on highlight, etc. After the line, it looks like an ugly old

Is it possible to define GTK+ type using gtkmm?

风格不统一 提交于 2020-01-14 04:05:13
问题 I would like to define a new subclass of some gtkmm type, implementing interface of underlying GTK+ object. Then, i want to compile it into some kind of dll and use in pure C code (GTK+, no gtkmm) through this interface. Is it possible? 回答1: The followings are required to use gtkmm widget in GTK+ : implement the desired custom widget in gtkmm create a library from the widget for Glade design the user interface containing the custom widget with Glade declare the C interface for the application

Gtk buttons over a Gtk drawing area

我们两清 提交于 2020-01-14 03:50:13
问题 i' working with Gtk developing some app. I must put some buttons over a map. I'm drawing the map on a GtkDrawingarea, but i'm not able to put buttons over it. Any suggestion? Thanks 回答1: Suggestions: Put both the drawing area and the buttons inside a GtkFixed container. Probably not the best solution, because GtkFixed has no way of controlling the z-ordering (other than the order in which you add the widgets to it?) Instead of using GtkDrawingArea , use a canvas widget that can include other

C# Mono Linux - Grab contents of global clipboard

半腔热情 提交于 2020-01-14 03:20:12
问题 I am trying to simply "grab" text from the clipboard and put into a variable. I'm having a lot of trouble doing this. I've tried to use Gtk.Clipboard.Get(Gdk.Atom.Intern("PRIMARY", true)) The code that I have so far, just returns "Gtk.Clipboard" to TextBox entry1. Gtk.Clipboard clipboard = Gtk.Clipboard.Get(Gdk.Atom.Intern("PRIMARY", true)); string textClip = clipboard.ToString (); entry1.Text = textClip; So I am unable to do anything productive with this. 回答1: Try this piece of code to get

Destructing Glib::RefPtr causes failed assertions in the GTK 3 core

╄→гoц情女王★ 提交于 2020-01-12 18:51:50
问题 The guys from Gtkmm are comparing Glib::RefPtr with std::auto_ptr<> : Glib::RefPtr is a smartpointer. Specifically, it is a reference-counting smartpointer. You might be familiar with std::auto_ptr<> , which is also a smartpointer, but Glib::RefPtr<> is much simpler, and more useful. But for some strange reason, I can't get my work done with the RefPtr . The same code is just fine with a auto_ptr . In the following code, SmartPtr is just a placeholder for one of these two smartpointers.

How to have drag-and-drop and sorted GtkTreeView in GTK3?

和自甴很熟 提交于 2020-01-12 06:53:27
问题 I am porting liblarch, a library for handling directed acyclic graphs, from PyGTK (GTK2) to PyGObject introspection (GTK3). I ran into the problem with GtkTreeView. The app using liblarch needs to sort GtkTreeView by a column but in the same time, the user can drag-and-drop rows, move a row under another row. For that I had to manually process dnd_data_get() and dnd_data_receive() which is perfectly okay. There is the minimal setup for GtkTreeView which works under PyGTK. Rows are sorted and

C GTK+ periodic event to update the UI

给你一囗甜甜゛ 提交于 2020-01-11 10:19:06
问题 How can I update a GTK+ interface on a periodic event. For example, let's say I wanted to update a text field containing the time every 200 milliseconds. How is this typically done? Update: Another question (How one executes a periodic job in gtk application?) mentiones g_timeout_add. Is this the best way to go about doing this? It is said in that thread that it may not be efficient? 回答1: This tutorial has an example. (Search for the section titled "A timer example".) The short answer is "use