Subject: pygtk2 and GC?
X-Mailer: VM 6.96 under Emacs 20.7.1
FCC: ~/persoonlijk/Mail/sent
Hi,
I installed pygtk2 this morning, and am now trying to sort-of port my
gtk dribbling to gtk2, but I'm having lots of problems with managing
GdkGC objects.
The examples in the distribution are not of much help, since they are
outdated. FWIW, i've tried to get scribble.py up and running, but
failed: at some point, I must come up with a GC object, and in pygtk
for gtk1, you could do
get_style().white_gc
but this no longer seems to work. How should I proceed?
--- scribble.py~ Thu Mar 14 14:56:02 2002
+++ scribble.py Thu Mar 14 16:10:32 2002
@@ -4,20 +4,28 @@
import sys
from gtk import *
+import gtk
+GDK =gtk.gdk
pixmap = None
def configure_event(widget, event):
global pixmap
win = widget.window
- pixmap = create_pixmap(win, win.width, win.height, -1)
- draw_rectangle(pixmap, widget.get_style().white_gc, TRUE,
- 0, 0, win.width, win.height)
+ (w,h) = win.get_size()
+ pixmap = create_pixmap(win, w,h , -1)
+
+ style = widget.get_style()
+
+ ## ??
+ style.white_gc.draw_rectangle(pixmap, TRUE,
+ 0, 0, w, h)
return TRUE
def expose_event(widget, event):
area = event.area
- gc = widget.get_style().fg_gc[STATE_NORMAL]
+ style = widget.get_style()
+
widget.draw_pixmap(gc, pixmap, area[0], area[1], area[0], area[1],
area[2], area[3])
return FALSE
@@ -39,21 +47,22 @@
else:
x = event.x; y = event.y
state = event.state
+
if state & GDK.BUTTON1_MASK and pixmap != None:
draw_brush(widget, x, y)
return TRUE
def main():
- win = GtkWindow()
+ win = gtk.Window()
win.set_name("Test Input")
win.connect("destroy", mainquit)
win.set_border_width(5)
- vbox = GtkVBox(spacing=3)
+ vbox = gtk.VBox(spacing=3)
win.add(vbox)
vbox.show()
- drawing_area = GtkDrawingArea()
+ drawing_area = gtk.DrawingArea()
drawing_area.size(200, 200)
vbox.pack_start(drawing_area)
drawing_area.show()
@@ -62,13 +71,15 @@
drawing_area.connect("configure_event", configure_event)
drawing_area.connect("motion_notify_event", motion_notify_event)
drawing_area.connect("button_press_event", button_press_event)
+
+
drawing_area.set_events(GDK.EXPOSURE_MASK |
GDK.LEAVE_NOTIFY_MASK |
GDK.BUTTON_PRESS_MASK |
GDK.POINTER_MOTION_MASK |
GDK.POINTER_MOTION_HINT_MASK)
- button = GtkButton("Quit")
+ button = gtk.Button("Quit")
vbox.pack_start(button, expand=FALSE, fill=FALSE)
button.connect("clicked", lambda widget, win=win: win.destroy())
button.show()
--
Han-Wen Nienhuys | [EMAIL PROTECTED] | http://www.cs.uu.nl/~hanwen/
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/