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.
Related
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
I have a program with some Label() widgets, some Button() widgets, some Text() widgets, and a few Entry() widgets. A couple of revisions ago, I didn't have the labels, and I had less Entry() widgets, and I mixed .pack() and .grid() as was convenient and I was fine. I had to do some refactoring, and added the extra widgets in the process - all the new things added used .grid(). Nothing about the other widgets changed. Now, I get an error along the lines of "unable to use grid in .", etc. (I can post the full error message if necessary). Why, and how can I fix this? (I can post code if necessary as well.)
You can't mix grid and pack with widgets that share the same parent.
Why? Because grid will try to lay widgets out, possibly growing or shrinking widgets according to various options. Next, pack will try to do the same according to its rules. This may require that it change widget widths or heights.
grid will see that widgets have changed size so it will try to rearrange the widgets accirding to its rules. pack will then notice that some widgets have changed size so it will rearrange the widgets according to its rules. grid will see that widgets have changed size so it will try to rearrange the widgets according to their rules. pack will then notice that some widgets have changed size so it will rearrange the widgets according to its rules. grid will see that ...
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.
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
how do I put my menu bar buttons on menu bar's left ? Right now I pack() them with side=LEFT but still they're in the middle. Here's the code for my menu bar: http://pastebin.com/bgncELcb
I recommend against creating menubars a) with frames and menubuttons, and b) with menus in non-standard places. You should use the menu option of your toplevel window if you're at all interested in usability. However, since you specifically asked about menubuttons in the middle of a frame...
If you want something precisely in the middle, one thing you can do is break your menu into three sections, a left, middle and right. Place those three subframes inside your "menubar" frame. Use grid to give the left and right sections the most weight (and equal to each other, so the middle stays in the middle). You can then pack a button or buttons in the middle frame and they will remain in the middle.
Another choice is to use place, and set the relative X position to .5 and the anchor to "n". That is probably the easiest, though you can have problems with overlapping buttons if they don't all fit because the user resized the window.
The option you chose -- pack -- is the most difficult route to take. pack by it's very nature is designed to pack things along edges. Again, you can use three subframes, but pack isn't the natural choice here.
My advice: rethink why you want a non-standard menubar. Use a real menubar with menu buttons along the left like 99.9% of all other apps in the world. Your users will thank you.
What does menubar.pack(side=LEFT) give you?
Can you also try with menubar.pack()?