Menu widget which allows displaying menu bars, pull-down menus and pop-up menus.
| 3560 | |
| 3561 | |
| 3562 | class Menu(Widget): |
| 3563 | """Menu widget which allows displaying menu bars, pull-down menus and pop-up menus.""" |
| 3564 | |
| 3565 | def __init__(self, master=None, cnf={}, **kw): |
| 3566 | """Construct menu widget with the parent MASTER. |
| 3567 | |
| 3568 | Valid option names: activebackground, activeborderwidth, |
| 3569 | activeforeground, background, bd, bg, borderwidth, cursor, |
| 3570 | disabledforeground, fg, font, foreground, postcommand, relief, |
| 3571 | selectcolor, takefocus, tearoff, tearoffcommand, title, type.""" |
| 3572 | Widget.__init__(self, master, 'menu', cnf, kw) |
| 3573 | |
| 3574 | def tk_popup(self, x, y, entry=""): |
| 3575 | """Post the menu at position X,Y with entry ENTRY.""" |
| 3576 | self.tk.call('tk_popup', self._w, x, y, entry) |
| 3577 | |
| 3578 | def activate(self, index): |
| 3579 | """Activate entry at INDEX.""" |
| 3580 | self.tk.call(self._w, 'activate', index) |
| 3581 | |
| 3582 | def add(self, itemType, cnf={}, **kw): |
| 3583 | """Internal function.""" |
| 3584 | self.tk.call((self._w, 'add', itemType) + |
| 3585 | self._options(cnf, kw)) |
| 3586 | |
| 3587 | def add_cascade(self, cnf={}, **kw): |
| 3588 | """Add hierarchical menu item.""" |
| 3589 | self.add('cascade', cnf or kw) |
| 3590 | |
| 3591 | def add_checkbutton(self, cnf={}, **kw): |
| 3592 | """Add checkbutton menu item.""" |
| 3593 | self.add('checkbutton', cnf or kw) |
| 3594 | |
| 3595 | def add_command(self, cnf={}, **kw): |
| 3596 | """Add command menu item.""" |
| 3597 | self.add('command', cnf or kw) |
| 3598 | |
| 3599 | def add_radiobutton(self, cnf={}, **kw): |
| 3600 | """Add radio menu item.""" |
| 3601 | self.add('radiobutton', cnf or kw) |
| 3602 | |
| 3603 | def add_separator(self, cnf={}, **kw): |
| 3604 | """Add separator.""" |
| 3605 | self.add('separator', cnf or kw) |
| 3606 | |
| 3607 | def insert(self, index, itemType, cnf={}, **kw): |
| 3608 | """Internal function.""" |
| 3609 | self.tk.call((self._w, 'insert', index, itemType) + |
| 3610 | self._options(cnf, kw)) |
| 3611 | |
| 3612 | def insert_cascade(self, index, cnf={}, **kw): |
| 3613 | """Add hierarchical menu item at INDEX.""" |
| 3614 | self.insert(index, 'cascade', cnf or kw) |
| 3615 | |
| 3616 | def insert_checkbutton(self, index, cnf={}, **kw): |
| 3617 | """Add checkbutton menu item at INDEX.""" |
| 3618 | self.insert(index, 'checkbutton', cnf or kw) |
| 3619 |
no outgoing calls
no test coverage detected
searching dependent graphs…