T.Chmelevskij
T.Chmelevskij

Reputation: 2139

How to call method keys in Python 3

I'm learning about Tkinter at the moment. To get more information about the methods I read the pydocs.

Problem is when I call:

>>>help(Text.configure)

I get :

configure(self, cnf=None, **kw)
Configure resources of a widget.

The values for resources are specified as keyword
arguments. To get an overview about
the allowed keyword arguments call the method keys.

So how would I call or list all the method keys?

I've tried:

>>>Text.configure.keys()

and

>>>Text.configure().keys()

But of course they do not work because it's a function not a dictionary.

Upvotes: 4

Views: 1702

Answers (1)

jonrsharpe
jonrsharpe

Reputation: 122061

keys is an instance method of all Widget sub-classes, you can access it as follows:

>>> from Tkinter import Text
>>> help(Text.keys)
Help on method keys in module Tkinter:

keys(self) unbound Tkinter.Text method
    Return a list of all resource names of this widget.

>>> Text().keys()
['autoseparators', 'background', 'bd', 'bg', 'blockcursor', 'borderwidth', 'cursor', 
 'endline', 'exportselection', 'fg', 'font', 'foreground', 'height', 'highlightbackground',
 'highlightcolor', 'highlightthickness', 'inactiveselectbackground', 'insertbackground',
 'insertborderwidth', 'insertofftime', 'insertontime', 'insertwidth', 'maxundo', 'padx',
 'pady', 'relief', 'selectbackground', 'selectborderwidth', 'selectforeground', 'setgrid',
 'spacing1', 'spacing2', 'spacing3', 'startline', 'state', 'tabs', 'tabstyle', 'takefocus',
 'undo', 'width', 'wrap', 'xscrollcommand', 'yscrollcommand']

Upvotes: 6

Related Questions