Re: [pygtk] How to modify python scripts at install time with distutils (was: How to build a PyGTK application with autotools for Windows)
Leonardo Ferreira Fontenelle wrote: > [...] > > Do anyone has advice on how do I get the setup script to edit a python a > file at install time with such data? Maybe not in the best possible way, but Py-gtktree [*] does that. Check files 'gtktree/__init__.py.in' and 'setup.py'. [*] https://launchpad.net/py-gtktree Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Problem with window.set_modal()
Mauro Giacomini wrote: > I have a problem with the set_modal function in a pygtk program I'm writing. > The situation: > I have a main window; when the user clicks on a button, a new window > came up for the selection of a particular item in a treeview. > When the user confirm the selection with the click on the "ok button", > this window disappear (destroy) and the interaction return to the main > window. > But, although I declare the second window such as modal window and > transient for main window, the instruction I put in the main window > after the call to the second window are executed without waiting the > response for the second window. > Is there something else to do? > Or is there a better approach to a similar situation? Modality itself only prevents user from interacting with other application windows. It doesn't cause application to wait for window response anywhere. If you want to get response "now", use gtk.Dialog.run(). Note that GNOME programs are generally not recommended to use modal windows. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Get width from a pane
Henning Bredel wrote: > I want to load an image in the right pane of a gtk.HPaned. The image > shall fit in the pane (I don't want to use a scrolled pane for that). > > How can I determine the currently used width of the right pane? Untested: paned.get_children () [1].allocation.width Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] pyGtk segfault comparing gtk.Image with 0
Pietro Battiston wrote: > What I mean is: where is it written that every crash is a bug, if Pygtk > developers themselves are not so clear on that (and I'm possibly too > ignorant)? I am a PyGTK developer (not active currently), Matthias Classen is not. He is a developer of GTK+ itself. I think it is pretty much common sense that Python or any other script language must not crash. For the record, the bug with gtk.Image (actually, with almost any PyGObject wrapper class) is known and there is an entry for it in the Bugzilla. It is a bug in PyGTK/PyGObject, not GTK+. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] pyGtk segfault comparing gtk.Image with 0
Pietro Battiston wrote: > Il giorno sab, 17/10/2009 alle 17.30 +0100, Tomeu Vizoso ha scritto: > > On Sat, Oct 17, 2009 at 17:12, René 'Necoro' Neumann > > wrote: > > > > > > Well -- you are not initializing gtk.Image. So it's your very own > > > mistake. I don't see a pygtk issue here. > > > > This is Python, any crash is a bug. > > Wait, wait. > > Read http://bugzilla.gnome.org/show_bug.cgi?id=561130 , then come back > here and let's talk :-) > > Pietro > > (P.S: as you can desume from the page, I _would like_ to agree with you) You can still rightfully agree with him that it _is_ a bug. Whether it gets fixed is another point. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] ToggleButton args break with python2.6
Thomas Mills Hinkle wrote: > After a recent OS upgrade, I found that my code broke with the following: > > self.pause = gtk.ToggleButton(_('_Pause'),True) > > [...] > python2.6 / pygtk 2.14: error There is a typo in PyGTK code. Can you check if the following helps? Paul diff --git a/gtk/gtk.override b/gtk/gtk.override index 8d7a0f5..cabe3b7 100644 --- a/gtk/gtk.override +++ b/gtk/gtk.override @@ -1713,7 +1713,7 @@ _wrap_gtk_toggle_button_new(PyGObject *self, PyObject*args, PyObject*kwargs) PyObject *py_use_underline = Py_True; if (!PyArg_ParseTupleAndKeywords(args, kwargs, - "|zO):GtkToggleButton.__init__", kwlist, + "|zO:GtkToggleButton.__init__", kwlist, &text, &py_use_underline)) return -1; if (text) ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] try/except won't trap DeprecationWarning from OptionMenu
Alessandro Dentella wrote: > I'd like to use deprecated OptionMenu, but I can't stop the > DeprecationWarning. Why is it different from a self produced one? It is not different. Please see the 'warnings' module. Last time I checked the warnings filters described there could be used to suppress warnings from PyGTK as well. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] scrolledwindows and treeview
francesco wrote: > Hi, i have a treeview inside a scrolledwindows > when i append a new row scrolledwindows daesn't scroll until bottom but > stay up, > if i scrolled by hand until bottom and so append a new row it scroll a > bit and cover the last row inserted. > HOw can i make scrolledwindows to scroll to show always the last row > inserted? Use gtk.TreeView.scroll_to_cell. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Python 3.0
Daniel Lewis wrote: > Can anyone clarify the status of PyGTK with Python 3.0? As an end user, is > it just a case of re-compiling? [...] Current PyGTK will not compile with Python 3 libraries. Maybe PyGTK 2.16 will, but I'm not aware of any plans to make it compatible. Major problem is the multitude of changes Python 3, especially in its C interface. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] Setting value of gtk.SpinButton without triggering the "value-changed" event.
Osmo Maatta wrote: > I need to change the self.width_spin (gtk.SpinButton) value, but in some > cases I do not want the changed event to fire. [...] Actually you don't. There can be some handlers that you don't know of, e.g. GTK+ itself can install some handlers for its own purposes. Then, if you slip some value change in without the corresponding signal, the code behind such handlers can break in unpredictable manner. What you should do instead is to block handlers you don't want to be run during this change and unblock them afterwards (or disconnect and the reconnect again). Or maybe set some internal boolean variable which means "ignore this change" for your handlers. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] spinbutton set value and signal
Frédéric wrote: > Is there a way to set the value of a spinbutton without having > its 'value-changed' signal emitted? No. Why do you need that? Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://faq.pygtk.org/
Re: [pygtk] PyGTK and threading
Vláďa wrote: > [...] > However the are some things which are unclear to me. First I read that I > have to use gtk.gdk.threads_enter() and gtk.gdk.threads_leave() whenever > I want to modify something in main GUI. But if I remove these commands I > don't see any change. It still works. What exactly do these calls? With threads there are certain bugs that appear only at times. When you remove enter/leave, you most likely trigger such bugs. I.e. it may work fine for you 100 times, then crash or something else on 101th. And on some other machine it may crash every second time. In other words, _never_ remove enter/leave unless you understand what you are doing. > [...] > Apparently I'm doing something wrong because after making my application > a little bigger, I have random freezes and locks. I'm absolutely new to > threads, I understand what are they good for, but unfortunately I have > almost no idea about the consequences and the problems they bring. That is just one example. Study synchronization, when it is needed and how it is implemented. This is not something that can be explained in one mail. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Multilevel ListStore
Shadi Azoum wrote: > Any help would be greatly appreciated. Use gtk.TreeStore instead. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] extending gtk.ListStore
Felipe Reyes wrote: > [...] The other way that I found (the one that I want to implent) is > proposed by Davyd Madeley[0], but it doesn't work, I attached a small > test case. It fails because you initialize gtk.ListStore as if with one column: super(PhotoListStore, self).__init__(Photo) You probably shoud super(PhotoListStore, self).__init__(Photo, str, int) instead. > how do you handle the ListStore to avoid data replication?, somebody has > some tip to do with pygtk the same that davyd does with gobject? That non-OOP approach of GTK+ tree models always bugged me as promoting bad coding style: duplicating data between your real back end and GTK+ GUI tree model with no means of automatic synchronization. I actually have some old code lying around, maybe I will try to clean it up and publish somewhere... In short, I think this is not easy. Maybe there are ready-made solutions out there, e.g. in Kiwi, dunno. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Contant height of GtkProgressBar
Mitko Haralanov wrote: > In my application (GUI designed using Glade2), I have a progress bar > that is used by multiple parts of the app. > > Some of the parts display text in the progress bar and others done. The > problem that I am having is that the height of the progress bar changes > when there is text displayed and when there isn't. This causes > re-drawing of the application and is really annoying. > > Is there a way that I can prevent this from happening, either by > changing the font used by the progress bar or by having the widget > height be calculated in a permanent way? Well, one idea is to connect to size-request signal on that progress bar and to ensure it requests at least some height X. For example, you can ensure that height request never goes down in an instance of your app. That way you will have at most one height change (I guess) --- if it is first without text, then with text and thus higher. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] gobject.type_register for class hierarchy?
Skip Montanaro wrote: > Suppose I have this sort of class relationship: > > class A(gobject.GObject): > def __init__(self): > gobject.GObject.__init__(self) > ... > > class B(A): > ... > > A is abstract. Do I need to call gobject.type_register for just A, just B > or both? Only for B and only if B has some do_*() methods. As far as I know, anyway. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] pygtk.require("2.0") changed sys.path[0]
Preben Randhol wrote: > Hi > > If I do: > > try: > import pygtk > pygtk.require("2.0") > except: > pass > > then sys.path[0] will point towards > /usr/lib/python2.4/site-packages/gtk-2.0 > in stead of the script. Is this expected behavior? Yes, I think. require() above changes sys.path so that correct GTK+ version (2.0 in your case) is loaded. > If so is there an alternative to sys.path[0] except from catching it > before doing pygtk.require. Do one need to do this at all by the way? There is no alternative I think. But most of the time you don't need to worry. If you do, however, better copy it to some meaningfully named variable like path_to_application = sys.path[0] before doing anything else. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Re: Re: Cannot subclass gtk.Widget
John Dennis wrote: > Could it be that 'do_' method naming is not subclassing but rather > auto-magic signal connecting via method naming convention? Either way, I > never did find any documentation on it. It could be, but is not the case. do_*() methods *do* override default class handlers. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Re: Cannot subclass gtk.Widget
Jeffrey Barish wrote: > I still don't understand what to do if my widget is composed of other > widgets (rather than Cairo drawing and text). Normally, you just use boxes or something else to align those widgets. Or subclass e.g. gtk.HBox. However, if you feel adventurous, you can play with this incomplete but working example: import gobject import gtk class CustomContainer (gtk.Container): def __init__(self, child): gtk.Container.__init__(self) self.__child = child self.__child.set_parent (self) self.set_flags (gtk.NO_WINDOW) def do_size_request (self, requisition): requisition.width, requisition.height = self.__child.size_request () def do_size_allocate (self, allocation): self.__child.size_allocate (allocation) def do_forall (self, include_internals, callback, user_data): callback (self.__child, user_data) gobject.type_register (CustomContainer) window = gtk.Window () window.add (CustomContainer (gtk.Label ('test'))) window.show_all () window.present () window.connect ('destroy', lambda window: gtk.main_quit ()) gtk.main () ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] HButtonBox and homogeneous
Yann Le Boulanger wrote: > Hi all, > > When I add 2 button in a HButtonBox, both have the same size, even if > text in first button is smaller than text in second one. > buttonbox.get_homogeneous() returns False. > > Same behaviour if I add buttons with buttonbox.add(button) or > buttonbox.pack_start(button, False) > > Is it a known bug ? in GTK maybe ? It is not a bug. If you don't want the box to mess with button sizes, use gtk.HBox instead. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Submenu not getting focus
Ian Larsen wrote: > I'm not sure if I explained this clearly. > > The problem is not that the submenu doesn't appear -- it appears in > all cases. The problem is when you click on a submenu item, the > activate signal is not emitted. Don't know, here "hello" is printed when I click on "Two" or "Three" item and never when I click on "One" item. It is not required to click on "One" before "Two" to get a hello. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Submenu not getting focus
Ian Larsen wrote: > I believe I've encountered a bug in pygtk. When creating a context > menu with a submenu, the submenu doesn't get focus until the menu item > it's attached to is clicked (even though the submenu appears when the > mouse is over the menu item.) Your code shows submenu after a short delay, just like every other menu here. PyGTK is 2.8.6. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] do_forall() and inheritance
Hi, I derive a custom container from gtk.VBox. In it, I add a private widget, so I need to override do_forall() to return it in case `include_internals' is True. How do I call the original method? Calling gtk.VBox.do_forall() doesn't work: AttributeError: type object 'gtk.VBox' has no attribute 'do_forall' and chain() works only for signal handlers. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Activate a window
Marcus Habermehl (BMH1980) wrote: > Peter Morgan schrieb: > > Is there a way to disable just the maximize "button" on a windows bar, > > leaving only the minimize/iconify and close ? > > > > Please searching but cannot find.. > > Do you searching for set_resizable(False)? I also have this in a custom wrapper over gtk.Window: def make_only_horizontally_resizable (self): self.set_geometry_hints (self, max_width = sys.maxint, max_height = -1) It keeps window resizable, but only horizontally. Good for e.g. dialogs with entries only. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Selecting a treeView row
Brian wrote: > On Fri, 2006-15-12 at 14:52 +, Peter Morgan wrote: > > Am going round the houses with this problem (and a pygtk newbie) > > > > I've got the function below load_data() and wish to keep the current col > > sort (which works) and the selected row. The number of rows does not change > > > > When I enter the load_data function the iter is there from the first > > line. However the last line fails with > > GtkWarning: gtk_list_store_get_path: assertion `iter->stamp == > > GTK_LIST_STORE (tree_model)->stamp' failed > > > > [...] > > If I'm not mistaken. The iter becomes dead when the model is changed by > an append, etc.. I don't have time to check my facts right now. But It > might shed light on it for you. Right. This is not necessarily true, BTW, but is true for all standard tree models, if I remember correctly. Try looking for `path' concept in TreeModel class. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] How do I access CellRenderer for a gtk.ComboBoxEntry?
John Green wrote: > According to the pygtk reference documentation for gtk.ComboBoxEntry: > > "A new combo box entry is created and packed with a gtk.CellRendererText but > no attribute mappings are set on the cell renderer." > > Some of the entries in the list are quite long and so I'd like to set > 'ellipsize' property on the cell renderer. The trouble is I can't figure out > >from the docs how I access the cell renderer for this widget. Can anyone > help? Probably the only possible way is to call clear() to remove the standard renderer and add a custom one. `text-column' property will not work anymore, of course. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] Displaying mathematical equations
Martin Remie wrote: > Hello, > > does someone know a way to display a math equation in a Glade/PyGTK GUI > on a label(well, or something looking like a label)? > > Preferably by using LaTeX scripts I already have, e.g. for the equation > below. A quick search turned this: http://helm.cs.unibo.it/mml-widget/ However, this is for MathML and in C++. You could try creating a Python wrapper library and contribute it for the project, but it is certainly not a ready-to-use solution. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] update notification signals
Mikael Lindqvist wrote: > Hello, > > Is there a way of distinguishing if the value of a control is changed > by the user or by code in some part of my program? > > To clarify, I'm setting the value of a spinbutton with code, i.e. > spinbutton.set_value(...) . This causes the value_changed signal to be > sent to my program. The behavior is the same as when a user modifies > the value. In the callback I need to be able to distinguishing what > caused the signal to be fired. Is this possible? Or, better yet, is it > possible somehow to not have the signal fired when you set the value > programatically? I'm not sure I undestand you: Python 2.3.5 (#2, Oct 16 2006, 19:19:48) [GCC 3.3.5 (Debian 1:3.3.5-13)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> import gtk >>> adjustment = gtk.Adjustment () >>> handler = lambda adjustment: sys.stdout.write ("%s %i\n" % (adjustment, >>> adjustment.value)) >>> adjustment.connect ("value-changed", handler) 1 >>> adjustment.upper = 10 >>> adjustment.value = 5 5 SpinButton signals look the same. If you want to connect a method of specific object, use spin_button.connect ("value-changed", the_object.handle_value_changed) Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] is it possible to use custom class wrappers?
Hi, Is it possible to use custom wrappers for GTK+-created objects? E.g. a combo box entry creates an entry (from C code, not from Python code.) Can I have a custom Python class (derived from gtk.Entry of course) instantiated as a wrapper for it? Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] is GObject initialized?
Johan Dahlin wrote: > > > Is there a non-hackish way to find if GObject is initialized or not? > > It seems non-initialized objects have zero hash, while initialized > > have non-zero, but it is probably a hack to depend on it... > > > Using the hash is fine. > It's currently implemented like this: > > static long > pygobject_hash(PyGObject *self) > { > return (long)self->obj; > } > > self->obj is NULL if the object isn't initialized and will return 0. > If it's initialized, self->obj will return the memory address of the > GObject pointer. > > This code is unlikely to go away and you can safely depend on it. Thanks. Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] do_response() missing?
Hi, I can't find do_response() method in PyGTK (version 2.6.1.) Is it really missing or is there some other approach? Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] is GObject initialized?
Hi, Is there a non-hackish way to find if GObject is initialized or not? It seems non-initialized objects have zero hash, while initialized have non-zero, but it is probably a hack to depend on it... Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] g_markup_escape_text ()
Gian Mario Tagliaretti wrote: > 2006/12/1, Paul Pogonyshev <[EMAIL PROTECTED]>: > > > It is probably added in latest versions. Not present in PyGTK 2.5. > > IIRC it was added in unstabòe 2.7 (stable 2.8) > > > Is there something to use for the old versions? Or do I have to write > > my own workaround for now? > > I'm afraid you will have to write a sort of workaroud if you cannot > ugrade to at least pygtk 2.8. OK, thanks for help. This function should not be hard to write anyway, it is not like a missing wrapper for an entire GTK+ class :) Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
Re: [pygtk] g_markup_escape_text ()
Gian Mario Tagliaretti wrote: > 2006/12/1, Paul Pogonyshev <[EMAIL PROTECTED]>: > > > What do I use in place of g_markup_escape_text()? I can't find the > > wrapper (is it missing?) > > >>> import gobject > >>> gobject.markup_escape_text > It is probably added in latest versions. Not present in PyGTK 2.5. Is there something to use for the old versions? Or do I have to write my own workaround for now? Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
[pygtk] g_markup_escape_text ()
Hi, What do I use in place of g_markup_escape_text()? I can't find the wrapper (is it missing?) Paul ___ pygtk mailing list pygtk@daa.com.au http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/