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

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

Related

How to create custom drawn columns in or alongside tree view?

A picture is worth 1000 words, so here is what I am trying to achieve:
In words, I would like to add a column to a tree view in which I can draw vertical connecting lines between certain rows of the tree view. This should work both when the tree view is scrolled, as well as when children of a row are expanded or collapsed.
First question: Is it at all feasible to do this within a ttk.Treeview? Since a tree view brings along all the additional functionality that I need, specifically for everything to the right of the connections column, I would prefer making use of it.
If not possible completely within a ttk.Treeview, how could I keep a separate canvas widget to the left of the tree view in sync with the tree view (row height, scroll position, collapsed/expanded children)?
Finally, if even keeping a canvas in sync with a tree view is not feasible, do you have an alternative suggestion regarding widgets and layouts in order to achieve this. Are there examples of using a grid layout to mimic the functionality of a tree view (expandable children, resizable columns)?

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

How to Reorder Elements Vertically Glade + Gtk?

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?

Splitter window display issue

I am writing a program which has a TreeCtrl on the left and a RichTextCtrl on the right.
Following is the code of the splitter, panel and other elements.
The problem is that in windows, the bottom of the treectrl and textctrl is hidden. The statusbar covers the bottom of the splitter. But even after removing the statusbar I cannot see the bottom of the treectrl (hides up to 6 rows).
self.panel=wx.Panel(self,wx.ID_ANY)
self.splitter=wx.SplitterWindow(
self.panel,-1,size=wx.DisplaySize(),style=wx.SP_LIVE_UPDATE)
self.splitter.SetMinimumPaneSize(5)
self.datatree=wx.TreeCtrl(self.splitter,1,style=wx.TR_HIDE_ROOT|wx.TR_ROW_LINES)
self.display=wx.richtext.RichTextCtrl(
self.splitter,1,style=wx.VSCROLL|wx.HSCROLL|wx.WANTS_CHARS)
self.display.SetFont(self.displayfont)
self.handler=wx.richtext.RichTextXMLHandler()
self.splitter.SplitVertically(self.datatree,self.display)
self.logger=self.CreateStatusBar()
I think the issue here may be that you've explicitly told the SplitterWindow to take up the entire display size. Try omitting the size argument to the constructor, or adjust it down some, to see if that has any effect.
If omitting the size parameter does not help, I'd suggest creating Panels with Sizers that contain your Tree and your Rich Text Control, then splitting those Panels vertically within the Splitter Window.

Allow a ToolItem to fill horizontally in a Toolbar

SO.
I've been busy working on a project in python and pygtk. I want to have (at the top) a "Toolbar" with back, forward etc. buttons and a long Entry that would take the rest of the horizontal space. I don't get the desired effect, however, as the space the Entry takes is quite limited.
self.omnicont = gtk.ToolItem()
self.omni = gtk.Entry()
self.omnicont.add(self.omni)
I've tried set_child_packing (which doesn't apply to Toolbars, it seems). I couldn't find any other way.
The buttons I have are declared in this way:
self.bBack = gtk.ToolButton(gtk.STOCK_GO_BACK)
and similar, so I don't think it's possible to put buttons like this in an HBOx.
How can I have the Entry take all the available horizontal space and, if that's not possible, how could I get an HBox to contain buttons with the stock icons?
Accordingly to the docs you can use:
set_expand(True)
on the item you want to expand.

Categories

Resources