How to use standard toolbar icons with WxPython? - python

I'm designing a simple text editor using WxPython, and I want to put the platform's native icons in the toolbar. It seems that the only way to make toolbars is with custom images, which are not good for portability. Is there some kind of (e.g.) GetSaveIcon()?

I don't think wxPython provides native images on each platform
but just for consistency sake you can use wx.ArtProvider
e.g.
wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN)

Related

Implementing replacement label for depreciate Gtk 3.10+ stock buttons in PyGObject 3.16

I’m using Glade 3.18 to design interfaces that I later load with PyGObject from the gi module to create a Gtk 3.16 user interface.
To have an example, let’s use the “OK” button. The reference manuals (for both Gtk 3 and GI) state that:
GTK_STOCK_OK has been deprecated since version 3.10 and should not be used in newly-written code.
Do not use an icon. Use label "_OK".
However, setting the label to '_OK', either programmatically using button.set_label('_OK') or in Glade (under the “General” tab, in the “Label with optional image” section), produces a button that displays “_OK” and not the expected “OK” and icon.
So my question is: what is the correct way to implement the proposed replacement for Gtk.STOCK_OK with PyGObject 3.16?
You should pack a Gtk.Image and a Gtk.Label inside a Gtk.Box, and pack the box inside the Gtk.Button. You should also use Gtk.Button.set_always_show_image() on your button, and Gtk.Button.use_underline() to enable the mnemonic for the _OK label.
box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
# image and label are defined elsewhere
box.add(image)
box.add(label)
button = Gtk.Button(use_underline=True, always_show_image=True)
button.add(box)
button.show_all()
In any case, you're strongly encouraged not to use an image or a generic label like 'OK'. Use a proper label describing the action, and avoid a pointless icon.
Stock icons and labels have been deprecated because they are not flexible enough for application developers. Stock icons do not cover the whole set of available named icons from the icon theme; stock labels are usually not expressive enough for users to understand, and they also have fixed mnemonics, which may collide in complex UIs (e.g. "_Open" and "_OK"), especially when it comes to translations.
Similarly, GTK does not provide a user setting to toggle the visibility of icons in menus and buttons any more; application developers and designers are responsible for deciding whether a menu item or a button should have an icon or not, as they are the ones responsible for deciding how the GUI should look and behave.
Application developers are strongly encouraged to use expressive labels in their UIs, and use icons from themes wherever that makes most impact.

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.

Python GUI with custom render/drawing

I am looking for a Python GUI library that I can rewrite the rendering / drawing.
It has to support basic widgets (buttons, combo boxes, list boxes, text editors, scrolls,), layout management, event handling
The thing that I am looking for is to use my custom Direct3D and OpenGL renderer for all of the GUI's drawing / rendering.
edit suggested by S.Lott: I need to use this GUI for a 3D editor, since I have to drag and drop a lot of things from the GUI elements to the 3d render area, I wanted to use a GUI system that renders with Direct3D (preffered) or OpenGL. It also has to have a nice look. It is difficult to achieve this with GUI's like WPF, since WPF does not have a handle. Also it needs to be absolutly free for commercial use.
edit: I would also like to use the rendering context I initialized for the 3d part in my application
I don't know what are you working at, so maybe this is not what you're looking for, but:
Have you considered using Blender + its Game Engine?
It supports Python scripting, and provides some APIs to create "standard" GUIs too, while allowing you to do a lot of cool stuff with 3d models. This could be especially useful if your application does a lot of 3d models manipulation..
Then you can "compile" it (it just builds the all-in-one package containing all the dependencies, in a way similar to what py2exe does) for any platform you need.
You can use Qt Scene Framework with OpenGL rendering. There are many examples on Nokia site.
The best Python GUI toolkit is wxPython (also known as wxWidgets).
This is not merely my opinion, see also: wxPython quotes
wxPython is the best and most mature
cross-platform GUI toolkit, given a
number of constraints. The only reason
wxPython isn't the standard Python GUI
toolkit is that Tkinter was there
first. -- Guido van Rossum
I can't say how easy or hard it would be to add your own renderer.
There are OpenGL bindings in Python that will get you 3D rendering. Personally, I'd use wxpython as your 'gui' manager and use the bindings to do opengl for the rest. Wx has the necessary demos (check the wxpython demos installation) and information in their GLCanvas demos.
Another sample code is here too.
You might find PyClutter useful.

Categories

Resources