View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0013606 | Scribus | Scripter | public | 2015-12-16 17:51 | 2016-11-17 12:52 |
Reporter | utnik | Assigned To | gpittman | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Platform | macOS X | OS | macOS X | OS Version | 10.9 / 10.11 |
Product Version | 1.4.5 | ||||
Fixed in Version | 1.5.3.svn | ||||
Summary | 0013606: script 'align_image_in_frame.py' doesn't work. | ||||
Description | the built in script 'align_image_in_frame.py'leeds to the spinning wheel without doing anything else. after clicking some menu entries the wheel disappears and the menu entries: 'scribus scripts', 'execute script' and 'recent scripts' are grayed out. | ||||
Steps To Reproduce | - draw an image frame - put an image in the frame - select 'scripts' ? 'scribus scripts' ? 'align_image_in_frame' - enjoy the wheel… | ||||
Tags | tkinter | ||||
Patch | No | ||||
related to | 0012627 | confirmed | [OSX] calendarWizard leads to an endless loop |
|
the script uses tkinter - so it's most probably the same as with the calendar wizard (bug id=12627) |
|
utnik, add a # before the bug number as in 0012627 to make mantisbt recognize it. Also if you want to reference a specific thread in a commentary look at the number above the posters name, for example, your above post has the number 37927 above your nick. So you add a tilde '~' in front of that number, 37927. It comes out to some ugly looking things like this: 0013606:0037927 |
|
confirmed |
|
punting to gpittman |
|
I can't confirm in Linux/Fedora 23 with version 1.4.7svn. Works as expected. I don't have OSX to check it out there. Presumably something to do with tkinter. |
|
what are alternatives to tkinter that we can use on OSX ? |
|
What I am going to do is make a new version that does away with tkinter. It won't be as pretty, but should still be (fairly) simple. Instead of having this tk grid, you would specify the desired position as a choice between ul, uc, ur, ml, mc, mr, ll, lc, or lr. (upper left, upper center, etc.) |
|
there is a script without tkinter: https://wiki.scribus.net/canvas/Align_an_Image_in_its_Frame#New_Version_NOT_Using_Tkinter it works for me with scribus 1.4.6, 1.5.0, 1.5.1 and 1.5.2svn rev 21241 |
|
Align_image_in_frame2.py (2,646 bytes)
#!/usr/bin/python # Align_image_in_frame2.py # This version 2016.04.30 """ This script will align an image inside a frame to one of 9 possible positions: Upper left, upper center, upper right; middle left, middle center, middle right; or lower left, lower center, lower right. USAGE Select one or more image frames. Run the script, which asks for your alignment choice (all selected frames will need to have the same alignment). This modification does away with tkinter and uses a valueDialog instead. Note There is minimal error checking, in particular no checking for frame type. See the wiki page for further info: wiki.scribus.net/canvas/Align_an_Image_in_its_Frame """ 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() objList = [] for i in range(nbrSelected): objList.append(scribus.getSelectedObject(i)) scribus.deselectAll() alignment = scribus.valueDialog("Align where?", "UL\tUC\tUR\nML\tMC\tMR\nLL\tLC\tLR\n Enter one 2-letter choice\nUL = Upper Left LR = Lower Right", "UL") alignment = alignment.upper() for i in range(nbrSelected): try: obj = objList[i] scribus.selectObject(obj) 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 alignment[0] == "U": imageY = 0.0 elif alignment[0] == "M": imageY = (frameH - imageH) / 2.0 elif alignment[0] == "L": imageY = (frameH - imageH) if alignment[1] == "L": imageX = 0.0 elif alignment[1] == "C": imageX = (frameW - imageW) / 2.0 elif alignment[1] == "R": imageX = (frameW - imageW) scribus.setImageOffset(imageX, imageY, obj) scribus.docChanged(1) scribus.setRedraw(True) scribus.deselectAll() except: nothing = "nothing" scribus.setUnit(restore_units) if scribus.haveDoc(): scribus.redrawAll() |
|
I have uploaded Align_image_in_frame2.py which uses valueDialog instead of tkinter. (I had thought that I had made the above script, but had forgotten where it was. Anyway, did it again.) Little error checking, but it does allow entry of upper or lowercase letters, since these are converted to uppercase. |
|
On rechecking this, it works as far as I can tell. One thing that fooled me was that the tkinter dialog was small and appeared off in the upper right corner of the screen, so I didn't see it at first. I am uploading a slightly modified version, first to place the tkinter dialog differently, and I also added an error check for not having any frames selected. |
|
Align_image_in_frame.py (6,119 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 (all selected frames will need to have the same alignment). Choose the position in the dialog radio button grid, click Align. Image(s) are aligned, and script quits. Note There is minimal error checking, in particular no checking for frame type. See the wiki page for further info: wiki.scribus.net/canvas/Align_an_Image_in_its_Frame """ import scribus try: from Tkinter import * from tkFont import Font except ImportError: scribus.messageBox('Tkinter', "This script requires Python's Tkinter properly installed.",scribus.ICON_WARNING,scribus.BUTTON_OK) scribus.messageBox('Script failed', 'This script requires Python\'s Tkinter properly installed.', scribus.ICON_CRITICAL) sys.exit(1) class TkImageAlignmentWizard(Frame): """ GUI interface for aligning an image in a frame""" def __init__(self, master=None): """ Setup the dialog """ # refernce to the localization dictionary self.key = 'English' Frame.__init__(self, master) self.grid() self.master.geometry('120x120+80+80') self.master.title('Scribus Image Alignment Wizard') #define widgets # alignment options self.alignLabel = Label(self, text='Select alignment:') self.alignVar = StringVar() self.alignRadio1 = Radiobutton(self, text='', variable=self.alignVar, value="TL") self.alignRadio2 = Radiobutton(self, text='', variable=self.alignVar, value="TC") self.alignRadio3 = Radiobutton(self, text='', variable=self.alignVar, value="TR") self.alignRadio4 = Radiobutton(self, text='', variable=self.alignVar, value="ML") self.alignRadio5 = Radiobutton(self, text='', variable=self.alignVar, value="MC") self.alignRadio6 = Radiobutton(self, text='', variable=self.alignVar, value="MR") self.alignRadio7 = Radiobutton(self, text='', variable=self.alignVar, value="BL") self.alignRadio8 = Radiobutton(self, text='', variable=self.alignVar, value="BC") self.alignRadio9 = Radiobutton(self, text='', variable=self.alignVar, value="BR") self.alignButton = Button(self, text='Align', command=self.alignImage) # setup values self.alignRadio5.select() # make layout self.columnconfigure(0, pad=0) currRow = 0 self.alignLabel.grid(column=0, row=currRow, columnspan=3) currRow += 1 self.alignRadio1.grid(column=0, row=currRow) self.alignRadio2.grid(column=1, row=currRow) self.alignRadio3.grid(column=2, row=currRow) currRow += 1 self.alignRadio4.grid(column=0, row=currRow) self.alignRadio5.grid(column=1, row=currRow) self.alignRadio6.grid(column=2, row=currRow) currRow += 1 self.alignRadio7.grid(column=0, row=currRow) self.alignRadio8.grid(column=1, row=currRow) self.alignRadio9.grid(column=2, row=currRow) currRow += 1 self.alignButton.grid(column=0, row=currRow, columnspan=3) # self.doneButton.grid(column=3, row=currRow, columnspan=3) def alignImage(self): 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() objList = [] for i in range(nbrSelected): objList.append(scribus.getSelectedObject(i)) scribus.deselectAll() for i in range(nbrSelected): try: obj = objList[i] scribus.selectObject(obj) 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 self.alignVar.get()[0] == "T": imageY = 0.0 elif self.alignVar.get()[0] == "M": imageY = (frameH - imageH) / 2.0 elif self.alignVar.get()[0] == "B": imageY = (frameH - imageH) if self.alignVar.get()[1] == "L": imageX = 0.0 elif self.alignVar.get()[1] == "C": imageX = (frameW - imageW) / 2.0 elif self.alignVar.get()[1] == "R": imageX = (frameW - imageW) scribus.setImageOffset(imageX, imageY, obj) scribus.docChanged(1) scribus.setRedraw(True) scribus.deselectAll() except: nothing = "nothing" scribus.setUnit(restore_units) self.master.destroy() def main(): """ Application/Dialog loop with Scribus sauce around """ nbrSelected = scribus.selectionCount() if (nbrSelected == 0): scribus.messageBox('OOPS','You need to have at least one object selected',scribus.ICON_WARNING,scribus.BUTTON_OK) sys.exit(1) try: root = Tk() app = TkImageAlignmentWizard(root) root.mainloop() finally: if scribus.haveDoc(): scribus.redrawAll() if __name__ == '__main__': main() |
|
I uploaded a new version of Align_image_to_frame.py This script is not included with Scribus anymore. |
Date Modified | Username | Field | Change |
---|---|---|---|
2015-12-16 17:51 | utnik | New Issue | |
2015-12-16 17:54 | utnik | Note Added: 0037927 | |
2015-12-16 21:23 | Kunda | Note Added: 0037933 | |
2015-12-16 21:23 | Kunda | Relationship added | related to 0012627 |
2015-12-16 21:24 | Kunda | Note Added: 0037934 | |
2015-12-16 21:24 | Kunda | Status | new => confirmed |
2016-04-21 23:24 | Kunda | Assigned To | => gpittman |
2016-04-21 23:24 | Kunda | Status | confirmed => assigned |
2016-04-21 23:24 | Kunda | Note Added: 0040374 | |
2016-04-29 20:44 | gpittman | Note Added: 0040615 | |
2016-04-30 11:56 | Kunda | Tag Attached: tkinter | |
2016-04-30 11:56 | Kunda | Note Added: 0040628 | |
2016-04-30 12:56 | gpittman | Note Added: 0040631 | |
2016-04-30 13:05 | utnik | Note Added: 0040632 | |
2016-04-30 14:38 | gpittman | File Added: Align_image_in_frame2.py | |
2016-04-30 14:42 | gpittman | Note Added: 0040638 | |
2016-11-06 17:35 | gpittman | Note Added: 0042340 | |
2016-11-06 17:35 | gpittman | File Added: Align_image_in_frame.py | |
2016-11-06 17:37 | gpittman | Status | assigned => closed |
2016-11-06 17:37 | gpittman | Resolution | open => fixed |
2016-11-06 17:37 | gpittman | Fixed in Version | => 1.5.3 |
2016-11-06 17:37 | gpittman | Note Added: 0042341 | |
2016-11-17 12:52 | jghali | Fixed in Version | 1.5.3 => 1.5.3.svn |