[scribus] Word Count of selected text

a.l.e ale.comp_06 at xox.ch
Wed Jul 14 12:42:44 CEST 2010

hi harsha,

> > I wished to know whether there was a way to know the 
> word count of selected
> > text.
> >
> > The "Edit Story" section shows the world count of the text 
> automatically of
> > the whole story. Or of the current paragraphs.
> >
> > But what if if wish to know the word count of a selected 
> text of the story?

this script will also solve your problem, but it won't work in the story editor: you have to use it on the text frame.

#--- 8< ---
this script counts the character in the current selection
@author: alessandro rimoldi
@version: 1.0 / 20100714
@copyright (c) 2010 alessandro rimoldi under the mit license
import sys
   import scribus
except ImportError:
   print "This script only works from within Scribus"

# check that the selection is one text frame and get that frame
frame_n = scribus.selectionCount()
if frame_n == 0 :
    scribus.messageBox('Error:', 'No frame selected');
elif frame_n > 1 :
    scribus.messageBox('Error:', 'You may select only one frame');

frame = scribus.getSelectedObject(0)
    char_n = scribus.getTextLength(frame)
except scribus.WrongFrameTypeError:
    scribus.messageBox('Error:', 'You have to first select a text frame');

if char_n == 0 :
    scribus.messageBox('Error:', 'There is no text in the frame');

scribus.messageBox('Character count:', 'There are
'+str(len(scribus.getText()))+' characters selected');
#--- >8 ---


More information about the scribus mailing list