gtk

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

淺唱寂寞╮ 提交于 2019-12-21 23:57:14
问题 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

How to save webkit page image resources from memory?

依然范特西╮ 提交于 2019-12-21 21:33:00
问题 I open page with python, gtk, and webkit. Now - how to save image from that page without downloading it again from the internet? 回答1: Here is a python program that will save a rendered web page to an image: http://pastie.org/4572412 This should be the section of primary interest to you: size = self.browser.mainFrame().contentsSize() if width > 0: size.setWidth(width) self.browser.setViewportSize(size) # Render the virtual browsers viewport to an image. image = QImage(self.browser.viewportSize

Example code for a minimal paint program (MS Paint style)

大兔子大兔子 提交于 2019-12-21 20:22:10
问题 I want to write a paint program in the style of MS Paint. On a most basic level, I have to draw a dot on the screen whenever the user drags the mouse. def onMouseMove(): if mouse.button.down: draw circle at (mouse.position.x, mouse.position.y) Unfortunately, I'm having trouble with my GUI framework (see previous question), I'm not getting mouse move messages frequently enough. I'm using the GUI framework wxWidgets and the programming language Haskell. Question: Could you give me some example

How do I take a screenshot using GdkPixbuf?

﹥>﹥吖頭↗ 提交于 2019-12-21 20:18:27
问题 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. 回答1: 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

Editing GtkWidget attributes/properties

此生再无相见时 提交于 2019-12-21 19:48:27
问题 In most pygtk widget pages, they contain sections called 'Attributes', 'Properties', and 'Style Properties'. How can I change these properties and attributes? 回答1: There are three ways to change properties: As in zheoffec's answer, use the set_property() function (or set_style_property() for style properties.) This function is actually not necessary in Python, but it is there for completeness because it is part of the C API. Use the props attribute. Any property that you find in the

Desktop integrated application (desktop widget like)

喜欢而已 提交于 2019-12-21 17:16:49
问题 i'm currently playing with the idea writing a desktop-integrated application for my personal system, which should act similar like usual desktop widget engines (screenlets, gdesklets, google gadgets). It should give me a complete overview about different information about my system, from the internet and should finally visualize them on my desktop. It should centralized all my daily necessary information. The easiest way would be surely to write my own widgets for one of the known desktop

Gtk+ icon missing when running in MS Windows

孤者浪人 提交于 2019-12-21 05:48:23
问题 I have a C/GTK+ application developed on Ubuntu, and I want to cross-compile it so that it runs on MS Windows. I followed this guide to set up the compiler, and the program was compiled successfully, and it runs on MS Windows. However, the icons on a Search Entry were missing. This is what I get when I'm on Ubuntu: This is what I get when I run the program in MS Windows (or Wine): In addition, the terminal shows the following: (main.exe:8): Gtk-WARNING **: Could not find the icon 'edit-find

How to get a num lock state using C/C++?

孤者浪人 提交于 2019-12-21 05:47:15
问题 I have read Gdk forum link which says that getting num lock state api is implemented since version 3.0. But I am using version 2.4 and I cannot update to version 3.0 as I need to support lower Linux version. Here is the discussion link: http://mail.gnome.org/archives/commits-list/2010-July/msg00259.html SO, is there any other way to get the num lock state using internal Linux command? Regards, iSight 回答1: Sample code to get the NumLock state. Let foo.c be: #include <stdio.h> #include <X11

How do I pass multiple variables as data with gtk signals

大憨熊 提交于 2019-12-21 04:01:01
问题 I have a small program where a gtk signal callback function needs 2 or 3 variables. I don't want to make these global variables (The entire goal of the project is to be neat and tidy) and I don't want to make a whole struct just so I can send a widget and a compiled regex to a function. As far as I've seen g_signal_connect only allows for a single data variable. Would the most efficient way of doing this perhaps be an array of void pointers to the two objects in question? Something like this?

Where GTK finds icon names to use with gtk_image_new_from_icon_name()?

*爱你&永不变心* 提交于 2019-12-20 18:05:48
问题 GTK can construct images by name of the "icon from current icon theme". For example: #!/usr/bin/env python import gtk; wnd=gtk.Window(); img=gtk.Image(); img.set_from_icon_name( "go-jump", gtk.ICON_SIZE_BUTTON ); wnd.add( img ); img.show(); wnd.show(); gtk.main() This will display a window with a pretty arrow inside it. But - only on ubuntu. On Windows or OSX it will display window with a "no image" icon inside :(. So my questions is - where GTK keeps icon names like "go-jump"? Is it some