Welcome to wxpython (1)-detailed examples

Source: Internet
Author: User
#  ! /Usr/bin/Python  #  -*-<Coding = UTF-8> -*-  Import  WX  Class  Myframe (wx. Frame ):  Def   _ Init __  (Self ):  """  Defines the _ init _ method, which is equivalent to constructors of other object-oriented languages. It is automatically called when a class object is created.  """          # Why do I need to call the initialization function of the parent class? Of course, the initialization of the parent class is also automatically called. Wx. Frame. _ Init __ (Self, none,-1, "  Myframe  " , Size = (300,300 ))  #  Create a panel control Panel = wx. Panel (self,-1 )  #  Event binding type: WX. Motion, mainly used to detect mouse movement.  Panel. BIND (wx. evt_motion, self. onmove)  # Create a static file to display information on the panel. Wx. statictext (panel,-1, "  POs:  " , Pos = (10, 12 ))  """  Create a text input box and assign this object to self. posctrl. I have never understood why I should assign a value to self. posctrl. it seems that the variable defined in the _ init _ method can be referenced in the whole class method. In the onmove () method below, I don't know whether to understand it, right.  """  Self. posctrl = Wx. textctrl (panel,-1, "" , Pos = (40, 10 ))  Def Onmove (self, event ):  """  Self. onmove is called by the BIND function. However, this place has always been very abrupt. It is not clear how the event is passed and operated.  """  Pos = Event. getposition ()  #  Display the current cursor position in the text box Self. posctrl. setvalue ( "  % S, % s  " % (Pos. X, POS. y ))  If   _ Name __ = '  _ Main __  '  : App = Wx. pysimpleapp () Frame = Myframe () frame. Show (true) app. mainloop () 

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.