Nictk 2.2.0
An easy to use pyton GUI
Menu Class Reference

Menu widget which allows displaying menu bars, pull-down menus and pop-up menus. More...

Inheritance diagram for Menu:
Misc

Public Member Functions

def __init__ (self, parent, label=None, popup=False)
 The constructor. More...
 
def activate (self)
 Sets the state of the menu to NORMAL. More...
 
def add (self, itemType, cnf={}, **kw)
 Appends an item to the menu. More...
 
def clear (self)
 Deletes all menu items. More...
 
def deactivate (self)
 Sets the state of the menu to DISABLED. More...
 
def delete (self, index1, index2=None)
 Deletes menu items between index1 and index2 (included). More...
 
def entry_activate (self, index)
 Sets the state of the menu item denoted by index to NORMAL. More...
 
def entry_config (self, index, cnf=None, **kw)
 Configures a menu item at index. More...
 
def entry_deactivate (self, index)
 Sets the state of the menu item denoted by index to DISABLED. More...
 
def entry_get_config (self, index, option)
 Returns the resource value of a menu item. More...
 
def entry_set_variable (self, index, variable=None, offvalue=None, onvalue=None)
 Sets a variable for the menu at index. More...
 
def insert (self, index, itemType, cnf={}, **kw)
 Inserts an item in the menu at the given index (starting from 0). More...
 
def size (self)
 Returns the number of elements in the items list. More...
 
- Public Member Functions inherited from Misc
def bind (self, sequence=None, func=None, add=None)
 Redefines the tk.Misc.bind() method. More...
 
def config (self, cnf=None, **kw)
 Configures resources of a widget. More...
 
def get_config (self, key)
 Returns the value for the key resource. More...
 
def get_winfo (self, key)
 Returns the widget info for the item key. More...
 
def has_option (self, opt=None)
 Returns True if the widget admits the given option. More...
 
def parent (self)
 Returns the widget parent. More...
 
def toplevel (self)
 Returns the widget toplevel container (a Window or Main). More...
 
def unbind (self, sequence, funcid=None)
 Redefines the tk.Misc.unbind() method. More...
 
def winfo_bh (self)
 Returns the height of the widget bounding box. More...
 
def winfo_bpad (self)
 Returns the list of the four pad amounts (E-N-W-S) of the widget with respect to its bounding box. More...
 
def winfo_bw (self)
 Returns the width of the widget bounding box. More...
 
def winfo_bx (self)
 Returns the x coordinate of the widget bounding box topleft corner. More...
 
def winfo_by (self)
 Returns the y coordinate of the widget bounding box topleft corner. More...
 
def winfo_height (self)
 Returns the widget height. More...
 
def winfo_width (self)
 Returns the widget width. More...
 
def winfo_x (self)
 Returns the x coordinate of the topleft corner of the widget with respect to the parent. More...
 
def winfo_y (self)
 Returns the y coordinate of the topleft corner of the widget with respect to the parent. More...
 

Additional Inherited Members

- Static Public Attributes inherited from Misc
def winfo_h = winfo_height
 Alias for winfo_height() More...
 
def winfo_w = winfo_width
 Alias for winfo_width() More...
 

Detailed Description

Menu widget which allows displaying menu bars, pull-down menus and pop-up menus.

**Common options** (see \ref ATTRIBUTES)

      abcolor, afcolor, bcolor, borderwidth, cursor, dfcolor, font, fcolor, relief,
      sfcolor, takefocus

**Less common options**

      activeborderwidth, postcommand, tearoff, tearoffcommand, title, type

see <a href="https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/menu.html">anzeljg reference</a>
for the class **tkinter.Menu**
\see \ref Menu.py example file

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  parent,
  label = None,
  popup = False 
)

The constructor.

It creates an empty menu, and you can add to it commands, checkbuttons, radiobuttons and separators.

Parameters
parentthe menu parent; if it is an instance of Menu this menu will be added to it as a cascade, if it is a window this is set as its menubar (but see below)
labelthe menu text
popupif True this is a popup menu, and will not be added to its parent

Member Function Documentation

◆ activate()

def activate (   self)

Sets the state of the menu to NORMAL.


The menu and all its submenus can interact with mouse and keyboard.

◆ add()

def add (   self,
  itemType,
  cnf = {},
**  kw 
)

Appends an item to the menu.

It overrides tkinter method. You, however, can continue to use add_command(), add_checkbutton(), add_radiobutton() and add_separator() (see the tkinter reference).

◆ clear()

def clear (   self)

Deletes all menu items.

◆ deactivate()

def deactivate (   self)

Sets the state of the menu to DISABLED.


The menu and all its submenus are grayed and cannot interact with mouse and keyboard.

◆ delete()

def delete (   self,
  index1,
  index2 = None 
)

Deletes menu items between index1 and index2 (included).

◆ entry_activate()

def entry_activate (   self,
  index 
)

Sets the state of the menu item denoted by index to NORMAL.


The menu item and all its submenus can interact with mouse and keyboard.

Parameters
indexcan be the label of the menu item or its index in the menu array.

◆ entry_config()

def entry_config (   self,
  index,
  cnf = None,
**  kw 
)

Configures a menu item at index.

◆ entry_deactivate()

def entry_deactivate (   self,
  index 
)

Sets the state of the menu item denoted by index to DISABLED.


The menu item and all its submenus are grayed and cannot interact with mouse and keyboard.

Parameters
indexcan be the label of the menu item or its index in the menu array.

◆ entry_get_config()

def entry_get_config (   self,
  index,
  option 
)

Returns the resource value of a menu item.

Parameters
indexthe item index as an int (starting from 0)
optionthe option we wantto know as a string

◆ entry_set_variable()

def entry_set_variable (   self,
  index,
  variable = None,
  offvalue = None,
  onvalue = None 
)

Sets a variable for the menu at index.

It is useful only for checkbutton items.

◆ insert()

def insert (   self,
  index,
  itemType,
  cnf = {},
**  kw 
)

Inserts an item in the menu at the given index (starting from 0).

It overrides tkinter method. You, however, can continue to use insert_command(), insert_checkbutton(), insert_radiobutton() and insert_separator() (see the tkinter reference).

◆ size()

def size (   self)

Returns the number of elements in the items list.


The documentation for this class was generated from the following file: