| | |
how to bind keys to menu items?
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
![]() |
how to bind keyboard keys to menu items? i know to bind with mouse buttons but with keybooard keys dont know.
for eg: Cntl+O to open a file in File menu.
how to implement undo, redo, find, find again, copy, paste functions in python. i actually gone through the IDLE.py, which is shipped with python package, but it is such big code i couldnt trace it. can any body breif about how implement this in python?
please help me out.
for eg: Cntl+O to open a file in File menu.
how to implement undo, redo, find, find again, copy, paste functions in python. i actually gone through the IDLE.py, which is shipped with python package, but it is such big code i couldnt trace it. can any body breif about how implement this in python?
please help me out.
I hope you are talking about Tkinter as GUI. This code might help you. You have to use a if statements to get the right key value to go to the proper function then.
Python Syntax (Toggle Plain Text)
# bind and show a key event with Tkinter from Tkinter import * root = Tk() prompt = ' Press any key ' label1 = Label(root, text=prompt, width=len(prompt)) label1.pack() def key(event): if event.char == event.keysym: msg = 'Normal Key %r' % event.char elif len(event.char) == 1: msg = 'Punctuation Key %r (%r)' % (event.keysym, event.char) else: msg = 'Special Key %r' % event.keysym label1.config(text=msg) label1.bind_all('<Key>', key) root.mainloop()
![]() |
Similar Threads
- replacement of getch() (C++)
- add sub menu items to css menu? (JavaScript / DHTML / AJAX)
- Add Administrative Tools to Your Start Menu (Windows tips 'n' tweaks)
- In which folder are the Start menu items? (Windows NT / 2000 / XP)
- In need of Menu over Frames (JavaScript / DHTML / AJAX)
- Drop Down Menu (ASP.NET)
Other Threads in the Python Forum
- Previous Thread: Thread Dump of a python process
- Next Thread: GUI for Python
| Thread Tools | Search this Thread |
Tag cloud for Python
ansi assignment avogadro backend beginner binary bluetooth character cmd code copy customdialog data decimals dictionary drive dynamic error examples excel exe file float format ftp function gnu graphics gui heads homework http ideas import input java leftmouse line linux list lists logging loop module mouse newb number numbers output parsing path pointer port prime program programming progressbar projects push py2exe pygame pyglet pyqt python random recursion recursive refresh schedule scrolledtext sqlite ssh statistics stdout string strings sudokusolver sum table terminal text thread threading time tkinter tlapse tricks tuple tutorial ubuntu unicode update urllib urllib2 variable wikipedia windows write wxpython xlib






