473,804 Members | 3,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PIL: Breaking/Wrapping lines "automatica lly"


Hi!
Is there something I can do in PIL to restrict a line to a certain size and
have it to break/wrap into a newline automatically? (Or by using some code, of
course...)

I'm trying to add information to barcodes and since the label space is fixed
I'd like to use all the horizontal space I can and since I'm with two or three
lines of free space I'd like to use them as well.
TIA,
--
Jorge Godoy <go***@ieee.org >

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.
Mar 23 '06 #1
3 1716
Jorge Godoy wrote:
Is there something I can do in PIL to restrict a line to a certain size and
have it to break/wrap into a newline automatically? (Or by using some
code, of course...)


there's no standard function for this purpose, no.

here's a somewhat rough implementation, based on a WCK demo:

http://effbot.python-hosting.com/fil...il/textwrap.py

a somewhat better approach would be to use collect words as long as
they fit, and write each line as a single string.

</F>

Mar 23 '06 #2
"Fredrik Lundh" <fr*****@python ware.com> writes:
Jorge Godoy wrote:
Is there something I can do in PIL to restrict a line to a certain size and
have it to break/wrap into a newline automatically? (Or by using some
code, of course...)


there's no standard function for this purpose, no.

here's a somewhat rough implementation, based on a WCK demo:

http://effbot.python-hosting.com/fil...il/textwrap.py

a somewhat better approach would be to use collect words as long as
they fit, and write each line as a single string.


Then I'd have to have some means to determine the width of the char (I'm using
a TrueType font due to my need of using Unicode text) to calculate how many
words I can put on a single line...

I'll take a look at the page above.
Thanks!

--
Jorge Godoy <go***@ieee.org >

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.
Mar 23 '06 #3
Jorge Godoy <go***@ieee.org > writes:
Then I'd have to have some means to determine the width of the char (I'm using
a TrueType font due to my need of using Unicode text) to calculate how many
words I can put on a single line...


Hmmm... It looks like your code does that! Thanks! I'll give it a try
here.

--
Jorge Godoy <go***@ieee.org >

"Quidquid latine dictum sit, altum sonatur."
- Qualquer coisa dita em latim soa profundo.
- Anything said in Latin sounds smart.
Mar 23 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1508
by: sparks | last post by:
As you might know that "java.lang" package are automatically imported by the java compiler so that one don't need to write the import statement of that package in the source code. Are there any packages in .net are automatically "used" when your are writing a .net application? I am told that Visual Studio ..net automatically include different packages depending on the kind of applications you are creating. is this true? Will the compilier...
13
3117
by: gary | last post by:
Hi, We all know the below codes are dangerous: { int *p = new int; delete p; delete p; } And we also know the compilers do not delete p if p==NULL. So why compilers do not "p = NULL" automatically after programs do "delete p"?
1
1285
by: Weixiao Fan | last post by:
as we know , FONT is not availble for XHTML standard . but VS.NET 2003 add it automatically. what can I do to make all the BODY , TD , FONT and so on to body ,td ? and don`t let it add <FONT> automatically . PS : I use chinese edtion.
0
1699
by: wurlds_wurst_coder | last post by:
A co-worker apparently checked the Show Disassembly Automatically checkbox at some point. This is really inconvenient to disassemble every dll we use everytime. How do I turn this option OFF?? TIA introspectre
2
1227
by: Ellis Yu | last post by:
Dear All I'm trying to create a control that inherits the combobox control. When I entered in the line "Inherits Combobox", the IDE automatically added the method Public Sub New(ByVal Container as System.Component.Model.IContainer). What is it used for? Is there any impact if I cut it out? Thanks Best Rdgs Ellis
1
2410
by: John Bailo | last post by:
using ( SqlCommand cmd = new SqlCommand("select * sample"), new SqlConnection( sqlDsn ) ) ) { SqlDataAdapter adapter = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); adapter.Fill(dt);
2
5765
by: NowItsWhatever | last post by:
In query DESIGN view, how do I automatically "fit" the columns in the table/field grid to the lengths of the table and field names (including any functions applied to the fields). I am not talking about the query results. I am talking about sizing parts of the query DESIGN view, so that they are readable (long table and field names that get chopped off, long criteria specifications that get chopped off, ...), and saving the sizing so I...
1
2415
by: Jedufa | last post by:
following of thread: "Adding namespaces to code behind automatically" Hello, I had quite the same problem and got further in the right direction with your suggestions, thanks. Nevertheless, I have a newer problem which seems to come from the fact that the assembly which contains my "SimpleComponentToolboxItem" must be already referenced
2
2168
by: Destiny111 | last post by:
Hi! I have a gps program which works only when the "manage gps automatically" function is checked in the PDA settings. I do not want to enable user to disable my gps coords logging by uncheck this, also I want to check the state of this at program start. I need a registry key which related to this function if it exits. Thanks. Ps.: I know, I can disable gps settings icon from registry, but before I do this I need to check...
0
9584
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,...
0
10337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
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,...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
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();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5654
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.