Scribus Forums

Scribus => Scripts and Plugins => Topic started by: shab.t786 on November 12, 2024, 05:53:48 AM

Title: Textbox Frame Size when creating a textbox using script
Post by: shab.t786 on November 12, 2024, 05:53:48 AM
sizeObject(...)
sizeObject(width, height [, "name"])
Resizes the object "name" to the given width and height. If "name" is not given the currently selected item is used.

I am trying to use this function to resize a text frame created. But it does not work
  text_frame = scribus.createText(x_pos, y_pos, width, height)
           
            # Insert only the cleaned text into the Scribus text box
            scribus.insertText(clean_text, -1, text_frame)

            # Optional: Set font styling
            scribus.setFontSize(10, text_frame)
            scribus.setFont("Baloo 2 Medium", text_frame)

            # Set columns for the text frame
            scribus.setColumns(2, text_frame)  # Adjust the number of columns as needed

            # Resize the object (if needed)
            scribus.sizeObject(width, height, text_frame)

            # Redraw all elements
            scribus.redrawAll()
Title: Re: Textbox Frame Size when creating a textbox using script
Post by: AdmFubar on November 12, 2024, 07:46:21 PM
at a quick glance at this script, I dont see what the new size would be, or how the size is going to be changed. Yes there the resize section, but are the width and height, getting the updated values?
Title: Re: Textbox Frame Size when creating a textbox using script
Post by: a.l.e on November 12, 2024, 08:19:58 PM
if width and height are defined, you're using the same width and height for creating the frame and then for resizing it.

in that case it won't change its size, no.

i just tested the sizeObject() function on my local Scribus and it did work as expected.

if reading this does not help, you might need to define a bit better what "it does not work" means...