Python visual interface

Source: Internet
Author: User

In the various button components, the default message is "Shall I continue?", so you can call them without any parameters.

Here we demonstrate to call Ccbox ()without any parameters, and return a Boolean value when you select "Cancel" or close the window:

If Ccbox ():    pass      #用户选择继续else:    return     #用户选择取消

Calling the Easygui function using the keyword argument

Calling the Easygui function also allows you to use the keyword parameter oh.

Now suppose you need to use a button component, but you don't want to specify the caption parameter (the second argument), you can still specify the choices parameter (the third parameter) using the method of the keyword argument, like this:

>>> choices = [' willing  ' to ' don't  want to ' be willing when you have money  ']>>> reply = Choicebox (' would you like to purchase resources to pack support for the Little turtle?  ', choices = choices)

8 Using key components

On demand, Easygui set up a series of function calls on Buttonbox ().

8.1 MsgBox ()

MsgBox (msg = ' (You message goes here) ', title = ' 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 simplest way to rewrite the ' OK ' button is to use the keyword parameter:

MsgBox (' I must learn to program! ', Ok_button = ' Come on! ‘)

 

8.2 Ccbox ()

Ccbox (msg= ' shall I continue? ', title= ', choices= (' c[o]ntinue ', ' c[a]ncel '), Image=none, default_choice= ' c[o]ntinue ', Cancel_choice= ' C[a]ncel ')

Ccbox () provides a choice: "C[o]ntinue" or "C[a]ncel", and returns True or False accordingly.

NOTE: [O] in "c[o]ntinue" means shortcut keys, that is, when the user taps the O character on the keyboard, it is equivalent to clicking the "C[o]ntinue" button.

8.3 Ynbox ()

Ynbox (msg= ' shall I continue? ', title= ', choices= (' [<f1>]yes ', ' [<f2>]no '), Image=none, default_choice= ' [ <f1>]yes ', cancel_choice= ' [<f2>]no ')

As with Ccbox (), only the default choices parameter values are different, [<f1>] means that the F1 function keys on the keyboard are used as shortcuts for "Yes".

8.4 Buttonbox ()

Buttonbox (msg= ", title=", choices= (' button[1] ', ' button[2] ', ' button[3] '), Image=none, Images=none, default_choice= None, Cancel_choice=none, Callback=none, Run=true)

You can use Buttonbox () to define your own set of buttons, andbuttonbox () displays a set of buttons that you customize.

When the user clicks on any of the buttons,buttonbox () returns the text content of the button.

If a user clicks Cancel or closes the window, the default option (the first option) is returned.

Take a look at the example:

 fromEasyguiImportEgstore#define a class called "Settings" that inherits from the Egstore classclassSettings (egstore):def __init__(self, filename):#need to specify file name        #Specify the name of the property to rememberSelf.author =""Self.book=""        #The following two statements must be executedSelf.filename =filename Self.restore ()#Create an instantiated object "Settings" for "Settings "Settingsfilename ="Settings.txt"Settings=Settings (settingsfilename) Author="Little Turtle" Book=""0 Basic Introductory Learning Pyhon""#Save the values of the above two variables in the "Settings" ObjectSettings.author =Authorsettings.book=Booksettings.store ()Print("\ nthe save complete \ n")

Try :         Print ('I love fishc.com! ' the        int ('fishc'#  here will produce an exception except:        Exceptionbox ()

Python visual interface

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.