Python button bind Event

Source: Internet
Author: User

# <button-1>: left mouse click event# &LT;BUTTON-2&GT;: Mouse click event# <button-3&gt: Mouse Right-click event# &LT;DOUBLE-BUTTON-1&GT;: Double-click event# &LT;TRIPLE-BUTTON-1&GT;: three-click eventFrom TkinterImport *tk = TK () canvas = Canvas (width=500,height=) Canvas.pack ()#canvas. Create_polygon (0,0,250,250,fill = ' red ')DefEcho_event(EVT):#打印键盘事件if Evt.type = ="2": Print ("Keyboard:%s"% evt.keysym)#打印鼠标操作if evt.type =  "4": Print ( "Mouse:%s"% Evt.num) # print (evt.type)  #键盘事件canvas. Bind_all ( "<KeyPress>", echo_event)  #如果绑定指定的键盘, then "<Key>" or "< Keypress> "can, specific to the specified key after adding an underscore and the specified key, such as: binding lowercase t and left key Canvas.bind_all (" <KeyPress-Left> ", Echo_event)  #鼠标事件canvas. Bind_all ( "<Double-Button-1>", echo_event) Canvas.bind_all ( "<Button-1>", Echo_event) Canvas.bind_all (  "<Button-2>", Echo_event) Canvas.bind_all ( "< Button-3> ", echo_event)             

Python button bind event

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.