I'm starting with tkinter with Python3 and I found some issues in Ubuntu practising with the exercises when coming to icons.
I'm reading Mark Lutz's "Programming Python" and he uses a ".ico" file, but it does not work in Ubuntu. I got curious and started to search on the web, and it seems that few icon formats work (.xbm) in Ubuntu, less in color mode.
I was googling and also found that using PIL or pillow is useful for managing and using color icons in tkinter applications and GUIs, but I didn't found yet any piece of code or detailed explanation on how to use an ".ico" file for an icon in a tkinter GUI in a portable way.
I find pretty weird as well not finding some reusable piece of code or library/module which takes a graphics file and returns some kind of usable icon object ready for being used.
Any reccomendation? Am I searching badly?
I suppose a good alternative is having some software to convert formats, but I would prefer the best code-oriented solution with multiplatform applications in mind and as many supported formats as possible.
Edit: For making this clear, when I talk about icons, I'm referring to icons, those little images in the top-left corner of our windows or in the OS bar when minimized. This isn't about any other kind of image in labels, buttons or other widgets (I don't even think that should be called an icon)
Thanks in advance
Related
Hello I am planning on creating a program in Python 2.7 using a tkinter GUI. I am looking for some guidance on the best method to play text as audio in order to aid people with visual difficulties.
The text that will need to be played would be text on buttons and text within textboxes. are there any libraries I can import that can help me achieve this?
Thanks.
The answer appears to be 'no'. According to tcl/tk developer Kevin Walzer "Tk doesn't support [screen readers]. I've looked into it a bit and it seems like a huge project to implement on a cross-platform basis." See link for a bit more.
If you really want to develop an accessible GUI application in Python, you shouldn't use Tkinter since it is not accessible at all.
Consider using some framework that has bindings to native APIs/controls, for example, WxPython which is a Python port of WxWidgets.
I googled and search stackoverflow before asking this question
Answers that I don't expect:
wxWidgets is the best Python GUIUse TkInter (BIM) for GUI development.
Q. How to make a GUI without using any module/library? i.e make a GUI from scratch. Modules like tkinter not allowed.
I've made several GUIs from scratch using SDL which is a low level drawing library. The advantage of doing that is that it will look exactly the same on any platform down to the pixel and you can get it to work on embedded systems. Full screen GUIs are really easy too. Disadvantages are that it is a lot of work.
In python the pygame library wraps SDL so you would use that, and in fact that is how I made the GUI for a lab instrument which had a large colour LCD screen. The controller ran linux, but not X-windows.
pygame is an extra library, yes, but I can't think of a way of making a GUI with only what python provides.
The easiest GUI to make without "module/library" is a web-based one. I.e. generate HTML with Javascript from your Python code, and let the Javascript interact via AJAX with your Python app. This can be implemented without too much effort with just the standard Python library (and some JS code, of course), or with modules that don't require "heavy" installation of platform-specific extensions.
I have a two years of experience in programming of enterprise application's with Java and Visual Studio, and I'm new in Python and wxPython. So my question is: Can wxPython provide me enough rich GUI to create those same app's? My reason if using Python is in it's diversity, simplicity and fast development of app's. Thank you!
I think it depends on your definition of "rich." I use it and like to think it can make some fairly useful GUIs. Here's a screenshot of a wxPython app to work with sensor data I'm writing right now - not the most elaborate or complicated in the world, but so far it seems fairly intuitive for users:
I find the wxPython docs to be a little sparse at times, but as long as you've got the demo installed and the wxWidgets docs open it's a good toolkit to use.
wxGlade will give you the GUI skeleton. You will still need a separate text editor (I recommend Geany) to fill in the handlers.
I would certainly suggest using Python and its GUI libraries, but only you can really make the decision as to wether you think its better than visual studio or Java. The syntax of Python is very basic and I think many people can agree its a plesure to use when you get your head around it (no curly brackets etc). Python Tkinter is quite a simple GUI library and its ideal for making a basic application. WxPython on the other hand is far more advanced than Tkinter hence a richer user experience. The only problem I have had while using Wx is not being able to find suitable examples on the web to demonstarte how some things are done. Good luck, hope you find what your looking for. Karl
The wxPython demo shows most of the widgets that are available. I suggest that you take a look at this and see whether it will do what you need.
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.
Now don't get me wrong, I'm not exactly a Python fan, but when you see a Tk directory inside of the python directory you kinda expect... Well Python. And yeah, I get that Tk came from TCL, but if I had to write a TCL to use Tk, I'd forget TK existed and use a completely different tool box. (The popularity of this combination completely eludes me.)
Expecting to see a relatively readable language like Python, and finding TCL is like walking in on your grandma naked. It's just visually painful.
I haven't drank the cool-aid when it comes to Python, but I use for simple task that I don't want to bother with C or C++ on and maybe if I want some for quick and dirty text processing. It just seems like a cruel joke to put TCL examples in the Python distribution.
Is there an equivalent package that includes those examples written in Python?
Edit:
I guess this also kinda begs the question is Tk the best option for GUI dev in Python?
There are no Tcl examples in Python's official distribution; whatever distro you're using must have bundled them on its own volition.
IMHO, Tk's only real advantage by now is the convenience that comes from having it bundled with Python. I was criticized for covering it in "Python in a Nutshell", but I stand by that decision because it is still "the" bundled toolkit, after all. But if you want something better and don't mind taking a tiny amount of inconvenience to procure it (and possibly to bundle it with apps you distribute), there are other excellent choices.
PyQt (if you can stand the GPL license or pay for the commercial one) and wxPython are IMHO currently superior offerings for cross-platform GUI apps (though you'll have to work to bundle them with py2exe or PyInstaller if you want to distribute a stand-alone app) and other packages are excellent if you don't care about cross-platform distribution or have specialized needs (e.g. pyui -- while now a general-purpose UI toolkit -- for simple UIs for games if you're using PyGame or PyOpenGL anyway).
Perhaps you should start by looking at the Python Tkinter documentation here and the Tkinter wiki here.
And where are you seeing Tcl examples? Are you looking at a Tcl library supplied with Python perhaps?
TCL / TK is a simple language to understand with which the applications are made very simple, very quickly occupying very few resources and hardware platform to be run on all platforms.
In TCL / TK exist there is also starkits or freewrap allowing wrap libraries, code and other files into a single package easier to carry around, to other platforms and run and install, without being necessary to bring all the libraries brings language.
While the evaluator of TCL / TK requires 3MB, the python requires much more, and uses many more that unused libraries.
When these applications grow, it is logical to migrate first to python and share the GUI using Tkinter, then they can move on to other GUI as QT or Wxwidgets, to work faster.
Who want to program with Tkinter, you must know how it works TCL and TK GUI with which are made tkinter.
Today is not here another library module GUI that there be a versatile as tkinter into a single file that allows cross-platform applications remain to be small and modular for all basic python project.
While tkinter is 2 MB, wxwidget are 80 MB and if you take a calculator, a notepad or a drawing application, you'll want a small GUI easy to incorporate into your projects.
Besides that today made Tkinter applications run faster and better in small devices with limited hardware, ARM or raspberry o smartphones but wxwidgets becomes slow.
If your application is basic and small and you platform is not robust chooses Tkinter, but if is big and heavy and platform of very much resources chooses wxwidget o QT.