Hi,
I would like to use pango.layout to display text in a pygtk2 project.
However I could not manage to get the pango.layout object incorporated
in my toplevel gtk.Window and have it displayed.
If anyone could help me either with a minimal example like 'Hello World'
displayed in italics in an pango.layout or the URL to a tutorial where I
can find the relevant infos (the PyGtk tutorial seems not to contain it,
unless I'm really blind)
Friedrich 2 2576
>>>>> "Friedrich" == Friedrich Dimmling <f.********@rem ove-this.snafu.de> writes:
Friedrich> Hi, I would like to use pango.layout to display text in
Friedrich> a pygtk2 project. However I could not manage to get the
Friedrich> pango.layout object incorporated in my toplevel
Friedrich> gtk.Window and have it displayed.
Friedrich> If anyone could help me either with a minimal example
Friedrich> like 'Hello World' displayed in italics in an
Friedrich> pango.layout or the URL to a tutorial where I can find
Friedrich> the relevant infos (the PyGtk tutorial seems not to
Friedrich> contain it, unless I'm really blind)
Here is pango_demo.py from my pygtk examples dir. I wrote this a long
time ago, so it may not be the best or most modern usage, but it may
help you along your way
from __future__ import division
import pygtk
pygtk.require(' 2.0')
import gtk
from gtk import gdk
import pango
win = gtk.Window()
win.show()
vbox = gtk.VBox()
vbox.show()
win.add(vbox)
figsize = 4,4
dpi = 72
def draw(widget):
gc = widget.window.n ew_gc()
context = widget.create_p ango_context()
layout = widget.create_p ango_layout('So me Text')
desc = pango.FontDescr iption('Times 14')
layout.set_font _description(de sc)
widget.window.d raw_layout(gc, x=100, y=200, layout=layout)
widget.window.d raw_rectangle( gc, 1, 100,100,100,100 )
def configure_event (widget, event):
global pixmap
pixmap = gtk.gdk.Pixmap( widget.window, 500, 500)
draw(widget)
return gtk.TRUE
def expose_event(wi dget, event):
draw(widget)
return gtk.TRUE
da = gtk.DrawingArea ()
da.connect('con figure_event', configure_event )
da.connect('exp ose_event', configure_event )
da.set_size_req uest(figsize[0]*dpi, figsize[1]*dpi)
da.show()
vbox.pack_start (da, gtk.TRUE, gtk.TRUE)
def byebye(button):
pixbuf = gtk.gdk.Pixbuf( gtk.gdk.COLORSP ACE_RGB, 0, 8,
500,500)
pixbuf.get_from _drawable(pixma p, pixmap.get_colo rmap(),
0, 0, 0, 0, 500, 500)
pixbuf.save('so mefile.png', 'png')
gtk.mainquit()
button = gtk.Button('Qui t')
button.show()
vbox.pack_start (button, gtk.TRUE, gtk.TRUE)
button.connect( 'clicked', byebye)
gtk.mainloop()
John Hunter wrote: Here is pango_demo.py from my pygtk examples dir. I wrote this a long time ago, so it may not be the best or most modern usage, but it may help you along your way
Hi John,
it helped me along my way by pointing to the right section in the PyGtk
Tutorial. Thanks
Friedrich This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Damien |
last post by:
I have just built a simple stopwatch application, but when i f5 to get
things goings i get this message,
An unhandled exception of type 'System.ArithmeticException' occurred in
system.drawing.dll
Additional information: Overflow or underflow in the arithmetic operation.
|
by: Pete |
last post by:
Hi All,
A total Newby with, possibly, a daft question? However, until I can get a
reasonable explanation I am disinclined towards going further. Here goes:
I recently downloaded the latest stable release and once activated it
requested access to the net. Without access it would come up with
recognition and 'localhost' connection errors?
Can anyone please tell me:
|
by: Pete |
last post by:
Hi All,
A total Newby with, possibly, a daft question? However, until I can get a
reasonable explanation I am disinclined towards going further. Here goes:
I recently downloaded the latest stable release and once activated it
requested access to the net. Without access it would come up with
recognition and 'localhost' connection errors?
Can anyone please tell me:
|
by: Fred Nelson |
last post by:
Hi:
I have programmed in VB.NET for about a year and I'm in the process of
learing C#. I'm really stuck on this question - and I know it's a "newby"
question:
In VB.NET I have several routines that upload and process images. I can't
get past "square one" with images in C#:
This statement:
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |