View Issue Details

IDProjectCategoryView StatusLast Update
0016816ScribusScripterpublic2022-06-23 17:52
Reporterkhbehrens Assigned Tojghali  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionunable to reproduce 
Platformscribus 1.5.8OSLinuxOS VersionUbuntu 20.04 LTS
Summary0016816: align_image_in_frame.py in appimage will not execute
DescriptionThe included script is the incorrect version for 1.5.8.
Steps To Reproduce1. select an image.
2. select Scripts > Scribus Scripts > align_image_in_frame script
3. the execute indicator spins, script does not launch
Additional InformationI downloaded this version from https://w.scribus.net/wiki/index.php/Align_image_in_frame and installed in my home script dir

New Version NOT Using Tkinter
Here I have completely eliminated all aspects of Tkinter.
Instead, you get a valueDialog and enter a 2-letter combination, the first being T, M, or B, and the second L, C, or R. The script allows upper or lower case entries, but if you don't follow this order, or use other letters (for example, either CM or XY), this defaults to top left positioning.
#!/usr/bin/python
# align_image_in_frame.py
# This version 2014.04.19

This version not using Tkinter works (code attached).
Please include it in the appimage build
TagsNo tags attached.
PatchNo

Activities

khbehrens

2022-06-22 12:46

reporter  

Align_image_in_frame.py (2,675 bytes)   
#!/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[i]
          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()
Align_image_in_frame.py (2,675 bytes)   

jghali

2022-06-22 18:45

administrator   ~0049717

Unable to reproduce here. I made tests on both Ubuntu 18.04, on which the AppImage was built, and on Ubuntu 20.04. In both cases, the script provided with the AppImage executes without issue.

khbehrens

2022-06-23 00:11

reporter   ~0049718

just to verify that you tested this appimage: scribus-1.5.8-linux-x86_64_fd6ae2e4aeae65bc980d1297c3dbeb24.AppImage
The py script did not work on any of my 4 ubuntu 20.04 machines, but the code I included did.

jghali

2022-06-23 06:36

administrator   ~0049719

>> just to verify that you tested this appimage: scribus-1.5.8-linux-x86_64_fd6ae2e4aeae65bc980d1297c3dbeb24.AppImage

I don't know where you got that AppImage from. The official 1.5.8 AppImage can be downloaded here and this is the one I tested:
https://sourceforge.net/projects/scribus/files/scribus-devel/1.5.8/

khbehrens

2022-06-23 16:13

reporter   ~0049720

I downloaded again using your link and everything worked as you said. I must have downloaded a dev version on scribus.org that did not have the code in it. It has been a while so this is probably what happened.
Thanks for setting me straight and this report can be marked as solved. Sorry for the confusion on my part.

jghali

2022-06-23 17:52

administrator   ~0049721

You're welcome!

Issue History

Date Modified Username Field Change
2022-06-22 12:46 khbehrens New Issue
2022-06-22 12:46 khbehrens File Added: Align_image_in_frame.py
2022-06-22 18:42 jghali Project Contributor Builds => Scribus
2022-06-22 18:43 jghali Category General => Scripter
2022-06-22 18:45 jghali Note Added: 0049717
2022-06-23 00:11 khbehrens Note Added: 0049718
2022-06-23 06:36 jghali Note Added: 0049719
2022-06-23 16:13 khbehrens Note Added: 0049720
2022-06-23 17:52 jghali Assigned To => jghali
2022-06-23 17:52 jghali Status new => resolved
2022-06-23 17:52 jghali Resolution open => no change required
2022-06-23 17:52 jghali Note Added: 0049721
2022-06-23 17:52 jghali Status resolved => closed
2022-06-23 17:52 jghali Resolution no change required => unable to reproduce