Python platypus changing from Portrait to Landscape - landscape

I'm looking for some inspiration. I have some code that is changing the orientation of a page from the default portrait to landscape however the frames I create within the pagetemplates always get created as if they are on a portrait page still.
doc = BaseDocTemplate('test2.pdf', pagesize=landscape(A4))
myFrameThresholdLeft = Frame(
doc.leftMargin,
doc.bottomMargin,
doc.width / 2,
doc.height,
showBoundary=1 # set to 1 for debugging
)
emptyTemplate = PageTemplate(id='emptyTemplate',
pagesize=landscape(A4),
frames=[myFrameThresholdLeft,
myFrameThresholdRight],
onPage=emptyLayout)
elements.append(NextPageTemplate('emptyTemplate'))
elements.append(PageBreak())
I think this is because the values returned by the e.g. doc.width methods are not changing as I change the pagesize in the pagetemplate. Can someone put me on the right tracks here?

Related

How do I resize an array of squished PyQt5 widgets? [duplicate]

I have a QScrollArea Widget, which starts empty;
It has a vertical layout, with a QGridLayout, and a vertical spacer to keep it at the top, and prevent it from stretching over the whole scroll area;
Elsewhere in the program, there is a QTextEdit, which when changed, has its contents scanned for "species" elements, and then they are added to the QGridLayout. Any species elements which have been removed are removed too. This bit works;
I have turned the vertical scrollbar on all the time, so that when it appears it does not sit on top of the other stuff in there. Note that the scroll bar is larger than the scroll box already though, despite not needing to be.
This is the problem. The scroll area seems to be preset, and i cannot change it. If i add more rows to the QGridLayout, the scroll area doesn't increase in size.
Instead, it stays the same size, and squeezes the QGridLayout, making it look ugly (at first);
And then after adding even more it becomes unusable;
Note that again, the scroll bar is still the same size as in previous images. The first two images are from Qt Designer, the subsequent 3 are from the program running.
If I resize the window so that the QScrollArea grows, then I see this:
Indicating that there's some layout inside the scroll area that is not resizing properly.
My question is; what do I need to do to make the scrollable area of the widget resize dynamically as I add and remove from the QGridLayout?
If you're coming here from Google and not having luck with the accepted answer, that's because you're missing the other secret invocation: QScrollArea::setWidget. You must create and explicitly identify a single widget which is to be scrolled. It's not enough to just add the item as a child! Adding multiple items directly to the ScrollArea will also not work.
This script demonstrates a simple working example of QScrollArea:
from PySide.QtGui import *
app = QApplication([])
scroll = QScrollArea()
scroll.setWidgetResizable(True) # CRITICAL
inner = QFrame(scroll)
inner.setLayout(QVBoxLayout())
scroll.setWidget(inner) # CRITICAL
for i in range(40):
b = QPushButton(inner)
b.setText(str(i))
inner.layout().addWidget(b)
scroll.show()
app.exec_()
The documentation provide an answer :
widgetResizable : bool
This property holds whether the scroll area should resize the view widget.
If this property is set to false (the default), the scroll area honors the size of its widget.
Set it to true.
Why don't you use a QListView for your rows, it will manage all the issues for you? Just make sure that after you add it you click on the Class (top right window of designer) and assign a layout or it wont expand properly.
I use a QLIstWidget inside a QScrollArea to make a scrollable image list
Try this for adding other objects to the list, this is how I add an image to the list.
QImage& qim = myclass.getQTImage();
QImage iconImage = copyImageToSquareRegion(qim, ui->display_image->palette().color(QWidget::backgroundRole()));
QListWidgetItem* pItem = new QListWidgetItem(QIcon(QPixmap::fromImage(iconImage)), NULL);
pItem->setData(Qt::UserRole, "thumb" + QString::number(ui->ImageThumbList->count())); // probably not necessary for you
QString strTooltip = "a tooltip"
pItem->setToolTip(strTooltip);
ui->ImageThumbList->addItem(pItem);
Update on Artfunkel's answer:
Here's a PySide6 demo that uses a "Populate" button to run the for loop adding items to the scroll area. Each button will also delete itself when clicked.
from PySide6.QtWidgets import *
app = QApplication([])
scroll = QScrollArea()
scroll.setWidgetResizable(True) # CRITICAL
inner = QFrame(scroll)
inner.setLayout(QVBoxLayout())
scroll.setWidget(inner) # CRITICAL
def on_remove_widget(button):
button.deleteLater()
def populate():
for i in range(40):
b = QPushButton(inner)
b.setText(str(i))
b.clicked.connect(b.deleteLater)
inner.layout().addWidget(b)
b = QPushButton(inner)
b.setText("Populate")
b.clicked.connect(populate)
inner.layout().addWidget(b)
scroll.show()
app.exec()

Fit to frame with vertical justification options

Working with InDesign script I am using
TF.fit(FitOptions.frameToContent). //TF as a textFrame
to fit the content into the textframe and remove the extra space
But when I have a condition for vertical justification options set to Align: Bottom i am not able to fit the content.
Assuming this to be my TextFrame (Image 1)
Here are the properties of the text frame (Image 2)
When I do FitOptions.frameToContent i get this (Image 3)
But when the text frame has the align property set to the bottom I want this to fit it like this(this was achieved by double-clicking on the top center alignment as shown in the red indicator below. (Image 4) (Image 5)
I tried all the available options at http://jongware.mit.edu/idcs4js/pe_FitOptions.html but I had no luck making it work. Please help me to achieve the same using scripting.
Cross-reference: https://community.adobe.com/t5/indesign/fit-to-frame-with-vertical-justification-options/td-p/11120458?page=1
================== First try ==================
var tf = app.selection[0];
var tfp = tf.textFramePreferences;
tfp.autoSizingReferencePoint = AutoSizingReferenceEnum.BOTTOM_CENTER_POINT;
tfp.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY;
tf.fit(FitOptions.frameToContent)
This still gives me the same result(image 3) but expected result is image 4.
================== Second try ==================
This is the auto-sizing property.
This command indeed seems to work only with the top edge as a reference point, just as it does in the UI (if you actually use the menu command, not clicking any borders).
What you could do to work around this, is to temporarily enable auto-sizing (height only) and setting the reference point for auto-sizing to the bottom:
var tf = app.selection[0];
var tfp = tf.textFramePreferences;
tfp.autoSizingReferencePoint = AutoSizingReferenceEnum.BOTTOM_CENTER_POINT;
tfp.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY;
tfp.autoSizingType = AutoSizingTypeEnum.OFF;
Note, the last line turns off the auto sizing again and is optional; if you don't mind that the frame keeps auto sizing you don't need to turn it off.

autoenablesDefaultLighting is too bright in iOS 12 and SCNView.pointOfView is not effective

I am using SceneKit’s autoenablesDefaultLighting and allowsCameraControl functions of my sceneView to provide light to an obj 3D model in the app and rotate around this object in Objective-C. Since upgrading to iOS12, the default light intensity of autoenablesDefaultLighting gets higher and the 3D model looks so bright!
Did anyone faced the same issue? If yes, is there a way to control the light intensity of autoenablesDefaultLighting when its value is ‘YES’? If it is not editable, I tried to attach/constraint an omni light or directional light to a camera by creating a node, assign a light to this node and add as child of SCNView.pointOfView but no light illuminates the scene.
Exemple:
3D object displayed before iOS 12
3D object displayed in iOS 12
It will be good if anyone can help me on it.
Many thanks!
Edit to solve this issue
I create a new SCNCamera and add this in a node and set the PointOfView of my scnView.
Activate the HDR of this camera with scnView.pointOfView.wantHDR = YES;
but a had a grey background.
To delete the grey background I delete the background color with scnView.backgroundColor = [UIColor ClearColor]
and set the explosure of the camera to -1 with :
self.scnView.pointOfView.camera.minimumExposure = -1;
self.scnView.pointOfView.camera.maximumExposure = -1;
Thanks
You can try enabling HDR. It should result in a balanced exposure
scnView?.pointOfView?.camera?.wantsHDR = true
With HDR enabled, you can even control exposure compensation with
scnView?.pointOfView?.camera?.exposureOffset
.camera?.wantsHDR = true
.camera?.wantsExposureAdaptation = false
Should solve the problem!

TYPO3 6.2: Tab "Appearance" disappeared (maybe caused by t3sbootstrap extension?)

When editing an image content element in TYPO3, usually there is a tab "appearance" with options for image size, alignment, position etc. In my installation that tab is not showing, but instead a "nameless" tab. I'm using the t3sbootstrap extension and this behaviour might be caused by bootstrap.
Does anyone know how I can make the appearance tab visible and usable again? I've searched the internet but didn't find anything helpful so far. Thanks for your help!
Here is a screenshot from my backend:
Apparently this problem is caused by a corrupted TCA. I made the following changes in default TCA using System -> Configuration:
To restore the options for Layout, Top and bottom margins and frames, I set the following:
$TCA['tt_content']['palettes']['frames']['showitem'] = 'layout;LLL:EXT:cms/locallang_ttc.xlf:layout_formlabel, spaceBefore;LLL:EXT:cms/locallang_ttc.xlf:spaceBefore_formlabel, spaceAfter;LLL:EXT:cms/locallang_ttc.xlf:spaceAfter_formlabel, section_frame;LLL:EXT:cms/locallang_ttc.xlf:section_frame_formlabel';
To restore the appearance tab title:
In $TCA['tt_content']['types']['image']['showitem'] I changed LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance to LLL:EXT:cms/locallang_ttc.xlf:tabs.appearance
To restore the image adjustments:
In $TCA['tt_content']['types']['image']['showitem'] I changed --div-- to --palette-- right after the frames part and I added LLL:EXT:cms/locallang_ttc.xlf:palette.image_settings;image_settings, --palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.imageblock;imageblock, --div--; after the frames part.
This is the result:
$TCA['tt_content']['types']['image']['showitem'] = '--palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.general;general, --palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.header;header, --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.images, image, --palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.imagelinks;imagelinks, --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.appearance, --palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.frames;frames, --palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.image_settings;image_settings, --palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.imageblock;imageblock, --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access, --palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.visibility;visibility, --palette--;LLL:EXT:cms/locallang_ttc.xlf:palette.access;access, --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.extended, , --div--;LLL:EXT:flux/Resources/Private/Language/locallang.xlf:tt_content.tabs.relation, tx_flux_parent, tx_flux_column, tx_flux_children;LLL:EXT:flux/Resources/Private/Language/locallang.xlf:tt_content.tx_flux_children';
Result
After making these changes, the result is the following:

Problems with MediaElement showing Video inside a Panorama

This script sets up a Panorama Control with 5 items, then loads up a video inside a MediaElement in the second Panorama item.
If I reduce this down to 2 items then no video shows (the media element is "invisible"), but you can still hear the audio - i.e. something like:
panorama = Panorama.new
panorama.title = "Video panorama"
Host.content_holder.children.add panorama
for i in 1..2 # if this is >2, then the video shows
panorama_item = PanoramaItem.new
panorama_item.header = "Child " << i.to_s
panorama.items.add panorama_item
if i == 2
panorama_item.orientation = Orientation.horizontal
media_element = MediaElement.new
media_element.source = Uri.new("http://files.ch9.ms/ch9/f2c3/b59b6efb-3c70-4bc2-b3ff-9e650007f2c3/wp7ces_ch9.wmv")
panorama_item.content = media_element
else
text_block = TextBlock.new
text_block.text = "Hello world"
panorama_item.content = text_block
end
end
I guess this is something to do with the animation and timing of the initial Panorama show - but I've not been able to get any grip on the problem.
The problem does appear to be the same in C#/XAML so it's not a scripting issue.
Has anyone got any ideas of where to look?
Don't have less than 3 items in your Panorama - I've heard it from MSFT peeps as a UX guideline. When technical issues have come up relating to a panorama with only 1 or 2 items those same people have pointed out that the Panorama is not intended to be used with so few items and so you may get weird behaviours.
Also be careful showing video in a PanoramaItem - as this is not the way the Panorama control is used in the standard applications - so it may fall outside the guidelines.