built-in alignment_image_in_frame script hangs

Previous topic - Next topic

szyfrow

Hi folks,

The built-in alignment script hangs on my computer. Can someone help me out?

Ii hangs on both versions 1.4.4 and 1.4.5.

I'm using a Mac, OSX 10.9.5 (Mavericks).






utnik

#1
hi szyfrow

this looks like the same (tkinter related) problem as with the calendar wizard and some other scripts – see bug id=12627...

utnik

edit: i just filed a new report for this one (bug id=13606)

szyfrow

Hi Utnik, I unsuccesfully tried another script, wich doesn't need tkinker. That didn't work either. In order to make sure I'm not having a general problem running scripts I ran the Autoquote script succesfully.

utnik

hi szyfrow

Quote from: szyfrow on December 18, 2015, 11:47:03 AM...another script, wich doesn't need tkinker. That didn't work either.

could you tell me which one – and what scribus did when you tryed to launch it?

utnik

szyfrow

#!/usr/bin/python
# align_image_in_frame.py
# This version 2014.04.19
"""
This script will align an image inside a frame to one of 9 possible positions:
Top left, top center, top right; middle left, middle center, middle right;
or bottom left, bottom center, bottom right.

USAGE
Select one or more image frames. Run the script, which asks for your alignment
choice. Possible legitimate entries are:
TL   TC   TR
ML   MC   MR
BL   BC   BR

and lowercase entries are also legitimate.

Note
There is minimal error checking, in particular no checking for frame type.

"""

import scribus


if scribus.haveDoc():
    restore_units = scribus.getUnit()   # since there is an issue with units other than points,
    scribus.setUnit(0)         # we switch to points then restore later.
    nbrSelected = scribus.selectionCount()
    if (nbrSelected == 0):
      scribus.messageBox('Error:', 'No frame selected')
      sys.exit(1)
    position = scribus.valueDialog('Image Position', '     T = Top,     M = Middle,     B = Bottom     \n     L = Left,     C = Center,     R = Right     \n     Example: ML = Middle Left', 'MC')
    objList = []
    for i in range(nbrSelected):
      objList.append(scribus.getSelectedObject(i))
      for i in range(nbrSelected):
        try:
          obj = objList
          frameW, frameH = scribus.getSize(obj)
          saveScaleX, saveScaleY = scribus.getImageScale(obj)
          scribus.setScaleImageToFrame(1, 0, obj)
          fullScaleX, fullScaleY = scribus.getImageScale(obj)
          scribus.setScaleImageToFrame(0, 0, obj)
          scribus.setImageScale(saveScaleX, saveScaleY, obj)
          imageW = frameW * (saveScaleX / fullScaleX)
          imageH = frameH * (saveScaleY / fullScaleY)
          imageX = 0.0
          imageY = 0.0

          if (position[0] == "T") or (position[0] == "t"):
            imageY = 0.0
          elif (position[0] == "M") or (position[0] == "m"):
            imageY = (frameH - imageH) / 2.0
          elif (position[0] == "B") or (position[0] == "b"):
            imageY = (frameH - imageH)
          if (position[1] == "L") or (position[1] == "l"):
            imageX = 0.0
          elif (position[1] == "C") or (position[1] == "c"):
            imageX = (frameW - imageW) / 2.0
          elif (position[1] == "R") or (position[1] == "r"):
            imageX = (frameW - imageW)

          scribus.setImageOffset(imageX, imageY, obj)
          scribus.docChanged(1)
          scribus.setRedraw(True)
        except:
          nothing = "nothing"
    scribus.setUnit(restore_units)
else:
    scribus.messageBox('Error', 'No document open')
    sys.exit(1)

if scribus.haveDoc():
    scribus.redrawAll()

utnik

#5
hi szyfrow

from where do you have this?
try this version – should work...
as far as i saw, there's only a bracket with the letter 'i' missing in line 39 of your script.

utnik

szyfrow

Hi Utnik,

Thank you for your reply. The script I was talking about was exactly the one on the page in your link. Strange thing is that both the script that didn't work before and the one on the page you provided now both work like a charm! Weird, because I tried the script a number of times in 1.4.4 and 1.4.5. The only explanation I can think of is that I foolishly failed to select a frame and missed the corresponding error message. Apologies for the annoyance and many thanks for thinking along!

Szyfrow