Author Topic: built-in alignment_image_in_frame script hangs  (Read 904 times)

szyfrow

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
  • Scribus User
built-in alignment_image_in_frame script hangs
« on: December 16, 2015, 11:11:09 am »
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

  • Hero Member
  • *****
  • Posts: 1049
  • Karma: 12
Re: built-in alignment_image_in_frame script hangs
« Reply #1 on: December 16, 2015, 07:35:49 pm »
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)
« Last Edit: December 16, 2015, 07:56:34 pm by utnik »

szyfrow

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
  • Scribus User
Re: built-in alignment_image_in_frame script hangs
« Reply #2 on: December 18, 2015, 12:47:03 pm »
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

  • Hero Member
  • *****
  • Posts: 1049
  • Karma: 12
Re: built-in alignment_image_in_frame script hangs
« Reply #3 on: December 18, 2015, 01:20:16 pm »
hi szyfrow

…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

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
  • Scribus User
Re: built-in alignment_image_in_frame script hangs
« Reply #4 on: December 18, 2015, 01:23:09 pm »
#!/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

  • Hero Member
  • *****
  • Posts: 1049
  • Karma: 12
Re: built-in alignment_image_in_frame script hangs
« Reply #5 on: December 18, 2015, 05:05:57 pm »
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
« Last Edit: December 18, 2015, 05:10:57 pm by utnik »

szyfrow

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
  • Scribus User
Re: built-in alignment_image_in_frame script hangs
« Reply #6 on: December 23, 2015, 11:23:11 am »
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