pygtk

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

How can I find out why/when a Python object loses attributes?

 ̄綄美尐妖づ 提交于 2019-12-21 20:37:01
问题 Update 2013-02-08 I have an idea now why I haven't been able to reproduce this problem in a small piece of test code. In a small program, Python's garbage collector isn't very active. I believe the problem is that Python is collecting some objects that are only referenced in GObject. I think it's a regression involving this bug, or a new similar bug. I figured this out because I encountered the same problem again, but with my own class (which has references only from GObject objects) -- this

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

A sorted and filtered treemodel in Python Gtk+3..?

跟風遠走 提交于 2019-12-21 04:46:05
问题 I am trying to get a treemodel (a liststore in fact) that can be filtered and also sorted. I have the following piece of code self.modelfilter = self.liststore.filter_new() self.modelfilter.set_visible_func(\ self._visible_filter_function) self.treeview.set_model(self.modelfilter) where self.liststore and self.treeview are standard Gtk.ListStore and Gtk.TreeView objects that I get from a glade file, and self._visible_filter_function is a filtering function. The problem is that self

Periodically call a function in pygtk's main loop

跟風遠走 提交于 2019-12-21 04:34:14
问题 What's the pygtk equivalent for after method in tkinter? I want to periodically call a function in the main loop. What is the better way to achieve it? 回答1: Use gobject.timeout_add: import gobject gobject.timeout_add(milliseconds, callback) For example here is a progress bar that uses timeout_add to update the progress ( HScale ) value: import gobject import gtk class Bar(object): def __init__(self,widget): self.val=0 self.scale = gtk.HScale() self.scale.set_range(0, 100) self.scale.set

How to install poppler in ubuntu 15.04?

匆匆过客 提交于 2019-12-20 12:26:53
问题 Poppler is a PDF rendering library based on the xpdf-3.0 code base. I have already downloaded the tar.xz file from the official site http://poppler.freedesktop.org/ But I do not know what to do with this file Is there any command to install or run? P.S. - I am new to linux, so I don't know a lot about it yet.. 回答1: What you downloaded from poppler site is source code and you may not be expert enough to install it yourself. For such situations, Ubuntu and other linux distros manage packages of

How to install poppler in ubuntu 15.04?

白昼怎懂夜的黑 提交于 2019-12-20 12:26:44
问题 Poppler is a PDF rendering library based on the xpdf-3.0 code base. I have already downloaded the tar.xz file from the official site http://poppler.freedesktop.org/ But I do not know what to do with this file Is there any command to install or run? P.S. - I am new to linux, so I don't know a lot about it yet.. 回答1: What you downloaded from poppler site is source code and you may not be expert enough to install it yourself. For such situations, Ubuntu and other linux distros manage packages of

Socket Thread and PyGTK

妖精的绣舞 提交于 2019-12-20 02:51:11
问题 I'm trying to write a instant messaging program, the basic ui is almost finished and i'm looking into the receiving part of messages. I have an UI class and a threaded Receive_Socket class. Each time the socket of the Received_Socket class receive a message, it does a gobject.idle_add() to call an UI method in order to display the message into a chat window. After the gobject.idle.add() line, i have a while loop which loops until the message is in fact displayed in the chat window ( I want

Python&PyGTK: Stop while on button click

浪子不回头ぞ 提交于 2019-12-19 21:24:18
问题 I'm working on programming some application and I would like to create while loop when button is clicked and if it's clicked again to stop it. This is the code for button: self.btnThisOne = gtk.Button("This one") self.btnThisOne.connect("clicked", self.startLoop) The code for startLoop def would be: def startLoop(self): while self.btnThisOne?(is_clicked)?: #do something How to do that? 回答1: Unfortunately, you cannot just have an unconstrained while loop running in the main thread of your

_really_ disable GtkTreeView searching

末鹿安然 提交于 2019-12-19 19:04:52
问题 How do I really disable gtk treeview interactive search? The docs say to set_enable_search(False) , but if I do this, CTRL + F still causes an annoying search pop-up to appear. Connecting to start-interactive-search and returning True doesn't work either. 回答1: The pygtk docs don't state this, but the C docs do: gtk_tree_view_set_search_column (GtkTreeView *tree_view, gint column) column : the column of the model to search in, or -1 to disable searching Passing -1 for the column really