python3 tkinter or ncurses - python-3.x

I want to impliment some kind of UI for my Python programs (some simple operations, nothing advanced).
So I looked around and considered ncurses and tkinter for python. Yet I am not sure which of these two would suit best my needs for a simple interface (in the sense of easy to learn to program) with the best output possibilies. It does not have to be fancy or anything, just help me visualise my code (lets say a text based chess game).
intuitively i would take tkinter, but could you probably just summarise for me the advantages of the two UIs? (in addition ncurses does not seem to have a good tutorial for python...)
Thank you in advance!

I would like to suggest tkinter as it comes with python and compare to other GUI packages it has good tutorials. And also it will help you to improve your OOP concept for python

If you plan on using your application across platforms, Tkinter or PyQt are both good choices. If you want a GTK+ application that matches your GNOME environment and don't plan on using the application on other platforms, then I would suggest using GTK+ via gobject-introspection (from pygobject). In Fedora, you should have support for it out of the box. Other distributions may require the installation of additional packages.
For more information on the above bindings, see:
TkDocs
The Python GTK+ 3 Tutorial
(Sorry I couldn't post a link for PyQt because I don't have enough reputation to post more than 2 links.)
Additionally, it's worth noting that both PyQt and GTK+ have interface designers available so that you don't have to create your interfaces programmatically if you don't want to. For PyQt I believe Qt Creator comes with an interface designer. For GTK+ you have Glade.

Related

Tkinter Creations

Can anyone point me toward some of the more visually intricate / complicated examples of what can be done with Tkinter? Canvas based widgets and OpenGL please.
Thanks.
There are a couple I think might be interesting;
Py in my eye
tkDocs
There are a couple of things to keep in mind;
Tk is over 25 years old. On X11 it predates things like Freetype. It is still evolving though.
Tk is cross-platform. This implies that it generally cannot use the latest and greatest platform-specific tricks. It has to work with all the platforms it supports.
"Theming" and "skins" are relatively new in GUI toolkits. Some of them (GTK+ comes to mind) had to be re-designed internally to be able to use themes. Tk acquired theming support relatively recently.
Things like transparency are platform dependent, making it difficult for a toolkit to support it on all platforms. E.g. on X11 it requires the rendering extension.
It you want to do really graphics intensive stuff, a GUI toolkit might not be the best tool for the job. A games toolkit like pygame or OpenGL interface might suit your needs better.
There were samples in python-2.7.15 that could represent what you are looking for:
On my Linux install they are located in /usr/doc/python-2.7.15/Demo/tkinter
if you have python3 only, you could maybe look for an older version to download and install, see if the documents get installed.

How to develop GTK app with Vulkan for Linux?

I'd like to develop an application targeting modern popular Linux distributions that uses GTK for its UI, but also the Vulkan API to render a 3D model. Ideally I'd like to use the gtkmm C++ wrapper for GTK, and the Vulkan C++ API.
What ways do I currently have to do this?
I know that I can get a Vulkan context using SDL2 and other similar low level libraries, and I can get an OpenGL context using GTK. But I haven't found resources for combining these two approaches.
To start, I'm not limited to developing on or targeting any particular Linux distribution. Although any insights into why a particular environment makes this easier or more difficult are appreciated.
Edit:
I'm aware of this question: What is the Vulkan equivalent of the GtkGLArea widget (GTK+)?
However, many months have passed since its most recent update. My Google searching does not indicate that the state of affairs has changed, but I would like to be proven wrong. In addition, I intentionally phrased my question more broadly. I don't necessarily want just a GtkVulkanArea widget. I want to know of any valid way to combine Gtk and Vulkan. For example, is it possible to embed a Gtk event loop and widgets in an SDL2 window? What about the other way around? Again, my Google searching has not been very helpful, and I hope someone knowledgeable on this topic will answer.

Anjuta/Glade Tutorials or Better IDE?

I am attempting to develop a GUI application for Tails. I'm doing the initial development on Debian 8 since development directly in Tails can be a pain.
I started out using Anjuta, but the documentation is essentially non-existent. The Anjuta website has nothing at all about how Glade is integrated or how to use it. I can't even track down documentation on how to change the main window title. The only tutorial I found has you start a project and build it using the default files that are generated for a GTKmm project.
Is there a good book or online tutorial out there for doing GUI development in Anjuta?
This is maybe not a complete answer, but it's too large to put in as a comment. I use Anjuta fairly regularly, but I share your feeling about the missing documentation (which is, by the way, not unique for Anjuta). I appreciate Anjuta (and Glade) very much, so don't take the following as criticisms on either program.
I would recommend you consider using PyGTK for GUI creation. It is a lot more productive. You can design the GUI in Glade - exactly the same way you would do for C/C++ - and then implement the code in Python, which you can also edit and manage from Anjuta. There are plenty of code examples, for example on the nullege code search engine.
About the work flow in Anjuta (for C/C++). It is based mainly on the Autotools system, so you should really read up a little on make, Makefile, and related tools. Though in principle Anjuta manages this, you will, sooner or later hit a problem, and some knowledge about Autotools will help you a long way (also this tutorial or this one. This slide series is interesting - probably because it is more graphical. There are even some video tutorials, like this one.).
There is no real necessity to use Glade from inside Anjuta. In fact, Glade has passed a long process distancing itself from 'code generation'. It now only contains an XML generator, which can be called separately. I find the screen space left for Glade inside Anjuta insufficient for comfortable work anyway.
So, in conclusion: If you mainly need a GUI, consider Python + Gtk. If you do need C or C++, Anjuta is a great IDE, but look at Gtk Development examples (like this one). Following those, the use of Anjuta should be a lot clearer.
EDIT:
Very useful answer. I have some underlying legacy code that has to be
C++. Is there a way to mix Python and C++ in Anjuta, or do you know of
any guideposts or tutorials for such?
You can open a C++ project in Anjuta - maybe even import you legacy code directly as a Makefile project. You can also add new files to your C/C++ project and create them as Python files. I've never tried to do that though, and I'm not sure how Anjuta would treat them, for example, in the Makefile(s). I don't have large projects mixing languages at the moment, but for small projects, I like 'Geany', because it doesn't get in the way. You do have to maintain the Makefiles manually.

Lowest common denominator GUI library on unix/Xserver

I want to code a primitive, DE independant application. Hence I want to be independant of Qt and GTK. What is the next lower library below Qt/GTK. I mean what is the lowest common denominator that is used by either of them and is available on every graphical linux system.
The X11/Xorg server is used by both Qt, GTK, and pretty much every GUI toolkit out there (FLTK, etc...), so it is the "lowest common denominator" you're talking about. You can use it directly with the XCB or Xlib library.
There is no such common library.
If you are writing a desktop app (i.e something you expect the user to interact with through their usual windowing system) my advice would be to use either QT or GTK - choice is yours.
There are some other reportedly simplier 'lightweight' libraries you can use such as EFL (Enlightenment) and TK (i.e. Old school tcl/tk apps haven't seen one of these for years). Or you could even use something more exotic like Motif (for that cutting edge mid 90's unix workstation CDE look and feel) - I hear that is open source now (finally).
For a full screen app like a game I believe you can use SDL or maybe ever write out directly to Linux's frame buffer device - I can't really offer anything here I have no experience.
There is no gurantee any of these libraries will be available on any given Linux installation. Thankfully package management exists to take care of this for you. Write the app publish the source and the make files. If people find it useful and want it in their distribution someone will package it for you.
If you are making a closed source binary you are left with static linking.

Where to start to learn how to build Linux GUI apps based on scripts?

First off, I'm looking to write GUI apps based on an interpreted language (PHP if possible--otherwise, Python). Second, I'm looking for a rapid-app GUI designer that lets me create windows, drop UI elements on it, and wire those elements up to code easily. Finally, it would be nice to have a simple way to package the whole thing up (deb, rpm, etc). Ideally my application should work on any Linux platform, and in Gnome or KDE.
I'm wondering if Glade is the way to go? And do I install just "glade" (via APT) or "glade-gnome"? (I'm on Linux Mint 10)
Bonus question: it would be cool to be able to have code that I could very easily just port over to Windows & Mac OS and work as well (UI and all). Of course, I'm thinking Python is probably the way to go as the underlying language.. if I recall correctly, Python has some way to build UIs that work on any platform? I could be wrong.
EDIT: Again, I have to say.. it is important to be able to have an interface designer of sorts. I absolutely do not want to code windows, buttons, input boxes, etc., by hand.
I'd really suggest you have a look at Qt. You have Python GPL (PyQt) bindings available or the (newer) LGPL Pyside bindings readily available:
A mature, stable, well documented and extremely rich framework
Comes with a GUI Designer for easy drag and drop UI design
Cross platform for free (Windows, Linux, Mac)
Look at PyGTK, wxPython

Resources