pygtk

Cairo context and persistence?

扶醉桌前 提交于 2020-02-02 06:31:32
问题 I am just getting started using pycairo, and I ran into the following interesting error. The program I write creates a simple gtk window, draws a rectangle on it, and then has a callback to draw a random line on any kind of keyboard input. However, it seems that with each keyboard input, I have to create a new context, or I get an error at the moment the program receives first keyboard input (specifically, on the .stroke() line). Error is as follows, if it matters. 'BadDrawable (invalid

Using markup with Gtk.TextView

不羁的心 提交于 2020-01-25 00:43:13
问题 I have been trying to find a way to use Pango markup with Gtk.TextView and Gtk.TextBuffer in Python GObject , but it seems like this functionality is only available for tooltips and labels. Gtk.TextBuffer has the insert_markup method, but requires Gtk.TextIter as input, and must be of specified length. The issue here is that I want to use Gtk.TextView only for displaying text without it being editable. So while I think I understood how you use Gtk.TextTag with editable/selectable text to

ImportError: No module named gi.repository Mac OS X

為{幸葍}努か 提交于 2020-01-22 18:58:44
问题 I am installing virt-manager0.10.0 on Mac OS X First I installed python,libvirt, gtk+3, pygtk, and other dependencies with homebrew But when I run virt-manager I got this error from gi.repository import GObject ImportError: No module named gi.repository When I run this import in python command line I get same error.but there is no error when I try import gtk I think the problem is the homebrew pygtk version doesn't use gtk+3 and uses gtk2 and as we can see here gi.repository Windows only gtk

Finding the workspace size (screen size less the taskbar) using GTK

可紊 提交于 2020-01-21 03:28:27
问题 How do you create a main window that fills the entire desktop without covering (or being covered by) the task bar and without being maximized ? I can find the entire screen size with and set the main window accordingly with this: window = gtk.Window() screen = window.get_screen() window.resize(screen.get_width(), screen.get_height()) but the bottom of the window is covered by the task bar. 回答1: You are totally at the mercy of your window manager for this, and the key issue here is: without

TypeError :object of type 'GtkSpinner' does not have property 'num-steps'

巧了我就是萌 提交于 2020-01-16 19:27:27
问题 I am learning about Spinners in PyGtk. I executed this program : #!/usr/bin/env python import gtk class Spinner: def __init__(self): window=gtk.Window() window.set_default_size(200,200) vbox = gtk.VBox(False, 5) hbox = gtk.HBox(True, 5) self.spinner = gtk.Spinner() self.spinner.set_property("num-steps", 10) button_start = gtk.Button("Start") button_stop = gtk.Button("Stop") window.connect("destroy", lambda q : gtk.main_quit()) button_start.connect("clicked", self.start_animation) button_stop

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

Embed interactive shell (VTE) in a PyGtk GUI to manipulate its own widgets

放肆的年华 提交于 2020-01-14 03:12:06
问题 I am planning to do the folliwing: Create a PyGtk GUI (hardcoded, no Glade) with some widgets, and at the bottom of the screen put some sort of VTE (Virtual Terminal Emulator) from where I could manipulate the widgets, for example changing their attributes and calling their methods from the commandline. The result would be similar to using AutoCAD's commands, only that I would be acting upon the GUI objects. I have already found very few things about gtk.VteTerminal widget, but not only could

Webkit threads with PyGObject on Gtk3

梦想与她 提交于 2020-01-13 09:31:52
问题 I am trying to load a webkit view on a different thread than main thread for gtk. I see the example PyGTK, Threads and WebKit I slightly modify for support PyGObject and GTK3: from gi.repository import Gtk from gi.repository import Gdk from gi.repository import GObject from gi.repository import GLib from gi.repository import WebKit import threading import time # Use threads Gdk.threads_init() class App(object): def __init__(self): window = Gtk.Window() webView = WebKit.WebView() window.add

Entry with suggestions

六眼飞鱼酱① 提交于 2020-01-12 08:11:08
问题 I'm building a small PyGTK application and I have an text input field (currently a ComboBoxEntry) which is populated with a few values that the user should be able to choose from. I think what I want to do is to filter out the matching fields and only show those ones so the user using the keyboard arrows can choose one of the matching ones. To give some background the predefined values are a bunch of urls and the user should be able to choose from theese or fill in a new one. Example: the

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