Is it possible to add a pyqtgraph to a PySide app without using a QLayout? - pyside

I want to add a pyqtgraph plot to my existing PySide application. All of the existing examples use a QLayout of some form to achieve this:
from PySide import QtGui
import sys
import pyqtgraph
app = QtGui.QApplication(sys.argv)
my_widget = QtGui.QWidget()
btn = QtGui.QPushButton("my button", my_widget)
plot = pyqtgraph.PlotWidget()
plotLayout = QtGui.QVBoxLayout()
plotLayout.addWidget(plot)
my_widget.setLayout(plotLayout)
my_widget.show()
app.exec_()
Is it possible to add pyqtgraph plots to my widget without adding it to a layout first? I'm guessing I need to do this because I'm trying to add a widget to a widget. Does pyqtgraph provide something more like QPushButton or QLabel, that can be directly added to the widget?

The widget is pyqtgraph.PlotWidget() (which is in your above code). You could add this to another parent widget as you do with other widgets with pyqtgraph.PlotWidget(parent) (see the documentation for the list of constructor arguments). This will place it at coordinates (0,0) inside the parents widget with a default size (I don't know what this size is or how it is determined - It could have dimensions (0,0) or something equally small).
However, typically the hierarchy of objects in a Qt interface should follow Widget -> Layout -> Widget -> Layout -> Widget ... (etc). This allows multiple widgets to be placed inside another widget and spaced and sized properly by the layout. Without layouts, you have to try and manually specify the coordinates and dimensions of each widget. This is possible (but cumbersome) as long as you don't mind widgets not resizing properly when the window size changes.
Given the small amount of overhead to ensure widgets are always inside layouts, and layouts are always inside widgets, I would encourage you to follow that pattern unless you have a specific reason not to.

Related

Resizing image to fit Ui Image View in xcode storyboard

I am trying to fit an image to fit the entire of the Ui Image View. I want to do this because I want to round my image and it does not work because the image is smaller than the entire view. So rounding it rounds the outside of the image and is not visible. I have tried to add constraints but that does not seem to have workout.
Here is an image of what I am trying to do:
https://i.stack.imgur.com/mIGow.png
The problem images:
https://i.stack.imgur.com/LGDyx.png
https://i.stack.imgur.com/K3RVZ.png
OK - the problem is that you don't understand the Xcode interface.
When you have added a UIImageView, set its image, and then select it, you see this:
If you click the image view again, Xcode shows an additional "highlight" outline:
That has nothing to do with how it will look when you run your app.
Regarding the screen-cap from the video you are watching... You either didn't notice, or forgot, two things:
it's a tutorial for SwiftUI - the screen-caps you've posted for what you're trying to do is from a UIKit based app.
at 17:20 of Part 1 of that series, the author explains how he is setting the corner radius.
To get what you want with UIKit, you need to write some code to give the image view rounded corners. To have it show up at design-time, you need to use an #IBDesignable image view subclass.
Here's a very basic example:
#IBDesignable
class RoundedImageView: UIImageView {
override func layoutSubviews() {
layer.cornerRadius = 20
}
}
If you set the Custom Class of your image view to RoundedImageView, and then either select either Editor -> Refresh All Views or have Editor -> Automatically Refresh Designable Views checked, you'll see this:

How to do a scale open animation in Flutter?

I'm trying to do this animation in flutter :
https://material.io/guidelines/motion/choreography.html#choreography-creation
My problem is that I have absolutely no idea how to do that.
As far as I know, widgets in flutter don't know their position nor the position or other widgets at all.
And you can't access context.size inside the build method.
I tried to use Hero animation to do it. Or ScaleTransition. But it's definitely not working.
You can use showMenu to dynamically show a popup menu at a given location. Consider using PopupMenuButton, which is an IconButton that automatically shows a menu when it is tapped. There's an example in the Gallery. If showMenu doesn't do what you want, you can copy the code in popup_menu.dart and customize it to make your own version. It uses CustomSingleChildLayout and PopupRoute.
If you just want to absolutely position a Material or Card on top of other elements, you can give it some elevation and use a Positioned within a Stack. You can use an AnimatedSize to adjust the element's size with a Curve. This won't interact with the back button on Android automatically, so if you want that, you may have to use addLocalHistoryEntry or PopupRoute.
If I understand you correct - you want to show square widget, and animation is not suitable at most because widget doesn't know its size.
In this case you can try MediaQuery.of(context).size.width - it returns width of your screen, so you can use it for calculating widgets size

In xcode and tvos, is it possible to convert the top shelf image to an image stack?

In xcode, and tvos, the 3D parallax icons in the asset catalog are shown as image stacks. But this is not the case with the so called top shelf image.
Is it possible to convert the top shelf image to a multi layer image stack in xcode?
Only content that is focusable is multilayered and then you need to provide several of them.
There are 3 top shelf types, but unfortunately none of them fit your needs.
You can read more about them in apple tv human interface guide lines.
1) single, static top shelf image
Provide a visually rich static image. Your app’s static top shelf
image is used when dynamic content isn’t provided or is unavailable.
Use it as an opportunity to highlight your brand.
Don’t imply interactivity in a static image. The static top shelf
image isn’t focusable, so it shouldn't include elements that make it
appear interactive.
2) "Dynamic Content Layouts" - "Sectioned Content Row"
this is for content similar to portrait movie posters. those can be multilayered, but:
Provide enough content to constitute a complete row. At a minimum,
load enough images in a sectioned content row to span the full width
of the screen.
3) "Dynamic Content Layouts" - "Scrolling Inset Banner"
this is for content similat to wide screen advertising banners. those can be multilayered, but:
A minimum of three images is recommended for a scrolling banner to
feel effective.
To make Dynamic Content you need an Apple TV extension. To include a layered image in the content use the Apple Parallax Previewer app to load all the images in the layered image, and export as an LSR file. Drop the LSR into an Apple TV Extension target. Use the code below to create a scrolling inset (rather than a sectioned one as in the RW tutorial). Then read in the file from the app bundle.
Note that the Top Shelf will "scroll through" your images so you probably want 3 related layered images (as the above answer suggests). You can see what a single image looks like (pretty lame) in this video.
import Foundation
import TVServices
class ServiceProvider: NSObject, TVTopShelfProvider {
override init() {
super.init()
}
// MARK: - TVTopShelfProvider protocol
var topShelfStyle: TVTopShelfContentStyle {
// Return desired Top Shelf style.
return .inset
}
var topShelfItems: [TVContentItem] {
let v1Ident = TVContentIdentifier(identifier: "V1", container: nil)!
let v1Content = TVContentItem(contentIdentifier: v1Ident)!
v1Content.imageURL = Bundle.main.url(forResource: "v1", withExtension: ".lsr")
// Create an array of TVContentItems.
return [v1Content]
}
}

Vertically align components by baseline in a QHBoxLayout

I'm using Qt Designer to lay out a form with QLabel, QLineEdit and QComboBox controls inside of QFormLayout and QHBoxLayout containers. What do I need to do to have the controls aligned vertically by their text's baselines?
When previewing the dialog on Max OS X, the different controls do not align by their baseline. The following example is using QHBoxLayout, but the same happens with QFormLayout:
Notice how the underscores are not on the same vertical position.
I'm looking for a solution that will work with all widget combinations where baseline adjustment is applicable and where the adjustment is done automatically based on style, platform, widget combination, widget sizes and font settings. Something comparable with CSS's vertical-align: baseline;.
Update
I've done the same test on Windows XP and also applied RA.s suggestion of using a style sheet. But that does not seem to change any of the placement of the controls or their text.
If I understand your question correctly, you need to change the vertical alignment of the QLabels. In Qt Designer, you can accomplish this by clicking on the QLabel, then adjusting the label's alignment property. In this case, I believe that changing the vertical alignment to AlignBottom might fix your problem. If that doesn't work, the label also has a margin property that you can adjust.
Update
Consider using Qt's style sheets for your application. The following style sheet achieved the desired result on the platforms that I could test on (which, unfortunately, does not include OS X):
QLabel, QComboBox, QLineEdit
{
background-position: bottom;
}

wxPython Button Background Image

Can I create a button with text with a background image? In wxPython, there are certain functions which create buttons such as wx.lib.buttons.GenBitmapTextButton and other functions like that. I'm wondering if I can create a button with a fancy background image, as well as label text.
There is no built-in button that allows a background image underneath the text. You can probably look at one of the generic button widgets though and use them as a template. Basically you just need to draw the bitmap on and then draw text on top, probably by using wx.DC or wx.GCDC or similar. The generic buttons include such things as wx.lib.buttons, wx.lib.agw.aquabutton and wx.lib.platebtn among others.

Resources