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()
Related
Using wxPython, is it possible to nest a combobox inside other combobox in a similar way to how submenus are nested within menus? I need something similar for a wx.Combobox or a wx.Choice.
Or is there any widget with which this can be done?
Well, there are some possibilities:
wx.lib.combotreebox.ComboTreeBox
wx.combo.OwnerDrawnComboBox
# possibly also:
wx.lib.popupctl
You might also use a button (or some control) to invoke a PopupMenu. It may be confusing for the user though, and you might get into trouble when trying to position the Popup menu correctly. Generally speaking, I advice not to be too creative when making UI.
Have you seen wxpython demo? It is a nice showcase of all possible widgets. You can obtain it from here: https://extras.wxpython.org/wxPython4/extras/
What's the best approach to mimic the Windows Explorer navigation bar in PyQt?. Perhaps a list of QComboBoxes as part of a parent class that concatenates the current item of each combo box to resolve the final path?
Is it possible to get a similar look by using stylesheets?
This is the object I need to mimic. I just want a theoretical approach about the best way to mimic it.
Thanks in advance
This is technically known as a breadcrumb widget.
There are multiple approaches to this. The closest emulation to Windows Explorer's behavior--leaving out the normally hidden line editor--involves a chain of widgets like so:
A top level parent QWidget-derived class with your implementation, which would have:
A QHBoxLayout
An arbitrary number of QComboBoxes
A QFileSystemModel from which to populate the combo boxes.
Alternatives
You could use a single QLabels with a series of hyperlinks divided by path separators if you don't care about drop-down behavior. Qt Creator does this.
If your data source is static and not as gigantic as the filesystem, you could use QToolButtons backed by a tree of QAction/QMenus. This is possibly a masochistic approach, given that you have to populate all of the actions and menus. Since that's what they are there for, though, it might be handy as part of a context-sensitive menubar or tab bar.
I was looking for such a widget too without any luck. So I've tried to implement this by myself. It's not finished yet and needs some more work, but here's the first result: breadcrumbsaddressbar.
It's based on QToolButton widgets with menu. Parts of address which don't fit are hidden like in Windows Explorer. Also the widget has auto-completion feature.
Update: there's also a C++ widget QtAddressBar which I have't tried.
I have a TextArea in my application that actually takes no interactions from the user.
Is there a way to either
Remove the scrollbar entirely and let me handle what happens when the scrollbar would appear?
Use a different object to display text to the screen? I need to be able to append text, but I don't need it to be highlight-able or take any user input.
According to your needs, you need to use label.
If you need TextArea, to remove scrollBars, you can do the next :
Use lookupAll(java.lang.String selector) method to find scrollBars, and
call scrollBar.setOpacity(0.0) for each found scrollBar.
2a. Don't call setVisible(false), as visible property (I believe) is used to TextArea to control scrollBar visibility.
I am trying to create a dockable window in Qt (it sits taking 4px width at the edge of the screen, always on top and it slides out when you hover it). I have to use WindowFlag BypassX11WindowManager (in order to hide taskbar hint, disable moving/resizing/etc. from window manager). I use these flags:
Qt::FramelessWindowHint
Qt::CustomizeWindowHint
Qt::X11BypassWindowManagerHint
Qt::WindowStaysOnTopHint
When I need my dock to be activated, I use the activateWindow() method. However, I have no idea, how to deactivate it.
Is there a way I can force my window deactivate? Now I can do it only by clicking another window and then return to the one that was active before revealing dock.
You should be able to use ->hide() to simply hide it if you don't want it to appear at certain points.
I assume, by the way, you know there is QDockWidget/ class that may help you as well. It's unclear from the above if you're using it or not.
I am trying to apply custom menu to tab pages on my notebook control. I need to be able to select certain specific action for the entire page and i figured the tab label would be the best place to start.
So, i created a EventBox, applied Label as its child, and bound event callbacks to button-pressed-event and it... works.. kindof.
What i get is two menus: one is the one I create, and on top of it - the one created by GTK Notebook. to select something from my custom menu i need to escape the notebook menu first, and i certainly don't like it.
so the question is: how do I disable gtk notebook menus? or how can i set my own, custom menu, with my own, custom callbacks? I don't want to list all the available tab pages in the menu - it's introducing too much noise, so adding menu labels to the existing menu is not really the way to go.
thanks bunches
GtkNotebook should only show the tab selector if enable-popup is true. It defaults to false, so you've probably enabled it by mistake.