Python Tkinter interface appearance changes depending on OS - python

My application looks beautiful on Windows
But on MacOS and Linux it does not look nice at all!
Is there something I can do to help make this widget appearance consistent across operating systems?
My application source code : http://pae.st/BILs/

Using Tkinter's place manager for widget layout causes the poor layout of your application on different operating systems. You should be using either pack or grid managers, both of which will adjust to the differing widget sizes you encounter.

Related

appearance of my GUI in several OS

I would like to check the appearance of my GUI while coding, for several OS where it should be distributed.
How can I do ?
The problem is that the ‘previsualisation’ proposed by QT Designer is very different from the appearance of the distributed release. I even have spots in tabs that appear with same font and size in ‘previsualisation’ but have different sizes on Windows... I work with: python 3.5, a GUI designed with QT Designer, developed on mac OS 10.11 and shared with Windows 7 and Windows 10 systems (installed with a recent pyinstaller)
The preview uses some approximation of the final style drawn completely by Qt, but the style used "for real" in most platform plug-ins either employs real, native widgets, or emulates them asking for theme parts straight from the machine where it's running. So, it's not possible to have a completely faithful preview unless you use a style that is always drawn completely by Qt (such as Fusion).
Long story short: to see how your application will really look on different platforms you'll have to test it "for real".
ok. For the moment, I developed a ui file for each OS and test the appearance "for real". That's awkward and, moreover, in a given ui file, some strings that have exactly the same apparent properties in Qt Designer may appear differently in the final release

How to change tkinter ttk Notebook background colour (Python)?

I am trying to change the background color of the ttk Notebook widget in my python tkinter application so that it matches the blue color instead of being white.
I've tried searching for hours but to no avail. Is it not working because I'm working on a mac?
tabs_notebook = ttk.Notebook(self)
tabs_notebook.configure(bg=DARKBLUE)
tabs_notebook.pack()
view_tab = ttk.Frame(tabs_notebook)
new_tab = ttk.Frame(tabs_notebook)
tabs_notebook.add(view_tab, text="View Patient Details")
tabs_notebook.add(new_tab, text="Add New Patient")
One of the major complaints levelled at Tk was that it was ugly. This was mostly because it never fit the native look and feel of the hosting environment and because the amount of configuration options provided meant application developers tended to roll their own style which never fit well with any other applications. The other problem was that on Windows and MacOS Tk used naive rendering APIs to draw buttons and other UI elements but failed to keep up when these platforms introduced theming. As a result even if the Tk application looked ok on default Windows XP, it would look out of place where a user selected an alternate theme.
So in developing ttk (themed Tk) one of the primary design goals was to ensure that the default theme fit the current platform. On Windows and MacOS this means that UI elements are drawn using the native theming APIs. On Linux - it just has to make a best guess.
In your specific case the notebook elements are being drawn using MacOS themeing API calls and you cannot change the colors for this theme from Tk. However, what you can do is define an entire Tk theme. There are some examples in Tk code doing this and these were imported to Python by someone. Those should yield enough to generate a new theme using Tk drawing APIs and possibly images for some elements to allow for a fully custom theme should you require that amount of customization.

PyQt5 Resize app for different displays

I am using PyQt5 and Python 3.6.4 to design a ui for a program. It was made on a 720p monitor however now using the same code on a 4k monitor, everything is tiny apart from the text. How would I go about resizing the whole app to look the same on all monitors: (720p, 1080p, 4k, etc.)
The program is to be run on windows through an executable created through compiling the python code.
Cheers
Simple 1 line fix for any who need
os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"
This is somewhat system dependent, so it would help if you mentioned your target platform(s).
Because PyQt5 is just a wrapper around Qt5, I think High DPI Displays from the Qt manual applies. Citing the relevant bit (but you should read the whole thing):
In order to get an application designed for low DPI values running on a high resolution monitors quickly, consider one of the scaling options (let the application run as DPI Unaware on Windows or set the environment variable QT_AUTO_SCREEN_SCALE_FACTOR to "1". These options may incur some scaling or painting artifacts, though.
In the longer term, the application should be adapted to run unmodified:
Always use the qreal versions of the QPainter drawing API.
Size windows and dialogs in relation to the screen size.
Replace hard-coded sizes in layouts and drawing code by values calculated from font metrics or screen size.
In a shell, you would do something like:
$ export QT_AUTO_SCREEN_SCALE_FACTOR=1
$ python my_application.py

wxpython balloonframe overlays all windows

I am using BalloonTip and BalloonFrame from wxpython in order to generate pop up notifications. Unfortunately the generated elements are overlapping all windows: Not only the window of my application but also all windows of the other applications.
I would like to suppress this behavior and display the notification only on top of my own application and not on top of all windows.
Is there any possibility to specify the "z-index" like in CSS or something similar?
You should probably just create your own frame then as I don't believe the Balloon widgets support that behavior. When you do create your own frame, you can tell it to center on parent. If you want it to disappear on it's own, you can use a wx.Timer. You could also look at this:
http://wxpython.org/Phoenix/docs/html/adv.NotificationMessage.html

How can I get a list of the running applications with GTK?

How can I get a list of the running applications? I'm referring to the ones in the panel at the bottom of the screen.
I believe what you are looking for is libwnck
The panel you are referring to is the GNOME panel. So this is a GNOME question, not a GTK question.
There is not a well-defined concept of "multi-window application" in GNOME that I know of. The panel task list is probably build by querying the window manager for the list of windows and grouping the windows by their "class" property.
There are also various window manager hints that must be taken into account, for example to ignore panels and other utility windows. In your place, I would look at the source code of the taskbar applet. There is maybe some documentation somewhere that covers the status-quo, but I do know where it would be.

Categories