Python Module Easygui

Source: Internet
Author: User

1, MsgBox

MsgBox (msg= ' (Your message goes here) ', title= ', ok_button= ' OK ', Image=none, Root=none)

MsgBox () displays a message and provides an "OK" button, you can specify any message and caption, and you can even rewrite the contents of the "OK" button. The following is an instance function of MsgBox ():

#! /usr/bin/env python#-*-coding:utf-8-*-#__author__ = "Ma Qing"#__date__ = "2017/03/31"#__desc__ = A small window of the simplest Java-like MessageBoxImportEasygui as G#for most of the Easygui functions there are default parameters, and almost all components display a message and a caption. #The title defaults to an empty string, and the information is unobstructed with a simple default value#For example, the parameters of the MsgBox () function title section are optional, so you can specify a message parameter when you call MsgBox, for example:msg = G.msgbox ("Hello Easy GUI")#of course, you can also specify information parameters and caption Parameterstitle = G.msgbox (msg="I must learn to program! ", title="Title Section", ok_button="come on")

2, Ccbox ()

Ccbox (msg= ' shall I continue? ', title= ', choices= (' Continue ', ' Cancel '), Image=none)

Ccbox () provides a choice: Continue or Cancel, and returns 1 (checked Continue) or 0 (check cancel) accordingly. Note that Ccbox () is a return integer of 1 or 0, not a Boolean type of True or False. But you can still write this:

Importimport  Easygui as Gif g.ccbox (" Dear still play ?" ", choices= (" also want to play!)  "," Forget It/(ㄒoㄒ)/~~")):    g.msgbox (" still don't play, go to sleep!  "Else:    sys.exit (0)

3, Ynbox ()

To be honest, this function is exactly the same as the Ccbox () function ..... Omit a good dozens of words ...

4, Buttombox ()

Buttonbox (msg= ", title=", choices= (' Button1 ', ' Button2 ', ' Button3 '), Image=none, Root=none)

You can use Buttonbox () to define your own set of buttons, and Buttonbox () displays a set of buttons that you have defined.

When the user clicks on any of the buttons, Buttonbox () returns the text content of the button. If the user cancels or closes the window, the default option (the first option) is returned. Take a look at the example:

Import Easygui as Gg.buttonbox (msg=" what kind of fruit do you like? " ", title=" ", choices= (" watermelon "," Apple ", " Strawberry "))

5, Indexbox ()

Indexbox (msg= ' shall I continue? ', title= ', choices= (' Yes ', ' No '), Image=none)

Basically the same as above, the difference is that when the user selects the first button to return the serial number 0, select the second button when the return sequence number 1.

6, Boolbox ()

Boolbox (msg= ' shall I continue? ', title= ', choices= (' Yes ', ' No '), Image=none)

Returns 1 if the first button is selected, otherwise 0.

7. Display the picture in Buttonbox ()

When you call a Buttonbox function (such as MsgBox (), Ynbox (), Indexbox (), etc.),

You can also assign a value to the keyword parameter image, which is to set an image in a. gif format (note that only GIF format is supported):

Import Easygui as Gg.buttonbox (" everybody say sniff cute ?" ", image="xiuxiu.gif", choices= (" cute ","  not Love "," miser "))

8, Choicebox ()

Choicebox (msg= ' Pick something. ', title= ', choices= ())

button components provide users with a simple button option, but a better strategy is to provide them with an optional list if there are many options, or if the content of the option is particularly long.

Choicebox () provides the user with an optional list that uses a sequence (a tuple or list) as an option, which is ordered in a case-insensitive manner before being displayed.

You can also use the keyboard to select one of the options (more tangled, but not important at all):

    • For example, when you press the "G" key on your keyboard, the first option that starts with "G" will be selected.
    • Pressing the "G" Key again will select the next option that starts with "G".
    • When you select the last option that starts with "G", pressing the "G" key again will return to the first option starting with "G" at the beginning of the list.
    • If the option does not start with "G", the option to start the character with the character sorted before "G" ("F") is checked.
    • If no characters in the option are sorted before "G", then the first element in the list will be selected.

Combine the file features we learned before, for example, in a popular case

Import" Choose your favorite kind of amateur life " "= [" Reading  "," swim "," ride a bike "," Play Games "  = G.choicebox (msg,choices=choicess_list)

9, Mutchoicebox ()

Multchoicebox (msg= ' Pick as many items as you like. ', title= ', choices= (), **kwargs)

The Multchoicebox () function also provides an optional list, unlike Choicebox (), Multchoicebox () allows the user to select 0, 1, or multiple options at the same time.
The Multchoicebox () function is also used as an option for sequences (tuples or lists), which appear to be ordered in a case-insensitive manner before they are displayed.

Import Easygui as Gg.multchoicebox (msg=" please choose which fruits do you like to eat? ") ", title=" ", choices= (" watermelon "," banana ", " Apple "," pear "))

10, Enterbox ()

Enterbox (msg= ' Enter something. ', title= ', default= ', Strip=true, Image=none, Root=none)

Enterbox () provides the user with one of the simplest input boxes, with the return value as a string entered by the user.

The value returned by default automatically removes the leading and trailing spaces, and sets the parameter strip=false if you need to preserve the trailing spaces.

Import Easygui as Gg.enterbox (msg=" please speak your mind at this time ", title=" Heart Whisper "  )
11, Interbox ()

Integerbox (msg= ", title=", default= ", Lowerbound=0, upperbound=99, Image=none, Root=none, * * invalidkeywordarguments)

Integerbox () provides the user with a simple input box, the user can only enter the range (lowerbound parameter set minimum value, upperbound parameter setting maximum value) of the integer value, otherwise it will require the user to re-enter.

Import Easygui as Gg.integerbox (msg=" Please enter your score ", title=" fractional stats "  , lowerbound=0,upperbound=100)

12, Mulenterbox ()

Multenterbox (msg= ' Fill in values for the "," title= ", fields= (), values= ())

Multenterbox () to provide users with a number of simple input boxes, pay attention to the following points:

    • If the user enters a value that is less than the option, the value in the returned list fills the user with an empty string for the input option.
    • If the user enters more than one option, the value in the returned list is truncated to the number of options.
    • Returns the value of the list in the field or the None value if the user cancels the operation
ImportEasygui as Gmsg="please fill in the information (where the item with an * number is required)"title="Account Center"FieldNames= ["* User name","* real name","Fixed Telephone","* Mobile phone number","QQ","*email"]fieldvalues=[]fieldvalues=G.multenterbox (msg,title,fieldnames)#print (fieldvalues) whileTrue:ifFieldvalues = =None: Breakerrmsg=""     forIinchRange (len (fieldnames)): Option=Fieldnames[i].strip ()ifFieldvalues[i].strip () = =""  andOption[0] = ="*": ErrMsg+= ("'%s ' is required"%Fieldnames[i])ifErrMsg = ="":         Breakfieldvalues=G.multenterbox (errmsg,title,fieldnames,fieldvalues)Print("you fill in the following information:%s"%str (fieldvalues))

13, PasswordBox ()

PasswordBox (msg= ' Enter your password. ', title= ', default= ', Image=none, Root=none)

PasswordBox () like the Enterbox () style, the difference is that the user-entered content is displayed with "*", returning the user-entered string:

Import Easygui as Gg.passwordbox (msg=" Please enter your password ")
Import" Please enter your password "= g.passwordbox (msg)Print (str (user_password))

14, Multpasswordbox ()

Multpasswordbox (msg= ' Fill in values for the "," title= ", fields= (), values= ())

Multpasswordbox () uses the same interface as Multenterbox (), but when it is displayed, the last input box appears in the form of a password ("*"):

Import" Please enter user name and password  " " User Login interface "  == G.multpasswordbox (Msg,title, (" username "," password  "))print(user_info)

15. TextBox ()

TextBox (msg= ", title=", text= ", codebox=0)

The textbox () function, by default, displays text content in proportional font (parameter codebox=1 is set to equal width font), which is useful for displaying general written text.
Note: The text parameter (the third parameter) can be a string type, a list type, or a primitive type.

Python Module Easygui

Related Article

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.