How to Reorder Elements Vertically Glade + Gtk? - python

I'm using Glade to design a UI, and I'm struggling to figure out how to reorder elements such that one element is on top of the other vertically. As an example, I added a draw element after a slider, picture, but I want to still be able to touch the slider through the draw element. Beyond reordering things manually in the XML/.glade file, how would I move things around such that the draw element gets "drawn" first with the slider on top of it?

Die clarification. So far i See from the picture (I dont understand the Text), you create radio buttons and in one type of it, you want to dynamically letting a new window area appearing with a slider in it when clicking?

Related

Tkinter button with both left and right aligned text

I would like to create a button where the title is left aligned and then a value with units that is right aligned.
I need to be able to press it in ordre to open a new frame for changing the value.
I haven't been able to find a solution..
I have also tried to create two labels and then placing them inside the button but with no luck.
Any good solution is more than welcome.
Picture

How to move canvas drawn shapes to have a fixed position on screen?

I have a GUI that I've made in tkinter using a canvas that has a bar along the left side and a bar along the top containing information. In the remaining area various rectangles are drawn corresponding to the information in those bars I described. The issue is, when you scroll away on the canvas, those events will leave as well.
Basically, I want to create a visual effect like position: fixed is in CSS where these bars on the side and the top stay in place relative to the rest of the canvas so that they don't move from their relative position while scrolling.
I tried making use of the scrollbar commands, but have had trouble making my own function there. I also tried to see if there was an event I could bind to the canvas to track the movement so that I could move the bars myself but I could not find anything.
There is no way to do this directly in the canvas unless you write the code to move the items in the top and left whenever the user scrolls. It would probably require a fair amount of work.
However, it's trivial to have separate canvases for the side and top that do not scroll, and a third canvas that has all of the scrolled data.
I was able to end up solving my own issue by adapting the solution from: How can I add Unscrollable Image to a frame/Canvas?
Simply put, I made my own yview and xview functions that would scroll my desired "bars" with the window by moving the objects.
Special thanks to #jasonharper for his help.

PyQT how to change layouts size

I am trying to make a GUI that is very similar to Spotify using PyQT
I've already designed the main window and I am struggling with applying the design to QT Creator.
This is what I want it to look like
But I'm trying to use Layouts in order to organize every widget.
For example
Image of the main window, split into 3 parts
like in the sketch I've made the software will be split into 3 parts, left bar, mid which is where the explore title is and right bar.
The problem I have is that I can't control the layouts size and the size of what's below them for example in the sketch the mid bar is wider than the right bar and the right bar is wider than the left bar but in the QTCreator I've no idea how to change the width and height of objects inside Layouts.
The first option (which I personally prefer) is to fill your layout with it's contents first (buttons, labels, etc.). This will already start to scale your layout, if there are more buttons in the middle bar than on the other bars. If your layout still isn't what you want it to be, you can use Spacers. They can push and pull puttons and position the in relation to other parts of the layout, as well as to the layout itself. The scaling will be adjusted automatically according to the spacers position.
This option has the advantage, that your application will be correctly scaled and not completely chaotic when it is run on a device with a display aspect ratio which is not the same as the one of the machine your developing it on.
There is, however, also a minimumSize and maximumSize attribute to the layouts, which provide a much more straightforward possibility, but sometimes cause your layouts to become very weird when adding or removing a button, or changing the text of a label. More on this option can be found in the Qt docs:
https://doc.qt.io/qt-5/qlayout.html

Using exact positions for PushButtons and still be able to scroll through them

First of all, check out this screenshot to see what I'm talking about.
Part A is much longer than shown (hundreds of rows - each row consisting of a label, 2 squares, another label and a checkbox). Now I want to add a scroll bar for part A, so all the rows can be viewed, while part B stays where it is.
It seems the solution to this is using layouts.
I haven't used them so far, simply because I didn't know they existed and I'm still not sure how they work exactly. I'm new to Python and PyQt (and programming, for that matter).
The problem with using layouts is that the squares in part A (which are PushButtons, btw) need to be positioned exactly (by pixels), instead of arranging them along a grid.
Is there a way to add a scroll bar for part A without having to use layouts?
-or-
Is there a way to give the squares an exact position within a layout?
I found a solution without having to use a layout. I put everthing in part A into a QWidget and put the QWidget into a QScrollArea. There may be better solutions, but this worked. The scroll bar doesn't have to be added manually. It appears when scrollContent is larger than scrollArea.
scrollArea = QtGui.QScrollArea(MainWindow)
scrollContent = QtGui.QWidget()
scrollArea.setGeometry(0, 0, 700, 600)
scrollContent.setGeometry(0, 0, 680, 25000)
# Here I add all the content. E.g. label = QtGui.QLabel(scrollContent)
scrollArea.setWidget(scrollContent)
I hope this is helpful to someone.

How can I add scrollable whitespace at the bottom of a QTreeView

When expanding an item at the bottom of a QTreeView, the view does not automatically scroll to show the newly-expanded items. I can fix this by detecting expansion and performing the scroll myself when appropriate.
However, I would instead like to allow the user to scroll the view farther than is currently allowed. Currently, if the tree is too tall to fit in the visible area, the view can be scrolled only until the bottom-most row comes into view.
I believe this should be doable by tricking the QTreeView's size calculation, but even after source diving I don't understand the interaction between QTreeView and its base QAbstractScrollArea well enough to know what to poke, or where to start poking.
If all else fails I may just add some dummy, non-editable rows to my data model.
you can add extra white space to the treeview by increasing its vertical scrollbar maximum value. Smth like this:
max = self.treeview.verticalScrollBar().maximum()
self.treeview.verticalScrollBar().setMaximum(max*2)
hope this helps, regards

Categories

Resources