PYQT Taking a screenshot of a hidden QWidget - pyqt

I have a QTabWidget with different tabs.
I want to take a screenshot of a hidden tab.
I found out how to create a screenshot of the tab if it's selected now.
The problem is that I want to be able to do that even if another tab was selected.

The solution was very simple in the end, I hope it would help someone if he needs to.
To capture a screenshot of a widget you have in your application, even if it's not currently visible.
For example if you have a number of tabs in your QTabWidget:
# tabs_hash is a dictionary of the widgets we have in the QTabWidget,
# or any widget we have in the application we want to print
for name in tabs_hash:
file = f'{name}.jpeg'
tabs_hash[name].grab().save(file)

Related

PyQt: How to hide everything? (whole application)

Is there a simple way to hide all widgets (essentially hide the whole application)? There are multiple windows and widgets not attached to any window. I'm assuming it's some sort of modifier to the QApplication([]).
EDIT:
Better wording of my question thanks to #eyllanesc:
hide() method that prevents any window (or widget) from showing after using it and you also want the "show" method restore to the previous state.
A possible solution is to iterate over the top level widgets using QApplication::topLevelWidgets() and hide it:
for tl in QtWidgets.QApplication.topLevelWidgets():
tl.hide()
# or
# tl.close()

How do I make a window draggable without a header?

So basically I have this main window with just a bunch of buttons on it. I am hiding the default header by using self.set_decorated(False). I want to be able to drag the window around my screen by clicking anywhere that's not a button. Is this possible? I haven't been able to find anything on this except for self.begin_move_drag(self.button_drag, event.x_root, event.y_root, event.time) which I don't really understand.
hb.props.custom_title = Gtk.Label(label=" ")

pyqt context menu with multiple qlineedit widgets

I hope someone can help me out with this.
I have a pyqtgraph context menu and want to add my own Z-Axis. I can create a qlineedit widget but I am not able to create multiple widget on the same line in the context menu as show below (e.g. radio button and 2 text boxes on same line)
As a minimum I would like to achieve:-
Z Axis -> [input value], string, [input value]
I've had a look in qmenu but couldn't find what I needed. Anyone know how to achieve this.
Also if anyone knows how to change the size of the X Axis qlineedit boxes and make them bigger it would be great as they are a bit squashed as you can see.
Someone on a different forum was able to help me with the answer so I thought I would also post it here for future users.
What you have to do is go into the site-packages for python and find pyqtgraph/graphicsItems/ViewBox/. In there are several files called
axisCtrlTemplate_*.py
A couple of lines down in the ui_form is the following line which you just need to increase the width (e.g. 450)
Form.setMaximumSize(QtCore.QSize(450, 16777215))
Hey presto fixed.
Also in the same location is a file called
ViewBoxMenu.py
you can see how the context menu is written here and I will use this information to create my min and max values which are created in a ui (qtdesigner) and then added to the menu

Menu items are not shown in SherlockFragmentActivity with tabs

My application runs on Gingerbread. It can properly show action-bar menu-item in normal SherlockFragmentActivity but when I add a menu item in an Activity with tabs the item is not shown. I was expecting to see the item above the tabs on the right of the name.
Is that normal or I'm doing something wrong?
I can add normal options-menu item that are properly show in the menu.
So the main question is: did someone manage to show both the tabs and the action-bar?
You're doing something wrong. Including other menu options doesn't have any issue. If you're using the actionbar spinner, then it's a different case as that wont work with tabs.
try adding the item in PrepareOptionsMenu in place of CreateOptionsMenu
I hope this will work

GXT, how to display the widgets labels with a VBOXLayout

I have been trying to resolve this by myself but I can't find any answers. I need the text fields the combo box, etc., to display its own label, but I can't put it to work on a panel different from the FormPanel (in which all works great). I'm trying to display the labels for a text field on a VBoxLayout but I don't find the way to do it.
I need to work with a VBoxLayout because I need the widgets to position in the middle of the form after the window is maximized or minimized and this layout is the only one that proves to work. Is there another way to accomplish this?
Add another LayoutContainer and then set the panel to use FormLayout for example
LayoutContainer innerPanel = new LayoutContainer();
innerPanel.setLayout(new FormLayout());
Now it will work just like a form panel.

Resources