Hi there.
Is there still no way within the Python programming interface to set the height of a row label row (and the data cells in that row too), or barring that, to trigger a reformatting of a row label height?
I ask because I have several Python customfunctions, which I access through MODIFY TABLES run on Frequency tables, that change row label column widths. After I have run MODIFY TABLES, there are several pivot tables that have row labels that are too TALL. They should be only one line high that are 2 or 3 lines high.
I also have dimension labels, for which I have changed the width of the cell through a different customfunction, that are too SHORT. They should be 3-4 lines high but are only 2 lines high.
I am on SPSS Client 21.0.0.2, with the latest version of MODIFY TABLES.
Here is the code for one of the customfunctions:
def ResizeCornerLabel(obj, i, j, numrows, numcols, section, more, custom):
""" Show corner (dimension) label, and then resize the column based
on the length of the contents. Custom parameter 1 is maximum dimension
label column width in characters, default is 60. Custom parameter 2 is
character width in points, default is 5. """
if section != 'labels':
tkMessageBox.showinfo("","Only works for labels!")
return
max_width = custom.get("maxwidth", 60)
char_width = custom.get("charwidth", 6)
obj.ShowHiddenDimensionLabelAt(1,obj.GetNumColumns()-1)
label_len = len(obj.GetValueAt(1,0))
if label_len <= max_width:
label_points = label_len * char_width
else:
label_points = max_width * char_width
obj.SetRowLabelWidthAt(1,obj.GetNumColumns()-1,label_points)
Thanks for any help that you can give!
J
Answer by JonPeck (4671) | May 01, 2014 at 10:47 PM
This isn't a MODIFY TABLES issue. When the apis are applied, the table should automatically resize the other dimension. I am surprised that it doesn't. (Remember, though that the sizes in MODIFY TABLES are always in points.)
CTABLES provides for direct control of label widths, but more generally a way around this would be to create a tablelook with the desired widths and set this as your default or apply it afterwards using MODIFY TABLES.
NOMREG, the SPSS syntax for multinominal logistic regression, referant 1 Answer
Modifying tables a bit more 3 Answers
SPSS Python Dummy Variable Module 1 Answer
PyScripter as Python IDE 4 Answers
Adding footnote to table 4 Answers