pyqtgraph: how to prevent viewbox from stretching with view? - python

I'm trying to create a list of plots one below the other, on the same axes.
I want to be able to scroll through the plots, and when resizing the view I want to display more plots rather than enlarging the existing plots.
I subclasses PlotWidget and tried to manipulate resizeEvent and sizePolicy and nothing worked.
Any idea?
Thanks
Update:
This is the initial view. When changing the window's height I get this.
What I'm trying to achieve is this.
Also, I would like to add a vertical scrollbar instead of vertical panning.
Update:
Apparently pyqtgraph isn't a good fit for what I'm trying to do. I ended up implementing with QGraphicsScene and QGraphicsView.

Related

Black boxes around slider in wxpython GUI

I imagine this is a simple question and was hoping it someone would be able to help me figure it out. I have multiple wxpython sliders in my GUI but some of them have black boxes around.
The sliders are placed inside a StaticBox which is placed inside ScrolledPanel. It seems that those that are on top (i.e. are shown without the need to scroll the panel) look normal, as for the 'Annotation font size' but the ones that were hidden have black background behind it. Anyone has any ideas?
I thought it was because I was not calling Layout() but it doesn't make any difference.
I managed to fix this problem on my side. Maybe it helps you too. In my case, I have a lot of text boxes and sliders on a scrolled panel (wx.lib.scrolledpanel.ScrolledPanel):
Black boxes around sliders:
I am fixing it by setting the background color of the panel after I have finished populating it with graphic elements:
self.SetBackgroundColour('WHITE')
Here is the result:
No more black boxes around sliders:

matplotlib gui respond to axes changes

I have created a little GUI with QT which set's up a single matplotlib figure and axes.
The GUI has controls to change just about everything to do with the appearance of the axes.
Basically, it does this by each widget emitting signals back up to the main frame and it calls the appropriate matplotlib setters on the axes and figure objects.
However, it is possible for the axes (and therefore the image displayed on the FigureCanvas) to change without input from the GUI (e.g. when autoscaling, or adding certain plots which adjust the axes automatically).
In this case, a widget controlling e.g. the limits of the x axis will now be displaying the wrong values.
I would like all the relevant widgets to update when the axes updates....how could I possible achieve this?
I'm thinking that this is a problem that has been solved before - how to enable a two-way communication between distinct objects?
fig.canvas.draw()
time.sleep(1e-2)
whenever anything writes to the plot? however it's hard to help with no code.
Showing an example of how your code is not working would help a lot.
EDIT:
I'll try this again then:
What about getting the state of the plot you are updating? I guess its what #Ajean means by updater method. I know that Artists in matplotlib have an Artist.properties() method that returns all of the properties and values.
I imagine Axes would have a similar method.
A quick look at the matplotlib docs yielded 2 interesting methods of axes:
ax.get_autoscale_on()
and
ax.set_autoscale_on().
ax.set_autoscale_on(False) will prevent plots from updating the state of the axes.

how to create an overlaying frame with qt4 in python

I would like to know if it is possible and how to create an overlaying frame (or any other widget) at a fixed position that would overlaying the content of the MainWindow with PyQt4.
The idea is to get a html-like render we can get with position: fixed or position: absoute. From what i know, all widgets have to inherit from the MainWindow's widget but is there a way to change this behavior or any way to simulate a widget with such level ?
Thank you
I suppose your problem is to insert an object inside a frame that uses a layout, and avoid respecting that layout.
I am afraid the only thing i can come up with in your situation is either to avoid using layouts altogether (but that's very uncomfortable) or to extend a layout class and place the frame outside of the layout.
To make your frame stay on top, look for z-order.
http://qt-project.org/search/tag/z-order

tkinter scale with two sliders?

Does anyone know if it is possible to have a single scale widget with two "sliders" from the tkinter module? Or anyway to fake it?
Such as (edited with GIMP):
I am thinking placing one scale on top of another scale, but with a transparent background?
No, you cannot do this with the scale widget. You can't give it a transparent background and stack them.
If I had to implement this functionality, I would use a canvas widget and draw my own sliders.
It's not very hard to do, but obviously it's going to be more work than an off-the-shelf widget.
Here is a custom widget using a canvas, made by MenxLi.
I think this might work: Range Slider Module
You can see how it looks,

Python : UI Image Wipe, compare two images

I wanted to know if anyone knew where to start in terms of recreating this sort of functionality?
http://www.learningnuke.com/wp-content/uploads/nukewipepreview.png
In the picture you can drag the centre line to reveal Image A or Image B or parts of each, interactively.
I want to be able to wipe/reveal across two images, maybe it's possible doing some sort of interactive crop of sorts.
Wanting to add this feature to a window in Maya, so maybe with QT, but not essential.
Just some pointers would be great.
I can tell you that this is possible via Qt/PyQt in maya. You can create a dialog that displays QPixmaps with some form of mouse interaction to control their display. I would forget about trying to extend the actual Render View as this would be a pain in the ass.
Just focus on a Qt solution. Unfortunately beyond this, I'm not sure what more I can offer unless you have a specific question about its implementation.
I would probably stack the QPixmaps on top of each other inside of custom QLabel widgets. The QLabel would have a custom mousepress/move event that would resize maybe the right edge to simulate the wipe effect, and reveal the one stacked underneath.
Also, it does resemble the functionality of a QSplitter so that might also work, with an image on each side of the layout and a custom style to the split bar.

Categories

Resources