Hi, ("KONNICHIWA" in japanese)
I have an experimental code about drawing stuff (offscreen, font).
Osamu Tanimoto
---- from here -----------
from gtk import *
def destroy(*args):
window.hide()
mainquit()
def configure_event(widget, event):
if widget.get_data('pixmap') == None:
win = widget.get_window()
pixmap = create_pixmap(win, win.width, win.height, -1)
widget.set_data('pixmap',pixmap)
draw(widget)
def expose_event(widget, event):
if widget.get_data('pixmap') != None:
area = event.area
gc = widget.get_style().fg_gc[STATE_NORMAL]
widget.draw_pixmap(gc, widget.get_data('pixmap'),
area[0],area[1],area[0],area[1],area[2],area[3])
def draw(widget):
pixmap = widget.get_data('pixmap')
win = widget.get_window()
draw_rectangle(pixmap, widget.get_style().white_gc,
TRUE, 0, 0, win.width, win.height)
gc = widget.get_style().fg_gc[STATE_NORMAL]
red = win.colormap.alloc(65535,0,0)
green = win.colormap.alloc(0,65535,0)
blue = win.colormap.alloc(0,0,65535)
save_fg, save_lw, save_ls = gc.foreground, gc.line_width, gc.line_style
gc.line_width = 2
gc.line_style = GDK.LINE_ON_OFF_DASH
draw_line(pixmap, gc, 0,0,50,50)
gc.line_width = 1
gc.line_style = GDK.LINE_SOLID
draw_rectangle(pixmap, gc, FALSE, 50,100, 30, 20)
draw_arc(pixmap, gc, FALSE, 30,30, 20,20, 0,360*64)
draw_polygon(pixmap, gc, TRUE, ((100,100),(120,130),(110,150)))
draw_point(pixmap, gc, 110,160)
draw_segments(pixmap, gc, ((100,20,120,20),(110,10,110,30)))
f = load_fontset('-*--14-*') # for non-ascii character (e.g. japanese)
gc.foreground = red;draw_string(pixmap, f, gc, 50,50,'red test')
gc.foreground = green;draw_string(pixmap, f, gc, 50,65,'green test')
gc.foreground = blue;draw_string(pixmap, f, gc, 50,80,'blue test')
gc.foreground, gc.line_width, gc.line_style = save_fg, save_lw, save_ls
window = GtkWindow(WINDOW_TOPLEVEL)
window.set_title("drawable")
window.set_position(WIN_POS_CENTER)
vbox = GtkVBox()
vbox.show()
window.add(vbox)
closeBtn = GtkButton('Close')
closeBtn.connect("button_release_event", destroy)
closeBtn.show()
vbox.pack_start(closeBtn,FALSE,FALSE)
swin = GtkScrolledWindow()
swin.set_usize(200,200)
swin.show()
vbox.pack_start(swin)
drawable = GtkDrawingArea()
drawable.set_usize(250,200)
swin.add_with_viewport(drawable)
drawable.show()
window.connect("destroy", destroy)
drawable.connect("configure_event", configure_event)
drawable.connect("expose_event", expose_event)
window.show()
mainloop()
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]