[pygtk] Buttons over a drawingarea in a fixed

2009-10-06 Thread Kim Adil
Hello,

I am trying to put some buttons over a drawing area in a fixed 
container, but the drawingarea always ends up looking like it is on top 
of the buttons despite my draw sequence. Is it because the expose or 
configure events are drawing over the buttons. If so how do I trigger 
the buttons to redraw? See sample below(modified from the tutorial):

#!/usr/bin/env python

# example fixed.py

import gtk

class FixedExample:
# This callback method moves the button to a new position
# in the Fixed container.
def move_button(self, widget):
self.x = (self.x+30)%300
self.y = (self.y+50)%300
self.fixed.move(widget, self.x, self.y)

def __init__(self):
self.x = 50
self.y = 50

# Create a new window
window = gtk.Window(gtk.WINDOW_TOPLEVEL)
window.set_title("Fixed Container")

# Here we connect the "destroy" event to a signal handler
window.connect("destroy", gtk.mainquit)
 
# Sets the border width of the window.
window.set_border_width(10)

# Create a Fixed Container
self.fixed = gtk.Fixed()

window.add(self.fixed)
self.fixed.show()
  self.f1=gtk.DrawingArea()
self.f1.connect("expose-event", self.expose)
self.f1.connect("configure-event", self.configure)
self.f1.set_size_request(200,200)
self.fixed.put(self.f1,0,0)
   
for i in range(1, 4):
# Creates a new button with the label "Press me"
button = gtk.Button("Press me")
 
# When the button receives the "clicked" signal, it will 
call the
# method move_button().
button.connect("clicked", self.move_button)
 
# This packs the button into the fixed containers window.
self.fixed.put(button, i*50, i*50)
 
# The final step is to display this newly created widget.
button.show()

# Display the window
window.show_all()
x, y, width, height = self.f1.get_allocation()
self.pixmap = gtk.gdk.Pixmap(self.f1.window, width, 3000)
def draw_objects(self):
   
x, y, width, height = self.f1.get_allocation()
self.pixmap = gtk.gdk.Pixmap(self.f1.window, width, height)
self.pixmap.draw_rectangle(self.f1.get_style().white_gc,True, 
0,0, width, 3000)
def expose(self,a,b):
self.draw_objects()
x, y, width, height = self.f1.get_allocation()

self.f1.window.draw_drawable(self.f1.get_style().fg_gc[gtk.STATE_NORMAL],self.pixmap,
 
0, 0, 0, 0, width, 3000)

return False
   
def configure(self,a,b):
   
x, y, width, height = self.f1.get_allocation()
self.pixmap = gtk.gdk.Pixmap(self.f1.window, width, 3000)
x, y, width, height = self.f1.get_allocation()

self.f1.window.draw_drawable(self.f1.get_style().fg_gc[gtk.STATE_NORMAL],self.pixmap,0,
 
0, 0, 0, width, 3000)

return False

def main():
# Enter the event loop
gtk.main()
return 0

if __name__ == "__main__":
FixedExample()
main()
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


[pygtk] checkboxes untoggled

2009-10-06 Thread anusha k
hello all,

i created a combobox with checkboxes.but i am not able to toggle
them.Actually i want to create multiselect combobox but landed up in this
issue.Is it possible to implement anyone of this.Thanks in advance

import gtk,gobject
class combo:
def __init__(self):
self.window = gtk.Window()

self.tax_list =
gtk.ListStore(gobject.TYPE_BOOLEAN,gobject.TYPE_STRING)
self.combobox_tax = gtk.ComboBox(self.tax_list)

renderer = gtk.CellRendererToggle()
renderer.set_property('activatable',True)
renderer.connect('toggled', self.toggled_callback, self.tax_list)
self.combobox_tax.pack_start(renderer, True)
self.combobox_tax.add_attribute(renderer, 'active', 0)

renderer = gtk.CellRendererText()
self.combobox_tax.pack_start(renderer, True)
self.combobox_tax.add_attribute(renderer, 'text', 1)

self.tax_list.append([False,'anusha'])
self.tax_list.append([False,'sha'])
self.tax_list.append([False,'anu'])

self.window.add(self.combobox_tax)
self.window.show_all()
def toggled_callback(cell, path, model=None):
iter = self.tax_list.get_iter(path)
self.tax_list.set_value(iter, 0, not cell.get_active())
if __name__ == '__main__':
c=combo()
gtk.main()
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

[pygtk] Bug 596612 - gtk_widget_get_snapshot bindings are missing caller-owns-return

2009-10-06 Thread Tomeu Vizoso
Hi,

anybody has any feedback on this patch? We are leaking 2MB per window
switch in Sugar because of this, so would be very convenient to get it
pushed to git so we can ask distros to ship it as a patch.

https://bugzilla.gnome.org/show_bug.cgi?id=596612

Thanks,

Tomeu

-- 
«Sugar Labs is anyone who participates in improving and using Sugar.
What Sugar Labs does is determined by the participants.» - David
Farning
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/


[pygtk] More on cut+paste accelerators

2009-10-06 Thread Geoff Bache

Hi all,

I'm also having some issues with the default cut and paste which is that 
my application can also cut and paste files. These file actions have 
naturally been assigned the accelerators Ctrl+X, Ctrl+V etc but this 
naturally means that currently these accelerators don't work for 
selected text in the TextView widgets. What I'd like is for Ctrl+C to 
copy a file if a file is selected and copy some text (as the default) if 
some text is selected.

What's the easiest or "normal" way of fixing something like this? As far 
as I can tell from the docs, accelerators apply to the entire window and 
there isn't an obvious way to divide it up so that they do different 
things if different widgets are in focus. Or is there some trick 
involving accelerator paths, accelerator groups and action groups that I 
haven't understood?

Or do I need to explicitly connect up every gtk.Entry, gtk.TextView etc 
in the application so that when the user selects something there all the 
file actions get disabled?

Regards,
Geoff

___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/