Grouping multiple buttons with absolute positioning in a layout - python

Is it possible to group buttons that are arbitrarily positionned with PyQt ?
There is the context :
I would like to code a visual programm to control a research system with specific geometry, through Python.
I expect this kind of result :
In this program, the buttons of "buttons group 3" are positionned is a specific geometry that does not fit in a grid. Those buttons are clickable and a click on them change their color.
I would like those buttons to be grouped together, in something like a layout, because it seems to be that it is coherent in order to change positions and sizes of layouts and window if needed.
I'm coding that with PYQT5,... but I cannot figure in PyQt5 how to code this group of buttons with specific geometry ?
Is it possible to group buttons that are arbitrarily positionned with PyQt ?
Thanks in advance for your advice, I feel I'm missing something in PyQt concept.

Related

Exporting data and graphs from a python GUI into a single file

I have made a GUI with qt designer and python. In this GUI i have multiple tabs. In some tabs i display a matplotlib widget and in some tabs i display a textedit. After pressing a button lines will be plotted in the matplotlib widgets and in the textedit some data will be displayed. How can i get these matplotlib graphs and the data from the textedits into one file after pressing an 'export' button?
The question doesn't specify many constraints, but if one big honking image is sufficient, you can take snapshots of the relevant widgets using Qt5 or Qt4 and just tile them into gigantic image:
After calling QWidget::grab or Pixmap::grabWidget, find the most reasonable layout for all the widgets and calculate the total size. Then create one gigantic QPixmap and render them via QPainter::drawPixmap to the appropriate coordinates into the combined image.
Of course, this seems pretty ugly and questionable to me, but I'm not one to second-guess what you want to do either... just know that I realize this is kind of icky.

Tkinter Python: Bar Gauge?

I am trying to find an effective way to create a bar gauge in Tkinter. I've been using labels inside a frame and changing the background color to indicate the level, but this is extremely inefficient as it involves ten if statements, each with ten lines of code, for each gauge. Would anyone be kind enough to point me in the right direction for how to do this?
Thanks in advance.
from the sounds of it you are simple after a progressbar, there are two such widgets in tkinter, one is part of ttk and the other is tix, they function much the same but the styling is different, and both of them can be linked to an IntVar and simply setting the value of the IntVar sets the progressbar.
1) ttk.Progressbar
see here
2) tix.Meter
see here

PyQtGraph : how to change size (height and width) of graph in a ScrollArea

I'm trying to plot graph in a scroll area but I've no idea how to change the size of my graphs. Here is an example of what I have:
As you can see, in my ScrollArea (in Red) which as the size I want, I have a graph (well, in reallity I have more graphs and I want to see more then one (at least two) in this area).
So, I want the height of my graph (A) to be smaller and the width of my graph (B) to be expanding. Somine can help me ?
Thanks for your help !
It looks like your plot is inside a layout with the "Hide EMG" button. The widget holding that layout must be resized to fit the scroll area. You'll need to provide a code sample if you want more help than that..
Also consider using pg.MultiPlotWidget, which already provides similar functionality.
Adding to Lukes comment: A PlotWidget, which is probably what we see there, is a QGraphicsView, which is a QWidget. This is layed out using Qt. I'd recommend you to play a bit with Qt Designer to get an intuition on how the layouting works.
Another resource would be: https://doc.qt.io/qt-5/layout.html
For your explicit problem, if you do not want to get into Qt layouting, you could use QWidget.setMinimumHeight and QWidget.setMaximumHeight to confine the widget vertically. For the horizontal part, that totally depends on what you are doing there. If that was a grid layout, I'd refer to e.g.: Expanding only one column in a QGridLayout

Python Plotting and displaying multiple objects in same GUI window

I have a 2 part question:
what is the best method for plotting data in Python? I only need to plot data in 2d.
I have a canvas GUI that I built using Tkinter's canvas function. It draws an 8x8 grid of rectangles and also has some code to allow you to scroll the window. (I've attached a picture).
Is it possible to include a plot in the same window as this canvas object? I need to be able to display plotted data and hopefully add buttons to my GUI that will allow me to update the plot during the run of the GUI.
Thanks in advance!
Matplotlib is the de-facto way to plot data with Python. It's really wonderful. It can also be embedded in Tk.

embedding grid in panel in wxpython

What is the proper way to embedd grid (wx.grid.Grid) into the panel? I tried the following code and got bizarre frame:
wx.Frame.__init__(self,wx.GetApp().TopWindow,size=(600,800),title='Material Properties')
self.GridPanel=wx.Panel(self,-1)
grid=wx.grid.Grid(self.GridPanel,-1)
grid.CreateGrid(10,10)
I cannot see an easy way to create a grid which can also have buttons as well as menubar and other related widgets. Is there any example which shows GUI of how to implement wx.grid to achieve some sort of spreadsheet which has tabs on it for manipulation. I seem to be lost on this.
I want to create two different grid and also want to add some buttons and additional functionalites to the frame containing the table. Is there any better way to do that in wxpython?
I wrote about grids quite a while ago on my blog. You might find the following articles helpful for putting a Grid onto a Panel:
http://www.blog.pythonlibrary.org/2010/04/04/wxpython-grid-tips-and-tricks/
http://www.blog.pythonlibrary.org/2010/03/18/wxpython-an-introduction-to-grids/
Once you have that figured out, you can easily put the panel into a Notebook. If you want to add buttons, create the buttons and then add them to the sizer (see second example). Adding a Toolbar to the frame is covered in the wxPython demo, but I covered it here too:
http://www.blog.pythonlibrary.org/2008/07/02/wxpython-working-with-menus-toolbars-and-accelerators/

Categories