Billy
Billy

Reputation: 1

Importing tkinter modules

Is it possible to just import parts of tkinter, like you can import parts of Java swing without having to import the entire library when you only need to use 4 or 5 modules. I am writing small python program with pop-up input/output window a few textboxes and buttons and only want to use grid layout manager.

I have looked through all the python and tkinter documentation and searched tutorial websites and youtube unable to find an example.

General python/tkinter language query.

Upvotes: 0

Views: 118

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385900

You have to have all of tkinter in memory even if you don't use it all. You can import individual pieces like you can with any other python module, but that won't make your program any smaller or more efficient. Under the hood python will import the entire module, even if it only makes part of the module visible to your code.

Arguably, the only real effect would be in making your code a bit harder to understand by deviating from best practices.

Upvotes: 1

Related Questions