Making Tk look like a native Linux app - linux

Browsing the TkDocs website, it looks like Tk has come a long way in the "native look and feel" department. But looking at some of these screenshots, it seems to be let down in Linux. If you scroll down that page, you'll see a Mac screenshot that looks exactly like Mac, a Windows XP screenshot that looks exactly like Windows XP, and a Linux screenshot that looks like ... well Windows 98 (or Windows XP with classic style).
I know Linux doesn't really have a "native look and feel", since every toolkit does its own styling. But I'm wondering if there is any way to style Tk so it looks like either GTK or Qt (preferably Gtk), so it would blend in to most other apps on the Linux desktop.
What about Windows Vista/7? I haven't seen any Tk screenshots on those platforms.

Tk has basically two sets of widgets, the classic widgets and the themed widgets. The classic widgets are default because of the need to support old applications, but new code should use the themed widgets. (They can't be overloaded because they work in quite different ways, and there's a lot of code out there that depends on the old classic way. Alas.) With the right theme, the themed widgets (typically referred to as Ttk) look native and behave natively on Windows and OSX.
There are partial Ttk themes that delegate to Gtk and Qt available (this presentation from last year shows them in action) but they're partial, in large part because of the poor quality of the themes (Gtk/Qt themes, not Ttk themes; this is confusing!) in typical use with those toolkits. The major problem is apparently in the reporting of metrics, which often seems to be wrong (resulting in widgets getting the wrong size or visual elements being put in the wrong place); I understand from talking to the author of that paper that a significant fraction of themes only happen to work with Gtk/Qt, but cannot verify this from personal experience. (I'm on OSX so I use Ttk's direct native support.)

For the impatient users of a modern Linux distribution:
echo '*TkTheme: clam' >> ~/.Xresources
xrdb -merge ~/.Xresources
Then restart your Tk based app.
Here is what to expect (shown is git gui):
On the left is git gui started after the above command was issued. Notice how the bar changed, buttons did too.

PySolFC includes a nice, modern look and feel, which can also be used with other Tk apps.
Stephan Sokolow writes about this in his blog:
Making Tk applications a bit less ugly (how to change the Tk theme)
Installing a new Ttk/Tile theme (how to use PySolFC's theme)

Just from what I've heard in Python's main mailing list from time to time, Themed TK (TTK) widgets are themable and can either mimic native widgets or do their own thing and look good. See http://www.tkdocs.com/tutorial/styles.html.
From experience, Tk (at least through Python) looks like crap. I pulled up a test for you on windows 7: http://sadpanda.us/images/542945-LNUGO0F.jpg. Not really a looker by default!

Related

How can one greate grid/tile view of selected parts of windows on xfce/linux

I have a few windows on my linux machine using the xfce4 desktop enviorment.
I wish to have a grid-like view where i can see only the part of each window im intrested in.
An example for the general vision:
see a script running without the window borders on terminal across the header
see work status of F#H client out of the advenced client view in the middle left
see only the turrents status list of qBittorrent at middle right
have another terminal at footer (again without header/borders)
My best way to describe it shortly is to generate a view from selective parts of windows.
Added a picture for illustration
Is there any way of doing such thing in a practical way? Am i missing out on a great software?
There are several tiling helpers for Xfce.
Perhaps try xpytile , which is a tiling add-on for Xfce. It offers
automatic tiling, manual tiling and can simulaneously resize side-by-side windows (like AeroSnap for MS-Windows).

Pygame, two windows one releated to other (Menu-like)

I am wondering if it is possible to create two windows in two different .py files where the first window will be some settings about the game, and the second the game with the setting, set by the user in the first window.
The first screen, it would be something easy, like 3 texts where the user can choose with the arrows. And when one of the three texts pressed, the game will be load on the screen.
Thanks
I think you want to create a window where a user can choose the resolution, or other settings, with a play button.
I would recommend Tkinter for the job.
Here you will find some tutorials about it.
You should then link a button with launching of the game itself.
EDIT:
Since you want to use pygame, this is still possible. Just have 2 seperate pygame scripts, and launch the second script after a MOUSE_DOWN event on one of the texts.
If by two windows you mean two separate windows, then no, PyGame can't do that yet.
This feature was only just added in SDL2, and I hardly think PyGame is using SDL2 yet.
If you want to use SDL2 with Python, then have a look at PySDL2: http://pysdl2.readthedocs.org/en/latest/tutorial/pygamers.html
It is suggested that you can fake it using multiprocessing: Creating multiple screens in pygame
If you want two different applications (a launcher and the game), then that shouldn't be much trouble. Just treat them as two separate PyGame applications.

How should I create a desktop mockup?

I want to create a desktop mockup on Elementary OS 0.2. By "mockup" I mean something that shows off the aesthetic of the mockup, mostly just showing what selecting/clicking/hovering over a button or widget does to that particular part of the UI. I'm thinking about creating the various parts on GIMP and coding animation and transition logic into the final result. I know that something like this can be done in HTML/JS, but I want to avoid using those. Is there anything optimized for a project like this? I'm open to most languages.
Try WireframeSketcher wireframing tool. Unlike Gimp or PowerPoint, WireframeSketcher is designed specifically to help you create mockups and wireframes. It comes pre-packaged for Debian systems and can also be found in Software Center and so it works on Elementary OS too. Note that it's a commercial tool, but you can try it freely for 14 days.
Most PMs at large companies mock these things up using a presentation package like PowerPoint. If you know the routine and where to click it can look fantastic with minimal effort.
MockupUI does both wireframe and Windows native looking mockups. It uses your desktop's visual style which makes screens and widgets look as a standard Windows application. MockupUI lets you export screens as individual images, docx, pdf or html.
Actions/interactions can be explained by highlighting widgets and adding text annotations.

How to programmatically invert screen colors in Linux

In Ubuntu, for example, you can use Super-M to invert the screen colors (requires desktop effects, see [1]). Other OSes have similar abilities, although I'm not really concerned with anything other than Linux.
Which API should I look into if I want to write a simple program that, when run, inverts the screen colors?
The language that I use the API from doesn't particularly matter to me. I am familiar enough with C/C++/Bash/Perl/Python that I can hack this up in whatever language has the easiest access to this API. Working on Ubuntu is required, working on other similar *nixes is not terribly important.
[1] https://help.ubuntu.com/community/KeyboardShortcuts#Desktop%20Effects%20enabled%20shortcuts
You could use xcalib to do what you want.
For example, a simple bash script to invert the screen colors would look like this:
#!/bin/bash
xcalib -invert -alter
Here are scripts and instructions for shifting colors using compton: https://github.com/vn971/linux-color-inversion
xrandr-invert-colors worked out of the box for me.
xcalib does not work for me using xorg and a tiling window manager, with an external display and gives me the following error: "Unable to get a display calibration".
Credit to Imat.

What is a cool wallpaper or background (if any) for a Main Application Window?

Does the opening Window enhance an application's attractiveness? Should it be a picture or bland Blue and White?
Use the default OS theme colors. Anything else will be attractive to certain groups of people, and ugly to others (who will complain very loudly about how ugly they find it). If you stick with the OS theme colors, then at least your application's appearance will not be something you'll be criticized over.
Some people like it clean and nice, while others consider stylish themes to be positive and nice to have. You gotta consider who your application is pointed towards and do what that group is interested in.
I would use the default OS colors. But actually if i could, i wouldn't put any color/themes at all there. I would put some information/controls in that area (assuming you talk about the background of an MDI/SDI application). Similar to what the most recent openoffice 3 version has done. For example, put "What do you want me to do? Open / Exit / Tutorial / ..." into it.

Resources