O'Reilly logo

Tkinter GUI Application Development Blueprints - Second Edition by Bhaskar Chaudhary

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling cross-platform differences 

Even though Tkinter is a cross-platform module, you might come across occasions when code written for one operating system might not work as expected on other operating systems.  We already saw one such example in the case of getting command-line results in the previous Redirecting the command-line output to Tkinter. In such cases, you can overcome these cross-platform discrepancies by first identifying the operating system on which the program is being run and then using a conditional statement to run different lines of code for different operating systems.

Here's a brief snippet that demonstrates this concept:

 from platform import uname operating_system = uname()[0] if ( operating_system == "Linux" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required