Tkinter Creations - python-3.x

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.

Related

Use multiple graphical windows in OCaml

OCaml comes with the Graphics module which allows the use of a graphical window.
Is it possible to open two graphical window, and switch between them ?
The Graphics module provides machine-independent tools but in case of a negative answer, perhaps it would also be interesting to have solutions for different window system, such as X11.
I looked through the Graphics module API and I don't see support for multiple windows. I would assume Graphics was intended as something useful but simple enough to be part of the base OCaml release.
For more complex graphics, it makes sense just to provide OCaml bindings to an existing library. If I go to opam.ocaml.org/packages and search for "graphics" I see a few possibilities.
I have done OpenGL coding in OCaml but in fact I had to build some wrappers for OS-native GUI functionality to create the windows. This was many years ago, however.
The Graphics module is quite limited and is more intended as a simple basic library for teaching purposes. A possible replacement for Graphics might be the tsdl package which is a thin wrapper around the SDL C library which should work on most platforms.

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.

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.

How is scrolling supported in Linux graphical environments like GNOME and KDE?

I'm curious to know: is scrolling (such as in Firefox, Nautilus, etc.) handled be each application separately? Or is it done by the environment? Or by the widget toolkit?
What confuses me, is that it is possible to change to "smooth scrolling" in Firefox, which makes it seem like each application handles its scrolling separately. However, when writing software for Linux, you don't really need to specify and it seems like GTK takes care of it on its own.
The reason I'm curious is because I wanted to know if Linux could have it's own "accelerated" scrolling, much like OS X. I know this is possible by app, because Google Picasa has its own built in.
To make this possible for the entire system, does GTK need to be modified? Or something else?
Most applications rely on their toolkit for scrolling behaviors.
Firefox does a lot of stuff by itself, partly because it runs on various platforms with various toolkits (not just GTK), and partly because it has advanced needs that aren't always met by whatever toolkit it happens to be using.
GTK is far from the only toolkit used on Linux. There is also Qt (which is used in KDE), wxWidgets, Tk, FLTK, Motif clones, Xt, and you can even build applications on Xlib itself without a toolkit.
You're using two different terms, "smooth scrolling" and "accelerated scrolling". These are not the same thing, and the latter is technically ambiguous.
There is absolutely nothing preventing Linux (really X) applications from having any particular scrolling behavior. It's up to the application and/or its toolkit, if it relies on one.
Regardless of the above, keep in mind that not everyone agrees that the scrolling behaviors you allude to are good.

Method for building lightweight, cross-platform, text editor

I'm planning to build a simple, lightweight text editor that combines a great look with keyboard focused input.
I want to have a lot of control over things like antialiasing and all the graphics in general, but I don't care about having a whole library of widgets. Almost the entire UI will be text-based and in the main canvas/window of the app.
Toolkits like GTK and Qt seem like overkill - tons of widgets I don't need and a complex codebase.
Titanium, AIR, and XULRunner are even bigger in some ways - dev would be quick, but that's not exactly the lightweight approach.
Shoes seemed like a nearly perfect fit, but it's a little too small and doesn't support enough events (e.g. no window resize).
What do you think, should I just build it on Cairo/Pango or another graphics library and roll the platform specific stuff myself? I'd rather use a framework of some kind.
Basically all I want is:
good event handling
windowing
menus
drawing with really great type rendering choices
I would love to build this cross-platform from the start.
Even if you use just Cairo/Pango you still need windows on the screen.
The simplest combination would be cairo + pango + GDK (the windowing part of GTK+)
however even in that case you have no menus, and constructing menus with pure Cairo
would be a tough (but not impossible) accomplishment.
If you insist on lightweight and crossplatform then check the following
Fast Light Toolkit
Fox Toolkit
wxWidgets (goes great with Python)
Scintilla is a cross-platfrom source code editing component (based on GTK+) with excellent support for syntax highlighting, code folding, text zooming, and of course all the usual text editing functions; it should be an excellent foundation for a text editor.

Resources