Is tkinter different under windows and linux? - 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.

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.

Are there any inbuilt GUI modules in python 3.4?

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.

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.

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

python 3 IDLE progressbar/loadingbar

I am using the standard IDE that comes with python3.
I would like to make use of the backspace function (\b) within the ILE in order to create a NICE LOOKING progressbar. Even a simple percentage counter requires the backspace function.
When I run the script I get a wonderfully useless symbol instead of a backspace.
Questions:
How can I use \b in the IDE
How else can I make a progress bar that would use something similar to a backspace (in other words, I don't want a lame eg: loading:##########################
I've read threads on this and the best solution I've heard involves actually re-writing the IDE base code which is just an tkinter app. I just don't understand why this would be required ... did they think it was a stupid feature to have a function like this in the standard python IDE? Mind-baffling
It sounds to me like you want a 'GUI' (often pronounced 'gooey') widget. That stands for Graphical User Interface. Python normally runs in a Text-Base Interface aka command-line interface (CLI). CLI applications are the sort of boring 1980s style terminal things that they had around before they invented the computer mouse and invented better graphics devices. If you want a progress bar to look modern (my interpretation of 'not lame'), you will have to create a GUI. Python can do this too, if you use special tools. You need a GUI framework. Some good GUI frameworks are listed here. Different frameworks are like different tools. I would recommend using tk and ttk for starters (TKinter and themed TKinter), and you can get that version of the progressbar here.
So actually implementing GUIs is always a mess. It is really complicated and very difficult to program. That is the value of the boring 1980s style CLI terminal applications is that they are much simpler to program.
If you still decide you want a GUI app, you should check out a tutorial or maybe even a GUI-builder. See this stack overflow thread and this website.

Resources