gtk绘制设置背景图像 [英] gtk drawing set background image

查看:350
本文介绍了gtk绘制设置背景图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个绘图区域和一个'png'图像,我想将该图像作为背景加载到绘图区域。

I have a drawing area, and an 'png' image I want to load that image to my drawing area as background.

屏幕比我的图像大问题是它没有'瓷砖'我的形象

the screen is bigger then my image and the problem is it does not 'tile' my image

我曾尝试添加图像作为pixbuf和pixmap,但它没有帮助

I have tried adding image as pixbuf and pixmap but it doesnot help

我使用此行

gc.set_tile(pixmap)
area.window.draw_drawable(gc, pimap, .....)

但它没有帮助

推荐答案

我找到答案
i将代码放在这里给其他人使用

i found the answer i put the code here for others

area=gtk.Drawingarea()

pixbuf=gtk.gdk.pixbuf_new_from_file('background.png')
pixmap, mask=pixbuf.render_pixmap_and_mask()

area.window.set_back_pixmap(pixmap, False)

这篇关于gtk绘制设置背景图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆