vb old bird Beginner python (python for Kids) instance __python

Source: Internet
Author: User

1. Tkinter

Import Tkinter:from tkinter Import *

Create window: TK=TK ()

Repaint window: Tk.update ()

Refresh. Tk.update_idletasks ()

Create button: Btn=button (tk, Text = ' button info ', command= function)

Create canvas (from left to right, top to bottom): Canvas=canvas (tk,width= wide, height= High)

Draw line: Canvas.create_line (beginning x, beginning Y, end x, end y)

Picture box: Canvas.create_rectangle (Start x, start Y, end x, end y[,fill= color), color rgb (' #xxxxxx ' #表明是16进制, each two-bit color)

Draw Arc: Canvas.create_arc (beginning x, beginning Y, endpoint x, endpoint y,extent= angle, STYLE=ARC)

Draw Polygon: Canvas.create_polygon (1x, Dot 1y, dot 1x, Dot 1y ...) [, Fill= ""])

Display text: Canvas.create_text (x,y,text= ' text ' (' font ', size)]

Display Picture: Myimage=photoimage (file= ' Full name of file ')

Canvas.create_image (x,y,anchor= direction, image=myimage)

Objects to move the canvas: Canvas.move (Object id,x,y)

Monitoring events, available event, such as: Def Moveobject (event):

Statement block

if Event.keysym = = ' Key Name ':

Operation or processing

Call the specified function when a specific event occurs: Canvas.bind_all (' <keypress-key > ', function), key name such as: Return, up, down, left, right change the properties of the object: Canv As.itemconfig (object id, attribute = ' value '), such as: fill= ' Blue ', outline= ' red ' gets the position of the object: Canvas.coords (Object ID)

Display: Pack (), Btn.pack (), Canvas.pack ()

Color Picker: Colorchooser.askcolor () [1]


Turtle Mapping Addendum:

Create canvas: Turtle.setup (width= wide, height= High)

To a coordinate: T.goto (x,y), x,y can use a negative number

2. Named parameters, that is, when the function is called, specify the parameter name, you can make the parameters are not in order to fill.

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.