Programmatically save PyQt Widget as image - python-3.x

Trying to use python to programmatically save a PyQt5 QWidget as an image (any format)
Came across a solution here, but this solution more or less saves a screenshot of the widget window, which demands the widget window to be open in the first place
What I'm trying to do is to get the widget to be saved without the GUI window being generated/shown on screen
So to be more precise:
Widget is created with script
Created widget is automatically saved without the UI popping up or external interactions
The widget I'm working with can be found here

Related

Upload an image to a label when a button clicked in tkinter

I'm building a GUI using tkinter(python 3) which every user should be able to click a button and open a file dialog, Then select an image. And the selected image get displayed on a label.
I have tried numerous possible code but I still can't get it.

Multi-window application

I want to create a application in python using wxpython library with multiple windows which will be inter-related to each other using buttons, i.e. we can go from one window to other and again come back to the previous window using buttons just like an app.
There should be one window on the screen at any time if possible. Is this possible using wxpython library. If so then can you suggest me how.
It is really simple. Normally you create one window (usually a frame or a dialog). If you want more windows, you will just create more frames or dialogs.

Qt Dockable windows snap to initial size when application central widget modified

I am building an app using pyqt5, where I have a central widget and several dockable widgets. The central widget consists of a QTabWidget and a pyforms ControlPlayer widget.
Whenever I resize any of the dockable widget and switch a tab in my QTabWidget, the dockable widgets get resized to their initial sizes. However, if I float around one of the dockable widgets and dock it right back then they don't resize, which is desirable for my application.
Can someone explain to me what is happening here? My guess is that some flag is being set on the central widget when I float the dock window, but I'm not sure which one
I came across the same in the manner: resized QDockWidgets snap back to their original form after the MainWindow is resized or something in my dockwidget is changed
(in my case: when tabs change within the dockWidget.)
This is, unfortunately, a bug and is not your fault.
I didn't find any fix for PyQt. The C++Community has a fix ready, but I guess I'm just to inexperienced in python to transfer that, since the self.resizeDocks doesn't seem to take my arguments.
see also:
https://bugreports.qt.io/browse/QTBUG-65592
or
QDockWidget splitter jumps when QMainWindow Resized

Updating QListWidget and QtreeWidget in a QMainWindow PyQt

I have a QMainWindow that creates a QListWidget and a QTreeViewWidget and places them in a QDockWidget. I then have an "open" action in the menu bar. When clicked it gives a dialog were you choose a pickle file to load. Upon opening i need the information to be loaded into the QTreeView and QListWidget in the QMainWindow. However, since the widgets were already instantiated upon opening the program they don't update. Everything works fine if i choose a file before the program actually starts. Everything also works if i close and reopen the widgets after i choose my file. So, is there some way to update the QMainWindow to show the updated information after opening a new file?

PyQt4 Qt Designer making dynamic GUIs

I'm trying to figure out a way of using Qt Designer to make a dynamic GUI. For example, let's say I have a main window with a horizontal layout. I have a push button on one side and an empty area on the other. When I click the button the empty area will be filled with a widget that I've made in Qt Designer. When the button is pressed again the widget will be replaced with another widget that I've made in Qt Designer. Would I have to go about making all my widgets, to fill the empty area, custom widgets?
I've tried setting the parent to the empty are, but on the second change I get this
QLayout: Attempting to add QLayout "" to QWidget "t2", which already has a layout
So then I tried deleting the layout but still see the old widget underneath the new one and the layout is now messed up.
help please
Never mind, figured it out. Simple really. Use QStackedWidget and as for the UIs made in Qt Designer wrap that in a class that inherits from QWidget.

Resources