importing

Mark Lawrence breamoreboy at yahoo.co.uk
Mon Mar 7 16:37:28 EST 2016


On 07/03/2016 20:07, MRAB wrote:
> On 2016-03-07 19:08, Mark Lawrence wrote:
>> On 07/03/2016 17:38, Chris Angelico wrote:
>>> On Tue, Mar 8, 2016 at 4:23 AM, Tony van der Hoff
>>> <tony at vanderhoff.org> wrote:
>>>> Thanks to all who replied to my cry for help; I understand it better
>>>> now.
>>>> But:
>>>>
>>>> On 07/03/16 16:08, Chris Angelico wrote:
>>>>>
>>>>>
>>>>> The documentation should tell you what you need to import to make
>>>>> something work. In this case, I would guess that "import
>>>>> tkinter.messagebox" or "from tkinter import messagebox" would be the
>>>>> recommended way to use this module.
>>>>
>>>>
>>>> Well, I found the tkinter documentation to be sparse in the extreme
>>>> (https://docs.python.org/release/3.1.3/library/tkinter.html), and it
>>>> certainly doesn't go into that sort of detail.
>>>
>>> You're looking at an ancient version of the docs. Here's the newest
>>> docs:
>>>
>>> https://docs.python.org/3/library/tkinter.html
>>>
>>> Up the top, it says to start with "import tkinter" or "from tkinter
>>> import *", and then it lists some *other modules* (including
>>> "tkinter.messagebox"). Obviously with the "turtle" module, you have to
>>> import that separately (it's completely outside the tkinter
>>> hierarchy); the same is true of the others.
>>>
>>> Incidentally, this message is visible in the 3.1.3 docs that you
>>> linked to, too. But I still recommend reading the current docs (unless
>>> you're actually running your code on 3.1.3, in which case you really
>>> REALLY should upgrade).
>>>
>>> ChrisA
>>>
>>
>> As I happen to be playing with tkinter I was searching literally minutes
>> ago for the way to put a grid onto a notebook tab.  Regrettably the
>> notebook grid is conspicious by its absence from the docs :(
>>
> It's in the tkinter.ttk docs:
>
> https://docs.python.org/3/library/tkinter.ttk.html
>

https://docs.python.org/3/library/tkinter.ttk.html#tkinter.ttk.Notebook 
lists add, forget, hide, identify, index, insert, select, tab, tabs and
enable_traversal, but no grid, possibly others.  yet:-

 >>> import tkinter.ttk
 >>> help(tkinter.ttk.Notebook.grid)
Help on function grid_configure in module tkinter:

grid_configure(self, cnf={}, **kw)
     Position a widget in the parent widget in a grid. Use as options:
     column=number - use cell identified with given column (starting with 0)
     columnspan=number - this widget will span several columns
     in=master - use master to contain this widget
     in_=master - see 'in' option description
     ipadx=amount - add internal padding in x direction
     ipady=amount - add internal padding in y direction
     padx=amount - add padding in x direction
     pady=amount - add padding in y direction
     row=number - use cell identified with given row (starting with 0)
     rowspan=number - this widget will span several rows
     sticky=NSEW - if cell is larger on which sides will this
                   widget stick to the cell boundary

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list