wxPython Create a LabelTool without adding it to a Toolbar - python

I want to create a ToolBarToolBase object without adding it visibly to the toolbar. I've tried instantiating ToolBarToolBase, but I'm using wxPython version 2.8.12.1 (I can't upgrade, I'm doing this for work) so I don't think it's fully implemented. Is there any way to do this?

No. That widget is part of the toolbar. Just use a BitmapButton or a PlateButton. They both support images and would be more flexible to use anyway.

Related

Qt Designer / PyQt - dynamically duplicate a tab widget with embedded widgets intact

I have C# experience, and I'm making my first Python app. I'm part way done the UI in QT Designer, and soon I'll try PyQt to integrate it with my code. This is a general guidance question for best approach.
I have a tab widget containing various things in each tab. I would like the entire tab widget to be duplicatable with a plus button. So basically, a scroll view containing as many of these tab widgets as the user wants. The user could duplicate an existing one as a new instance, or create a blank one.
Could someone please help me understand how to accomplish this? Does it work like this?
Create the scroll view.
Put the tab widget inside the scroll view.
Add duplicate and delete buttons in the corner of the tab widget.
Put a plus button just outside the scroll view.
Accomplish all of the rest via python code? Or would I be missing out on some Qt Designer tricks?
Any tips on how to do this in QT Designer and also coding in PyQt would be appreciated.
Additionally, perhaps off topic, but any general tips on PyQt installation and usage would be nice. v5 not v4? I'm running Python 3.6 32 bit, which I was told should run 3.5 packages fine (but 64 bit may not).
Thanks,
First the out of topic : use PyQt5 if you start a new project. Qt 4 has reached end of life and won't see any new release unless it's a critical security fix.
As for most of your questions: if you want to use Designer then you should start by taking a look at Qt Designer's documentation. It will get you started nicely.
As for 5, it depends on tastes. Developers have been using both for various reasons. It's really up to you decide which style fits your needs best. There's no tricks in designer that you can't accomplish in code.

Gtk HeaderBar doesn't expand children

I'm using Gtk to build an application on Linux using Python 3. I'm trying to use a Gtk.HeaderBar. So far it's been working Ok, but it seems that I can't get it to expand it's child widgets. For example:
As you can see above, I've tried putting my Gtk.Entry into the Gtk.HeaderBar, but even with things like Gtk.Entry.set_hexpand(True) it simply refuses to expand. I've even tried putting it inside a Gtk.Box, expanding the Gtk.Box, then adding the Gtk.Entry inside that. Even when I set the Gtk.Entry as a custom title for the Gtk.HeaderBar, this happens:
What's causing this? How can I fix it?
Enabling hexpand only says that you want the widget to be allocated all the remaining space; it does not actually resize your widget. You want the halign property set to GTK_ALIGN_FILL (or whatever it's called in Python) in addition to hexpand.
Check the diagrams on this page for a visual explanation.
You can use Box instead of Headerbar with window.set_titlebar method

How to get multiple panels in one window - GTK+

I am looking to know what is the best practice to make a window which the content changes, but without changing the window. Something like using tabs, but with no tabs, controlled with buttons.
What widget should i use to archive what i need?
And if you don't mind the little off-topic, should it be drawn manually or with a GUI designer like glade?
It is meant to be used within python.
If you can use GTK 3.10, take a look at GtkStack and GtkStackSwitcher. If not, use GtkNotebook and set the show_tabs property to False, then build your own buttons.

Using wxCode widgets (like wxScintilla, wxPlotCtrl) in wxPython

Good day all.
I am writing my open source application in python and chose wxPython for gui.
And I mentioned that wxWidgets has excellent set of custom controls called wxCode: (http://wxcode.sourceforge.net/), therefore I have a question:
Is there a way for using them with wxPython?
Yes.
Scintilla:
http://www.wxpython.org/docs/api/wx.stc.StyledTextCtrl-class.html
http://www.yellowbrain.com/stc/index.html
wx.lib.plot:
http://www.wxpython.org/docs/api/wx.lib.plot-module.html

Can I add a label to a single tool in a wxPython toolbar?

Does anyone know if it's possible to add a label to a single tool in a wx.ToolBar? I've found a global setting but no option to set it for a single tool.
I have a feeling that's a limitation of the native widget. It's an all or nothing affair. You could make the label a part of the image on the tool item though. Or you might be able to do it with FlatMenu which has a Toolbar widget equivalent that's written in pure Python, so you can hack it. See the wxPython demo for an example of its API.

Categories

Resources