Re: [Tutor] interface
On 18/12/15 18:38, Alex Kleider wrote: > I've settled on "Modern Tkinter" by Mark Roseman. > His is the most recently published of the various references recommended > and he makes the point that the "themed" (ttk) component is recent > (and I assume not covered in the other sources.) FWIW My recent book Python Projects includes coverage of both ttk and Tix as well as core tkinter. But it's only designed to be a taster, it's not a complete reference. It's more about the general approach to putting a UI on an app than about any specific toolkit. > import tkinter as tk > from tkinter import ttk For production code this is better. And you can swap out Tkinter for Tix by just changing one line: import tkinter.tixix as tk # v3 or import Tix as tk# v2 So all the existing tk code carries on working but you now have access to the extra widgets in Tix too. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] interface
Alex Kleider writes: > On 2015-12-18 14:13, Mark Lawrence wrote: > > On 18/12/2015 18:38, Alex Kleider wrote: > > >> […] uses a syntax that is strongly discouraged Yes. It is discouraged in PEP 8 and in other guides for Pythonic code. Wildcard imports ( from import * ) should be avoided, as they make it unclear which names are present in the namespace, confusing both readers and many automated tools. https://www.python.org/dev/peps/pep-0008/#id17> For all new Python code, that should IMO be strongly enforced. > >> so my inclination is to use > >> import tkinter as tk > >> from tkinter import ttk > >> instead. > >> > >> Comments? I agree with that usage. ‘import inconvenientlongname as shortname’ is excellent code that combines the virtues of being explicit, concise, readable, and easily-introspected. > > from xyz import * is The Road To Hell. > > Vindicated! Note that the Python standard library documentation for Tkinter explicitly contradicts PEP 8 advice: […] usually, to use Tkinter all you need is a simple import statement: import tkinter Or, more often: from tkinter import * https://docs.python.org/3/library/tkinter.html#tkinter-modules> This is one of many cases where conventions have resolved after some significant code (and documentation) violating the convention entered the standard library. So, it is an uncomfortable fact that Python's Tkinter recommends un-Pythonic idioms — and that will likely remain the case. I applaud attempts to carve out an ever-increasing space where the more Pythonic idiom ‘import tkinter as tk’ is enforced. Be aware, though, that there is a lot of existing code – most of which shouldn't be changed only to fix this – which violates that idiom. -- \ “If we don't believe in freedom of expression for people we | `\ despise, we don't believe in it at all.” —Noam Chomsky, | _o__) 1992-11-25 | Ben Finney ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] interface
On 2015-12-18 14:13, Mark Lawrence wrote: On 18/12/2015 18:38, Alex Kleider wrote: Another issue about which I'd like to hear comments has to do with how the imports are done. Roseman indicates that from tkinter import * from tkinter import ttk is the generally accepted way of doing the importing but the first line uses a syntax that is strongly discouraged so my inclination is to use import tkinter as tk from tkinter import ttk instead. Comments? from xyz import * is The Road To Hell. Sticking with the explicit way of importing modules makes life so much easier in the long term that there is IMHO nothing to discuss. Vindicated! Thank you. Alex ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] interface
On 18/12/2015 18:38, Alex Kleider wrote: On 2015-12-16 17:42, boB Stepp wrote: On Mon, Dec 14, 2015 at 10:08 PM, Alex Kleider wrote: Thank you, gentlemen (Alan, Ben, Mark,) for your advice. The consensus seems to be in favour of tkinter so I'll head in that direction. If you are into books, "Programming Python, 4th ed." by Mark Lutz, has an extensive section on tkinter (Alan had pointed this out to me, and I have found Lutz's coverage very helpful). Plus the book (very thick!) has lots of other goodies. Also, the now old book, "Python and Tkinter Programming" by John E. Grayson is just about Tkinter (with a capital "T") as it is copyrighted 2000. Despite this I think it is still quite useful even if you are working in Python 3 as, as far as I can tell, t/Tkinter has not changed substantially in how the coding goes. I've settled on "Modern Tkinter" by Mark Roseman. His is the most recently published of the various references recommended and he makes the point that the "themed" (ttk) component is recent (and I assume not covered in the other sources.) I'd prefer a real book but have had to settle for the kindle edition:-) A pdf version may also be available. Another issue about which I'd like to hear comments has to do with how the imports are done. Roseman indicates that from tkinter import * from tkinter import ttk is the generally accepted way of doing the importing but the first line uses a syntax that is strongly discouraged so my inclination is to use import tkinter as tk from tkinter import ttk instead. Comments? from xyz import * is The Road To Hell. Sticking with the explicit way of importing modules makes life so much easier in the long term that there is IMHO nothing to discuss. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] interface
On 2015-12-16 17:42, boB Stepp wrote: On Mon, Dec 14, 2015 at 10:08 PM, Alex Kleider wrote: Thank you, gentlemen (Alan, Ben, Mark,) for your advice. The consensus seems to be in favour of tkinter so I'll head in that direction. If you are into books, "Programming Python, 4th ed." by Mark Lutz, has an extensive section on tkinter (Alan had pointed this out to me, and I have found Lutz's coverage very helpful). Plus the book (very thick!) has lots of other goodies. Also, the now old book, "Python and Tkinter Programming" by John E. Grayson is just about Tkinter (with a capital "T") as it is copyrighted 2000. Despite this I think it is still quite useful even if you are working in Python 3 as, as far as I can tell, t/Tkinter has not changed substantially in how the coding goes. I've settled on "Modern Tkinter" by Mark Roseman. His is the most recently published of the various references recommended and he makes the point that the "themed" (ttk) component is recent (and I assume not covered in the other sources.) I'd prefer a real book but have had to settle for the kindle edition:-) A pdf version may also be available. Another issue about which I'd like to hear comments has to do with how the imports are done. Roseman indicates that from tkinter import * from tkinter import ttk is the generally accepted way of doing the importing but the first line uses a syntax that is strongly discouraged so my inclination is to use import tkinter as tk from tkinter import ttk instead. Comments? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fwd: Kivy Install
On 17/12/2015 18:06, peter mcfarlane wrote: Hi, I don't know if this is the correct forum, I am new to Python and trying to install Kivy. I keep getting the following error message. Can you help? thanks, pete pip install --user Kivy [snip attempted Windows build] I've given up trying to build anything on Windows, it's just too much like hard work. So go to http://www.lfd.uci.edu/~gohlke/pythonlibs/ and download Kivy-1.9.0+sdl2-cp27-none-win32.whl or Kivy-1.9.0+sdl2-cp27-none-win_amd64.whl as appropriate. Then use "pip install" against the local file name. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor