Modern tkinter menus in Windows - python

Is it possible, using tkinter, to create a modern menu with a divider on the left for icons?
It was introduced in Windows Vista, if I'm not mistaken.

Tkinter can not provide native looking windows. If you're looking to make a more modern program, I'd suggest using wxPython or PyQt.
You could probably just use the menu from either and attach it to a Tk window somehow, but it's not recommended.

Related

How does Tkinter work on Microsoft Windows?

I was reading the up on Tkinter for certain operations that the windows manager handles and I got to wondering how exactly does Tkinter communicate with the OS's window manager? Per the docs it uses Xlib to draw graphics, but how does that work on Microsoft Windows? Isn't Xlib a Unix-like grahpics library, i.e. X11? How exactly does Tkinter communicate with Windows graphics? Does the Windows version of Python have access to the WinAPI and doesnt use Xlib?
Tk (the library upon which tkinter is base) uses the windows API on windows, and cocoa libraries on OSX. Those two platforms don't use xlib, though it is possible to compile X11-based versions on those platforms if you wish.
A lot of information about the windows port of tcl/tk is available on the Tcl wiki: https://wiki.tcl-lang.org/page/Microsoft+Windows+and+Tcl

python system tray using tkinter

I want to create a system tray for my application using python tkinter.
can anyone let me know how can I do the same using python tkinter?
No, I don't think python Tkinter can do it alone. You'll probably need to install some tk extension, which will be platform-dependant and hard to use from python's bindings.
For completeness, on gtk you'd use gtk.StatusIcon

Python - Best GUI library for the job?

I've been using WxPython and I've tried Tk, but it seems that, while both are good and I'll likely use them for other projects, neither of those appear to be capable of accomplishing the things that I want for my current project (which is fine, they're good at what they do).
Basically what I'm looking for is something that will allow me to make rich graphical GUIs. My specific goal is a window that will draw bitmap buttons, resize the parent window automatically to fit them, and possibly animate the resize with a slide effect and have the buttons fade in. Also being able to have my own window border style instead of the inbuilt one is important to me.
This particular project will be Windows only, so non-portable libraries are fine in this case, though portable ones would be great too.
If I missed how this can be done in either WxPython or Tk, I'm all ears.
PySide: http://www.pyside.org/
The PySide project provides
LGPL-licensed Python bindings for the
Qt cross-platform application and UI
framework. PySide Qt bindings allow
both free open source and proprietary
software development and ultimately
aim to support all of the platforms as
Qt itself.
The Windows version of PySide is quite new and may be considered as a beta version. PySide is API compatible with PyQt.
How about PyQt?
http://www.riverbankcomputing.co.uk/software/pyqt/intro
Just sharing my opinion: Kivy.
Innovative open-source library. Supports both 2.x and 3.x versions of Python.
Kivy - Open source Python library for rapid development of applications
that make use of innovative user interfaces, such as multi-touch apps.
Kivy is based on OpenGL ES 2 and includes native multi-touch for each platform and Android/iOS. It’s an event-driven framework based around a main loop, and is thus also suitable for game development.
Try Pyglet. Its a library for python that makes using OpenGL very easy. You can draw pretty good 2d interfaces using Quads.
I can't tell you what is best because that is subjective but I can give you another option: PyGTK
PyGTK lets you to easily create programs with a graphical user interface using the Python programming language. The underlying GTK+ library provides all kind of visual elements and utilities for it and, if needed, you can develop full featured applications for the GNOME Desktop.
PyGTK applications are truly multiplatform and they're able to run, unmodified, on Linux, Windows, MacOS X and other platforms.

How's Python GUI development today (Sep/2010)?

Last time I saw, GUIs in Python were extremely ugly, how's it today?
(saw some beautiful images on google images, but I don't know if are really Python's)
Python 2.7 and 3.0 ships with the themed tk ("ttk") widgets which look much better than previous versions of Tk (though, honestly, any competent GUI developer can make even older Tk look good). Don't let the people who don't know much about Tk sway you from using it, it's still a very viable toolkit for many, many tasks. You won't be creating a Photoshop clone with it, but how many people write those kinds of apps anyway?
I've been using wxPython for the past year and would still choose Tkinter over it for most tasks. Tkinter is much simpler and in many respects more powerful. The only advantage wxWidgets has is that it has more built-in widgets, but I find many of them a bit buggy and hard to use. For most apps that most people will write, Tkinter is still an excellent choice.
Some screenshots of themed widgets are available here:
http://code.google.com/p/python-ttk/wiki/Screenshots
Here's a screenshot of a Tkinter app that uses the themed widgets on the Mac:
http://www.codebykevin.com/phynchronicity-running.png
Tk is sill is the default GUI toolkit for Python, but it has a theme support from Python 2.7/3.1. It is not as ugly as before.
However, you can use some nice alternatives which still look better (IMHO) and have more functionalities :
wxPython : maybe the most used, cross platform and all, your applications will look the same as native.
PyQt or soon PySide : bindings for the Nokia Qt open source framework. There is more than just a GUI toolkit.
PyGTK : bindings for the GTK+ libraries
Here is more info : http://wiki.python.org/moin/GuiProgramming
Python has bindings for Tk, Qt, GTK, wx, and many more. There's no reason it should be any uglier than another language. You're probably thinking of a gui made with Tk, which has a reputation of being ugly. It's not specific to python, but it might be more common because it's very simple and ships with python by default.
See Gui Programming on the python wiki for more info.
I Think the latest Tkinter version offers native look for Macos. WxPython and QT offers native look for macos,windows and linux. GTK is abit ugly and prone to crashes on mac cause of the X11 implentation there.
Of course you could build your own GUI , that something I am trying to do with pygame.Let me clarify , I am not making a GUI library just GUI for my own application. I am making the graphics in the 3d app Blender.
My vote for Generic GUI goes to wxPython, tried it, looks great, easy to use and works like a charm across platforms. You will also find tons of info about it. Integrates well with opengl so if you want to do extreme guis on it , it can do them.

How would a system tray application be accomplished on other platforms?

Windows has the "system tray" that houses the clock and alway-running services like MSN, Steam, etc.
I'd like to develop a wxPython tray application but I'm wondering how well this will port to other platforms. What is the tray equivalent on each platform, and how much manual work would be required to support Windows, OSX and Linux (which shells in particular would be friendliest).
wx is a cross-platform GUI and tools library that supports Win32, Mac OS X, GTK+, X11, Motif, WinCE, and more. And if you use it's classes then your application should work on all these platforms.
For system tray look at wxTaskBarIcon (http://docs.wxwidgets.org/stable/wx_wxtaskbaricon.html#wxtaskbaricon).
Under OS X you have the Status Menu bar - the right-most items are often status-related things (like battery status, WiFi connections, etc).
Try searching for NSStatusBar and NSMenuExtra. It's almost trivial to turn an application into one that has an NSStatusBar menu and doesn't appear in the Dock. There are tutorials around on how to do it.
For many Linux desktop systems (Gnome, KDE, etc.) a Freedesktop's SysTray Protocol is implemented. You can try that if any other solution fails.
On Linux it really depends - you got diffrent programming environments there, and some window managers don't even have a tray area. Altho, if you use Gtk (and wx is Gtk really), the gtk.StatusIcon is your friend.
Here are some examples of that (haven't checked if they actually work, but should show you the path).
For wx I found some example code here.
Use Qt: Qt Systray Example
That'll show a systray icon on all platforms that Qt runs on and that support such icons. You'll need to come up with a strategy when systray functionality isn't supported, though.

Categories