Are there any inbuilt GUI modules in python 3.4? - python-3.x

I am learning python from a video tutorial series that uses a GUI called 'simpleGUI'.
It is not inbuilt in python so I had to download install a similar module called 'simpleGUITK'.
I'm new to python and I wish to know if there is any inbuilt module that I can import without any installation (like I important math or random) which is same as (or at least similar to) simpleguitk?
Because I might need to send some py files to a friend who might not be having the simpleguitk module.

To my knowledge there is no GUI module in the standard library. However, some, like Tkinter, are included with most Python distributions.
I strongly advise that you have a look at the GUI FAQ in the official documentation.

A standard build of python includes tkinter. From the GUI FAQ:
Standard builds of Python include an object-oriented interface to the
Tcl/Tk widget set, called tkinter. This is probably the easiest to
install (since it comes included with most binary distributions of
Python) and use. For more info about Tk, including pointers to the
source, see the Tcl/Tk home page. Tcl/Tk is fully portable to the Mac
OS X, Windows, and Unix platforms.

Related

How to choose and use a python3 dbus library to replace a dbus-send call

Using ubuntu 20.10
I want to write a python script to process the output of this shell command:
dbus-send --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.GetInhibitors
I don't know anything about coding dbus. The first place to start was I hoped a good python library.
I learn this about the apparently canonical library: "dbus-python is a legacy API, built with a deprecated dbus-glib library, and involving a lot of type-guessing (despite "explicit is better than implicit" and "resist the temptation to guess") (from https://wiki.python.org/moin/DbusExamples)
The library https://pypi.org/project/dbus-next/ promises a pure python implementation: "Zero dependencies and pure Python 3."
It is not mentioned on the wiki page mentioned above, but it looks like a healthy project.
However it seems that the pure python approach requires me to use the asyncio version. I think this is overkill for my needs.
I tried using dasbus but I can't install the necessary libraries, at least not in a virtual env.
Despite installing the system package python3-gi, I get errors "no module named gi" and trying to install PyGObject fails because "no package 'cairo' found" ... and ERROR: failed building wheel for pycairo.
So at this point, I have a library which is old and not recommended, a library with dependency difficulties and a library which seems to force me to use asyncio.
I now understand why the php script I am trying to re-write in python executed a shell command and dealt with the ugly output.
On top of that, I think I have worked out these points:
I need the SessionBus
The "path" is "/org/gnome/SessionManager"
The "interface" is org.gnome.SessionManager
I want to "call" the "member" GetInhibitors
I find async a bit of overkill since this is a shell script but if this is only way I can avoid a C dependency, I will deal with it.
Which library should I use?
pydbus is a very capable library that allows me to build things quickly and simply although the repo isn't necessarily that active.
I've only used dbus-next library a few times and it does have various *_sync methods if you don't want to do things asynchronously.

Find all programms, written on python3 + gtk3, installed on my linux system

I'm practicing in GTK3-based GUI development on python3 and since I'm beginner both in programming or python or GTK3-framefork, I wish to look at examples of serious working programs written this way. My current desktop OS is Linux Mint 19.3 with XFCE environment, and I see that several graphical utilities included with distro built on GTK3 library.
So I assume the most dumb but simple way to get what I want is grepping all text files at /usr/share/* which contains
import gi or gi.require_version("Gtk", "3.0") or from gi.repository import Gtk lines.
But, may be there is more elegant and intelligent way to find desired packages by using package management systems (pip or apt-derivated)? I'm afraid that potentially interesting packages will be turned out of grep scope, because they are installed at any other unusual directory or using different importing instructions.

Is tkinter different under windows and linux?

Obviously Tkinter code under linux and windows are different, but I have never seen a tutorial or documentation that mentions that. Most books on python and tkinter are written for linux platforms. I wonder if there are any books written specifically for windows?
It's not that obvious: the code itself is really the same but, of course, the GUI is builded with different libraries in runtime. The result is that the appearance of the GUI change in different OSs.

How to see every dependency in a Python program (e.g. imports)?

I have several apps I'm developing that are for end users that have no idea how to use Python. I have already discovered how to setup a package that allows them to run any script without Python knowledge but I don't know how to minimize the distribution size by only including subsets (I.e. the actual function calls in large libs like NumPy) of each imported library that are required. Is there a way to output the actual subcomponents of each imported library that are actually accessed during the function? All my internet searches end up with cyclical imports which is not what I need. There must be some Python dependency walker equivalent I have yet to discover. Much appreciated any libs that can outline this.
[UPDATE]
I converted Snakefood 1.4 over to Python 3x (3.5 tested to build) with python setup.py install and saved it here: https://github.com/mrslezak/snakefood per the accepted answer.
Use Snakefood
Here's a command
sfood -i -r myscript.py | sfood-cluster > dependencies.txt

python3 tkinter or ncurses

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.

Resources