couldn't find anything with google or search.
I have some QPushButtons and QLabels in a QVBoxLayout. Now I want them to scale down. Not only the text, the hole QButton and QLabel. Is that possible? If yes, can you please tell me how or post me a link to the doc. I'm pretty sure, that there must be a way. But I think I'm searching with the wrong words.
Not sure what you mean, but perhaps you're looking for QBoxLayout::addStretch? By the way, I recommend using Qt Designer to create your layout, PyQt4 comes with a tool called pyuic4 that creates the Python code for you. Qt Designer allows you to visually insert spacer items.
Related
I want to write something like a taskbar/dock/panel(like tint2,...) with pyQt5.
I know how to write regular GUI applications with it, but my tiling window manager(herbstluftwm) maximizes my panels and openbox makes them resizable etc.
My question : How can I make pyQt show my application as a panel instead of a window? I haven't found anything about that in the documentation.
Thank you.
Thanks to musicamente's help, i could find that the function setWindowFlags() is what I need. It allows to change the behavior of a window.
A website explaining this function is https://pythonprogramminglanguage.com/pyqt5-window-flags/
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 used Designer to create the layout for my gui. I need to be able to have QLabel that is part of the main GUI cycle through a couple of different, newly-created images while the GUI is running. There must be a way to do this, right? Whenever I look up how to do that, I only find ways to add an image to Designer, then pyrrc the qrc file, and you know the drill. But there must be a way to add an image while avoiding all that.. right?
There is, actually. Find the label you want. Let us say the label is label_1. Then, in your MainDialog class (or wherever), use QPixmap like this:
self.label_1.setPixmap(QPixmap("img.jpg"))
That should work. Good luck!
When using tkinter to create a more modern looking application, I looked to MS Word to inspire my design. Then I noticed that only when I'm using the application on a High DPI device that it looks so terrible.
Is there a way to compensate and make it look just as crisp?
NOTE: "Don't use tkinter" is not on the table.
The best solution I have found for this is to create a custom widget using the WCK (Widget Construction Kit). Text displayed using this is automatically Anti-Aliased.
Try typing this at the beginning of your code
try:
from ctypes import windll
windll.shcore.SetProcessDpiAwareness(1)
except:
pass
I think this will solve your problem.
I found a library, this library supports vertical scrolling cards, I want to change this library according to my needs (Horizontal scrolling).
Can anyone suggest how to implement Cards just like the mentioned library cards horizontally.
Guys I just found a library, which helped me to solve this issue.
Carousel Library
Best Library I found which I customized for my project:
https://github.com/applm/CarouselWidget
Other helpful libraries:
https://github.com/davidschreiber/FancyCoverFlow
https://android-arsenal.com/details/1/3289
I hope, this answer may help you in finding solution.
As I always suggest to ask an author and this time I'm the author of this library, I'll tell you what to do.
RecentsList is very simple and the only place you have to change is here: https://github.com/ZieIony/MaterialRecents/blob/master/app/src/main/java/tk/zielony/materialrecents/RecentsList.java#L127 . This method layouts cards inside container. You have to write your own layouting logic.
Why I don't implement that change? Because I'm not sure what do you mean by horizontal cards. Lollipop in landscape orientation shows vertical cards (at least the one I have on my desk).
The second reason is that I think I should rewrite this library from scratch. It was just an experiment with custom layouting code. Correct implementation would use view reusing and recycling just like RecyclerView and ListView do.