Re: [pygtk] Cell renderer repository?
On Wed, 1 Oct 2008 17:22:58 +0200 Alessandro Dentella <[EMAIL PROTECTED]> wrote: > I'm wandering if there exist already such a renderer or a repository of > cell renderer ready to use. A second one I need is > Date/DateTimeRenderer. I guess I'm not the first one that need such a > beast... At one point, a long time ago, I did this by setting a custom data function for a cell with (C func) gtk_tree_view_column_set_cell_data_func. The custom data function would get the value from the tree model, format it as needed, and then set the "text" attribute of that cell's renderer. The renderer itself was a text renderer. Looking that the pygtk reference manual, this can be accomplished with gtk.TreeView.insert_column_with_data_func() HTH -- Mitko Haralanov == Computer programmers do it byte by byte. ___ 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] gtk.IconView random segfault
On Wed, 09 Jul 2008 19:41:31 -0400 Felipe Reyes <[EMAIL PROTECTED]> wrote: > Yes, with the locks everything works fine, but the locks added some > overhead (about 10 secons when loading 2500 pictures), I suppose that > this is normal, right? I guess it is possible for the locking to add overhead since the entire gtk uses one master lock. Also, are you sure that it's the locks? Have you been able to load all 2500 images before without segfaults so you can measure the time? The alternative would be to not use a separate thread for loading the model. -- Mitko Haralanov == Everybody needs a little love sometime; stop hacking and fall in love! ___ 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] gtk.IconView random segfault
On Tue, 08 Jul 2008 19:57:23 -0400 Felipe Reyes <[EMAIL PROTECTED]> wrote: > I added a test case that shows (at least on my system) my trouble. > > somebody can give me a clue? The issue is locking. Changing the code to this seems to have solved the problem: class FillListStore(threading.Thread): def run(self): gtk.gdk.threads_enter () model.clear() for i in range(600): a = random.randint(0, len(img)-1) model.append ([gtk.gdk.pixbuf_new_from_file_at_size(rootdir + img[a], 64, 64), str (i)]) gtk.gdk.threads_leave () thread = FillListStore() thread.start() win.show_all() gtk.gdk.threads_enter () gtk.main() gtk.gdk.threads_leave () -- Mitko Haralanov == 67. Well, _my_ files were backed up. --Top 100 things you don't want the sysadmin to say ___ 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] Entry dir autocompletion
On Tue, 01 Jul 2008 14:59:57 +0200 Timo <[EMAIL PROTECTED]> wrote: > Anyone with a working example? Here you go: import pygtk import gtk import gobject import os import dircache def entry_changed (editable, *user_data): comp = user_data[0] text = editable.get_text () matches = [] if text: path = os.path.dirname (text) start = os.path.basename (text) files = dircache.listdir (path) for file in files: if file.startswith (start): if path == "/": matches.append (path+file) else: matches.append (path+os.sep+file) model = comp.get_model () model.clear () for match in matches: model.append ([match]) win = gtk.Window () entry = gtk.Entry () completion = gtk.EntryCompletion () entry.set_completion (completion) liststore = gtk.ListStore (gobject.TYPE_STRING) completion.set_model (liststore) completion.set_text_column (0) win.add (entry) entry.connect ("changed", entry_changed, completion) win.connect ("delete-event", gtk.main_quit) win.show_all () gtk.main () -- Mitko Haralanov == printk("Penguin %d is stuck in the bottle.\n", i); 2.0.38 /usr/src/linux/arch/sparc/kernel/smp.c ___ 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] Entry dir autocompletion
On Sat, 28 Jun 2008 11:36:07 +0200 Timo <[EMAIL PROTECTED]> wrote: > Hello, I want autocompletion in my gtk.entry. I found a lot of info, but > all for autocompletion of an existing list and stuff. > What I want is that it completes the path that I'm typing. So if I type > "/ho" it should complete with "/home/", and so on. > How can this be done? What I would do is connect a callback to the "changed" signal of the gtk.Entry. This way the callback gets called on every character change. In the callback construct the completion list based on the current content of the Entry: def entry_cb (editable, *user_data): text = editable.get_text () path = os.path.dirname (text) start = os.path.basename (text) files = dircache.listdir (path) matches = [] for file in files: if file.startswith (start): matches.append (path+os.sep+file) -- Mitko Haralanov == This is an unauthorized cybernetic announcement. ___ 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] Scrolling gtk.Viewport to a specific location
I have a gtk.ScrolledWindow, which has a gtk.VBox added with a gtk.Viewport. What I would like to do is be able to scroll the gtk.ScrolledWindow to a specific location (one of the gtk.VBox children). I know how to do the actual scrolling (using the h/vadjustments) but how do I determine how much to scroll it by so the correct child is in view? Thanks for the help? -- Mitko Haralanov == Professor: No fair! You changed the outcome by measuring it. ___ 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] Getting configure_event on widgets in notebook pages
Hi, My application uses a custom graphing widget (rtgraph) do display multiple graphs. The graphs are packed in a GtkTable, which in turn is added to a notebook page. The notebook has several pages each with a separate graph. The problem that I am facing is that the graphing widget uses a backing store pixmap which gets created when the widget receives a "configure_event". However, the only widget that receives a configure_event is the one on the currently displayed notebook page. If I start the graph updates, my application crashes due to the missing backing store pixmap. If on the other hand, I click on every one of the notebook pages, each of the graphing widgets received their configure_event and all is good. Is there a way that I can cause the configure_event to be sent without requiring the user to click on each of the notebook pages? Thanx -- Mitko Haralanov == 65. What do you mean /home was on that disk? I umounted it! --Top 100 things you don't want the sysadmin to say ___ 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] getting actual size of widget
On Thu, 22 May 2008 14:49:12 -0700 Mitko Haralanov <[EMAIL PROTECTED]> wrote: > What I have is a main application window which contains a > notebook. Each of the notebook pages contains a table. When the main > window is resized, the notebook (and the tables on the pages) get > resized. I would like to be able to find the actual width and height of > the table in the GtkNotebook page. > > I have tried using GtkWidget.get_allocation() but that returns the same > number regardless of how much I resize the main window. OK, I did more digging around and it turned out that I wasn't really understanding the situation correctly. Here is what is actually going on: When the main window is constructed, I used gdk.Window.move_resize() to change the size and position of the main window to a user-specified values. When this happens, the size of the GtkTable inside the GtkNotebook changes from their default size. However, the new size does not become "active" until gtk.main() is called, which results in my inability to find a way to get the new size before I have entered the main loop. Unfortunately, as part of the main window construction, I insert a bunch of widgets into the table, which is why I need the its size. Can anyone give me some advice about how to go about getting the table size? -- Mitko Haralanov == Real computer scientists don't comment their code. The identifiers are so long they can't afford the disk space. ___ 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] getting actual size of widget
I am trying to find a way to get the actual size (in pixels) of a widget. What I have is a main application window which contains a notebook. Each of the notebook pages contains a table. When the main window is resized, the notebook (and the tables on the pages) get resized. I would like to be able to find the actual width and height of the table in the GtkNotebook page. I have tried using GtkWidget.get_allocation() but that returns the same number regardless of how much I resize the main window. Any advice is appreciated. Thank you -- Mitko Haralanov == 56. Sorry, we deleted that package last week... --Top 100 things you don't want the sysadmin to say ___ 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] Checking version of PyGTK from withing Python
On Mon, 19 May 2008 13:20:23 -0700 David Ripton <[EMAIL PROTECTED]> wrote: > $ python > [...] > ['check_version', 'gtk_version', 'pygtk_version', 'ver'] > [...] > (2, 10, 4) > [...] > (2, 10, 1) > [...] > (2, 12, 1) I am sorry but your reply is not very useful. Are those methods of a module? Defined constants? I can't find them defined anywhere -- Mitko Haralanov == Niblonian: They travel from world to world making everyone stupid in order to wipe out all thought in the universe. Leela: Wipe out all thought? My God, they're like flying televisions. ___ 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] Checking version of PyGTK from withing Python
Is there a way to check the version of PyGTK from within my Python program? I know of pygtk.require() but that returns False for anything higher then 2.0, even though I have pygtk-2.12 installed. -- Mitko Haralanov == THEGODDESSOFTHENETHASTWISTINGFINGERSANDHERVOICEISLIKEAJAVELININTHENIGHTDUDE ___ 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.timeout_add timeout recalculation
On Thu, 15 May 2008 18:48:22 -0500 [EMAIL PROTECTED] wrote: > I believe it works like this: > > set wakeup for X milliseconds from now > call your callback > if it returned true: > set wakeup for X milliseconds from now > call your callback > if it returned true: > set wakeup for X milliseconds from now > call your callback > if it returned true: > set wakeup for X milliseconds from now > ... > > If X is 2500ms and your callback takes 2ms to execute, the interval between > successive calls will actually be 2502ms. Unfortunately, it is how it work. In fact, that how I would like it to work. Here is what my testing shows: t0: set wakeup for X milliseconds from now t0+X: set wakeup for X milliseconds from now (t0+X+X) call callback if it returned true: noop else: delete the timer Here is an example: #!/usr/bin/python import gtk import gobject import time def callback (timeout): print "callback called at: %s"%time.time () time.sleep (timeout) print "callback returning at: %s"%time.time () return True if __name__ == "__main__": gobject.timeout_add (20*1000, callback, 10) gtk.main () If you run this, you get: callback called at: 1210897497.69 callback returning at: 1210897507.69 callback called at: 1210897517.69 callback returning at: 1210897527.69 callback called at: 1210897537.69 callback returning at: 1210897547.69 callback called at: 1210897557.69 Note that the time difference between the "callback returning at" and "callback called at" is not 20 seconds but 10 seconds (20 second timeout - 10 second callback runtime). -- Mitko Haralanov == A programming language is low level when its programs require attention to the irrelevant. ___ 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] gobject.timeout_add timeout recalculation
In my application, I am using gobject.timeout_add to trigger periodic updates of the status of a number of machines. However, I am having a bit of trouble understanding exactly how the timeout is calculated. According to the documentation: After each call to the timeout function, the time of the next timeout is recalculated based on the current time and the given interval (it does not try to 'catch up' time lost in delays). The "After each call to the timeout function,..." leads me to think that the timer is reset when the timeout function returns. However, the phrase "(it does not try to 'catch up' time lost in delays)." makes me think that the timer is reset as soon as the timeout function thread is started. (This also seems to be confirmed by tracing my code) What I would like to happen is that the timeout gets recalculated when my timeout function is done/returns. I guess, I could add a new timeout from within my timeout function and have it [the timeout function] return False (so the old timeout is destroyed) but I am thinking that there has to be a better way to do this. I appreciate any advice on the matter. -- Mitko Haralanov == A Fortran compiler is the hobgoblin of little minis. ___ 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] Contant height of GtkProgressBar
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? Thanx -- Mitko Haralanov == A nasty looking dwarf throws a knife at you. ___ 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] (FileChooserDialog) Save-Overwrite
On Wed, 7 May 2008 15:42:36 -0700 (PDT) Andrea Caminiti <[EMAIL PROTECTED]> wrote: > even if i got the job done, after making some mods, i need to ask: what does > the uri (on the example) do or stands for? In this case, it's the filename. In your case, it shouldn't matter whether you are using get_uri() or get_filename(). > and another question: the overwrite windows appears behind the > filechooserdialog. > is there any way to set that window on top/in front of all windows?? Hmm... don't really know why that's happening. -- Mitko Haralanov == 9. SMIT makes it all so much easier.. --Top 100 things you don't want the sysadmin to say ___ 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] (FileChooserDialog) Save-Overwrite
On Wed, 7 May 2008 12:09:34 -0700 (PDT) Andrea Caminiti <[EMAIL PROTECTED]> wrote: > when i try it, an select an existing file, no overwrite dialog was displayed. > when i check > the file the previous content was changed for the new one. any idea on what's > wrong? > any suggestions? Try connection the dialog's "confirm-overwrite" signal before you run the dialog. If you look at the pygtk documentation for gtk.FileChooser, you'll see an example of how to use the "confirm-overwrite" signal. -- Mitko Haralanov == "Who would have though hell would really exist? And that it would be in New Jersey?" -Leela "Actually..." - Fry ___ 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] python-gtkhtml2 docs
On Thu, 24 Apr 2008 13:09:40 -0700 Mitko Haralanov <[EMAIL PROTECTED]> wrote: > Hi, does anyone know of any useful documentation, API, turorials, > examples of python-gtkhtml2. > > I can't seem to find anything useful. Alright, I've been able to find enough information to get a very simple usage of the widget. One thing that still puzzles me is the fact that according to everything I read GtkHTML2 supports CSS and image loading. This either doesn't hold true for the Python module or I just can't get it to work. It seems that the request to load the css is being made and I can see the data being written to the GtkHTML2 stream handler but nothing is being done with the data because the stylesheet is not applied. I would appreciate any help from anyone that has played with GtkHTML and it's Python bindings. Thanks -- Mitko Haralanov == "No bugs were harmed in the preparation of this patch. It's just me fartarsing around." - Andrew Morton ___ 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] python-gtkhtml2 docs
Hi, does anyone know of any useful documentation, API, turorials, examples of python-gtkhtml2. I can't seem to find anything useful. Thanx -- Mitko Haralanov == panic("sun_82072_fd_inb: How did I get here?"); 2.2.16 /usr/src/linux/include/asm-sparc/floppy.h ___ 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] Getting widget visibility
On Wed, 23 Apr 2008 13:23:22 -0400 John Ehresman <[EMAIL PROTECTED]> wrote: > Try >syslog_frame.props.visible That worked. Thank you. -- Mitko Haralanov == 43. If I knew it wasn't going to work, I would have tested it sooner. --Top 100 things you don't want the sysadmin to say ___ 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] Getting widget visibility
On Wed, 23 Apr 2008 14:10:10 -0300 "Facundo Batista" <[EMAIL PROTECTED]> wrote: > If you could provide an example that makes this to you, for us to try > it, we could help you better. Here you go: #!/usr/bin/python import gtk import pygtk def toggle_func (widget, *user_data): frame = user_data[0] if frame.visible: frame.hide () else: frame.show () window = gtk.Window () vbox = gtk.VBox () button = gtk.Button ("Toggle") frame = gtk.Frame ("Test Frame") label = gtk.Label ("Some Text") frame.add (label) vbox.pack_start (frame) vbox.pack_start (button) window.add (vbox) button.connect ("clicked", toggle_func, frame) window.connect ("delete-event", gtk.main_quit) window.show_all () gtk.main () # ./test.py Traceback (most recent call last): File "./test.py", line 8, in toggle_func if frame.visible: AttributeError: 'gtk.Frame' object has no attribute 'visible' -- Mitko Haralanov == I WILL NOT USE ABBREV. I WILL NOT USE ABBREV. I WILL NOT USE ABBREV. I WILL NOT USE ABBREV. Bart Simpson on chalkboard in episode 2F33 ___ 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] Getting widget visibility
On Tue, 22 Apr 2008 21:31:35 -0700 John Finlay <[EMAIL PROTECTED]> wrote: > It does inherit the visible property - what makes you think it doesn't? The exception that my app threw when I tried to use it: Traceback (most recent call last): File "/monitor/track.py", line 131, in start_updates if syslog_frame.visible: AttributeError: 'gtk.Frame' object has no attribute 'visible' -- Mitko Haralanov == Usage: fortune -P [] -a [xsz] [Q: [file]] [rKe9] -v6[+] dataspec ... inputdir ___ 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] Getting widget visibility
What is the best way to get whether a widget is visible or not? According to the documentation, gtk.Widget has the 'visible' property which is Read-Write. However, gtk.Frame for example does not seem to inherit that property of gtk.Widget. Thanks for the help! -- Mitko Haralanov == I WILL NOT SHOW OFF I WILL NOT SHOW OFF I WILL NOT SHOW OFF I WILL NOT SHOW OFF Bart Simpson on chalkboard in episode 7F21 ___ 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] Passing user data to callbacks with libglade
On Thu, 10 Apr 2008 08:30:40 -0300 "Airton Arantes" <[EMAIL PROTECTED]> wrote: > Second the docs, there isn't as to pass an user data using > signal_autoconnect method, see below: Thank you for the reply (I somehow missed your previous one requesting code). Here is a simple example that can illustrate what I am talking about: with the PyGTK/GObject API once can do window = gtk.Window (...) button = gtk.Button ("test") window.connect ("delete-event", handler, button) the result of which is that the button widget will be passed to the 'handler' callback. You see to be confirming my understanding that one can not pass user data to the signal callback using signal_autoconnect. I was also interested if there is any other way that it can be done but by looking at the contect of the gtk.glade module it doesn't seem to be the case. If it is truly not possible to pass user data to signal callbacks with Python's bindings for libglade, it seems to me that this is a pretty big shortcoming of the module. I am not sure whether this can be done with the C API but as far as the Python's API is concerned it seem to limit it's usability somewhat. I guess I could use GObject.connect instead of signal_autoconnect for the callbacks that need data passed to them. -- Mitko Haralanov == The use of anthropomorphic terminology when dealing with computing systems is a symptom of professional immaturity. -- Edsger Dijkstra ___ 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] Passing user date to callbacks with libglade
On Thu, 3 Apr 2008 17:57:34 -0700 Mitko Haralanov <[EMAIL PROTECTED]> wrote: > I can't seem to figure out how to pass user data to callbacks connected > with libglade's signal_autoconnect. The documentation does not mention > anything about it and all my searching has not come up with anything. > > I'd appreciate it if someone could shed some light on the subject? There's gotta be a way to pass user data to callback with libglade! Anybody know how? -- Mitko Haralanov == "The 'C' language can order structure members anyway it wants." - Richard B. Johnson ___ 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] Doc/tutorial on creating custom widgets
On Fri, 4 Apr 2008 13:02:47 -0700 Mitko Haralanov <[EMAIL PROTECTED]> wrote: > If I understand the mechanics correctly, what I will have to do is make > a custom "clicked" handler that gets the coordinates of the mouse when > a click occurs, if they are within the frame of the checkbutton, act on > the checkbutton, otherwise call the "clicked" callback. For those that might be interested, here is what I came up with that works as I want it to (well, almost). I do have to manually tweak the pointer coordinates since I can't correctly compute the coordinates of the checkbox (self.chk.get_parent_window() returns None). Also, I wish I could have the CheckButton be only the check box instead of the check box and the space allocated to the label, but I guess it's better then nothing. #!/usr/bin/python import pygtk pygtk.require("2.0") import gtk import gobject class Size: def __init__ (self, x=0, y=0, w=0, h=0): self.x = x self.y = y self.width = w self.height = h self.x_end = self.x + self.width self.y_end = self.y + self.height def __repr__ (self): return ""%(self.x, self.y, \ self.width, self.height) def __str__ (self): return self.__repr__ () class Button (gtk.Button): def __init__ (self, label=None): gtk.Button.__init__ (self) self.label = label self.callback = None self.user_data = None vbox = gtk.VBox () self.chk = gtk.CheckButton ("Select") self.label = gtk.Label (self.label) vbox.pack_start (self.label) vbox.pack_start (self.chk, False) self.add (vbox) def widget_coords (self, widget): allocation = widget.get_allocation () window = widget.get_parent_window () if not window: # When 'widget' is self.chk, 'window' is # None, so let's use the button window = self.get_parent_window () x, y = window.get_root_origin () w, h = window.get_size () extents = window.get_frame_extents () coord = Size () coord.x = x + (extents.width-w)/2 + allocation.x coord.y = y + (extents.height-h)-(extents.width-w)/2 + allocation.y coord.width = allocation.width coord.height = allocation.height coord.x_end = coord.x + coord.width coord.y_end = coord.y + coord.height return coord def do_realize (self): gtk.Button.do_realize (self) # try to get the coordinates of the checkbutton self.chk_coord = self.widget_coords (self.chk) self.add_events (gtk.gdk.BUTTON_PRESS_MASK | \ gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK) self.connect ("motion-notify-event", self.motion_notify_event) def connect (self, signal, callback, *user_data): if signal == "clicked": self.callback = callback self.user_data = user_data gtk.Button.connect (self, signal, self.clicked_handler) else: gtk.Button.connect (self, signal, callback, *user_data) return def clicked_handler (self, button, *user_data): if self.pointer_x >= self.chk_coord.x and \ self.pointer_x <= self.chk_coord.x_end and \ self.pointer_y >= self.chk_coord.y and \ self.pointer_y <= self.chk_coord.y_end: self.chk.set_active (not self.chk.get_active ()) return False else: return self.callback (button, *self.user_data) return def motion_notify_event(self, widget, event): # if this is a hint, then let's get all the necessary # information, if not it's all we need. if event.is_hint: self.pointer_x, self.pointer_y, state = event.window.get_pointer() else: self.pointer_x = event.x self.pointer_y = event.y state = event.state # Since I can't compute the coordinates of the checkbutton correctly # I have to tweak the pointer coordinates self.pointer_x += 5 self.pointer_y += 5 self.chk_coords = self.widget_coords (self.chk) return False def c (widget, *user_data): print "c:", widget, user_data if __name__ == "__main__": gobject.type_register (Button) window = gtk.Window(gtk.WINDOW_TOPLEVEL) window.set_border_width(10) bcb = Button ("Checktext") bcb.connect ("clicked", c) window.add(bcb) window.connect("delete-event", gtk.main_quit) window.show_all() gtk.main() -- Mitko Haralanov == Computer programmers do it byte by byte. ___ 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] Doc/tutorial on creating custom widgets
On Fri, 4 Apr 2008 11:40:23 +0100 Stephen Fairchild <[EMAIL PROTECTED]> wrote: > Checkbuttons or any other widget can be embedded into a button face as this > small piece of code demonstrates. Passing on the button clicks is a bit more > involved but in this simple example is not necessary. Thank you very much for the example. Of course, what I would like to have is a button which has an embedded checkbutton where both "widgets" (the button and the checkbutton) behave as normal. What I mean is that the button click and the checkbutton can be interacted with separately. So far, I can have a checkbutton embedded onto a button surface where the button click does one of two things: 1. makes the checkbutton active/inactive (your example) 2. act as a normal button click and does not allow control of the checkbutton. If I understand the mechanics correctly, what I will have to do is make a custom "clicked" handler that gets the coordinates of the mouse when a click occurs, if they are within the frame of the checkbutton, act on the checkbutton, otherwise call the "clicked" callback. I guess, there is a lot more that I need to learn... -- Mitko Haralanov == GARLIC GUM IS NOT FUNNY GARLIC GUM IS NOT FUNNY GARLIC GUM IS NOT FUNNY GARLIC GUM IS NOT FUNNY Bart Simpson on chalkboard in episode 7G13 ___ 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] Passing user date to callbacks with libglade
I can't seem to figure out how to pass user data to callbacks connected with libglade's signal_autoconnect. The documentation does not mention anything about it and all my searching has not come up with anything. I'd appreciate it if someone could shed some light on the subject? -- Mitko Haralanov == Remember: the biggest mistake to do is to overdesign. The road to hell is paved with good intentions. - Linus on linux-kernel ___ 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] Doc/tutorial on creating custom widgets
I am trying to create a custom widget that is basically a GtkButton but along with the label it also has a checkbutton embedded into the button face. To that end, I am trying to find some tutorials, docs, examples on how to create custom widget. The only thing that I have been able to find is this one page: http://www.pygtk.org/articles/writing-a-custom-widget-using-pygtk/writing-a-custom-widget-using-pygtk.htm but it seems that the information on it is not enough to get me going. Can anyone recommend any docs that could help me? Thanks for the help! -- Mitko Haralanov == kernel/smp.c ___ 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] Increasing memory usage of GtkTreeView/GtkTreeModel
On Thu, 20 Mar 2008 14:26:52 -0400 John Ehresman <[EMAIL PROTECTED]> wrote: > Do you have a minimal test case? I didn't but I wrote one and it doesn't seem to happen, which points to a memory leak in my code, rather then GtkTreeView. I have been trying to narrow down where it happens but I am so, so stuck. Well, back to the drawing board. -- Mitko Haralanov == Leela: You buy one pound of underwear and you're on their list forever. ___ 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] Increasing memory usage of GtkTreeView/GtkTreeModel
On Tue, 18 Mar 2008 13:31:19 -0700 Mitko Haralanov <[EMAIL PROTECTED]> wrote: > I am pretty sure that there is something I am missing because such a > huge memory leak in GTK would have been caught. Any ideas? Hi, I am still trying to figure out why the memory usage of my app keeps climbing and I have not com up with anything. I would appreciate any ideas? Thanks -- Mitko Haralanov == Never trust an operating system. ___ 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] Increasing memory usage of GtkTreeView/GtkTreeModel
I have an application which has a GtkTreeView widget. Every so often (usually two minute intervals), the application does a refresh of the content of the TreeView. The refresh code, gets the TreeModel by calling the get_model() method, then does a model.clear(), and after that re-fills the model by calling model.append() for every row. What I am noticing is that the memory footprint of my application keeps raising with every refresh cycle. It starts at 72K and after an hour or so, it is at 230M. I am pretty sure that there is something I am missing because such a huge memory leak in GTK would have been caught. Any ideas? -- Mitko Haralanov == Leela: Bender, maybe you can interface with the Femputer and reprogram it to let them go. Bender: Maybe you can interface with my ass... by biting it. ___ 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] Dynamically adding glade widgets?
I used glade to design my GUI and in one of the dialogs I have a HBox with only one cell. In that cell, I have a tree of widgets which form the content of the cell. What I want to have is a button, which the user can click and the action would be that a new tree of widgets (identical to the original one) would be packed at the end of the HBox. Can this be done using some glade trick or do I have to build the tree of widgets in the Python "clicked" signal handler? -- Mitko Haralanov [EMAIL PROTECTED] Senior Software Engineer 650.934.8064 HSG InfiniBand Engineering http://www.qlogic.com == There are no games on this system. ___ 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] Apply button behavior with GtkDialog
In the application that I am working on, I have a GtkDialog with three action buttons: Apply, Cancel, and OK. All three buttons return a GTK_RESPONSE when clicked (I am using the GtkDialog's run method). When the user presses the OK or CANCEL buttons everything is fine, since on those button presses the dialog window gets closed. However, the APPLY button is a different story. On a click of the APPLY button, the dialog returns the GTK_RESPONSE_APPLY response ID (which allows me to perform the actions that are associated with that button), however after that none of the buttons do anything. This makes sense since the run() method returned but the question that I have is how do I make the GtkDialog responsive again? Calling the dialogs' run() method doesn't work and I don't want to destoy and re-create it. -- Mitko Haralanov [EMAIL PROTECTED] Senior Software Engineer 650.934.8064 HSG InfiniBand Engineering http://www.qlogic.com == 52. NO! Not _that_ button! --Top 100 things you don't want the sysadmin to say ___ 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/