Python learning record 6 --- some interesting places in easygui 2

1, How to display pictures in a buttonbox

When we call a buttonbox() function (such as msgbox(),ynbox(),indexbox(), etc.), we can also assign a value to the keyword parameter image and set one gif or png format image:
Don't say much, just go to the code

import easygui as ac
ac.buttonbox('If I were DJ Will you love me?',image='123.png',choices=('love','Not love','$%%%%@#'))

The program is implemented as follows:


In fact, to be honest, it took me a lot of time to complete this step. 1 I don't know where to put the picture I don't know why I can't display the picture

Solution
It's really impossible to find more information on the Internet. You can ask Daniel you know to help you solve it
The picture must be in the form of png or gif and put in the same path as your py file
With pycharm compiler, you can automatically select the url of the picture

As for the pictures that cannot be displayed, you can refer to this blog Solve the problem that the buttonbox does not display pictures

2, Provides users with a range of options

**Several functions of buttonbox() * * provide users with a simple button option, but if there are many options or the content of options is particularly long, a better strategy is to provide them with a selectable list.
choicebox() and multchoicebox() - optional drop-down list
(1)choicebox()

import easygui as ac
ac.choicebox(msg='What's College for?',title='',choices=["For ideal","In order to make more money in the future","Just playing around"])`

The choicebox() function provides the user with a list of choices, using sequences (tuples or lists) as options, which are sorted alphabetically.
The program is implemented as follows:

(2)multchoicebox()

import easygui as ac
ac.multchoicebox(msg='What's College for?',title='',choices=["For ideal","In order to make more money in the future","Just playing around"])

The multchoicebox() function also provides a selectable list. Unlike choicebox(), multchoicebox() supports users to select 0, 1 or multiple options at the same time.
The multchoicebox() function also uses sequences (tuples or lists) as options. These options will be arranged in case insensitive order before being displayed:
The program is implemented as follows:
Using different functions for the same content, we can realize two different functions

3, Let the user enter a message

(1) enterbox() -- text input box

enterbox(msg=' Enter something. ', title=' ', default=' ', strip=True, image=None, root=None)

msg: content to be displayed
Title: the title of the window
Default: the keyword defines the default value of the text box
strip: when the value of is True, the leading and trailing spaces will be automatically ignored, while False is the opposite
image: display picture (path required)

The enterbox() function provides the user with the simplest input box, and the return value is the string entered by the user:

import easygui as ac
ac.enterbox(msg=' What do you want to say about yourself today ', title=' Ask once a day', default=' ', strip=True, image=None, root=None)

The program implementation is shown in the figure:

(2) integerbox() - digital input

integerbox(msg='', title=' ', default='', lowerbound=0, upperbound=99, image=None, root=None,)

msg: content to be displayed
Title: the title of the window
Default: the keyword defines the default value of the text box
lowerbound: the minimum value entered
upperbound: the maximum value entered
image: display picture (path required)

Return value:
  the returned value is the entered number after entering the content
  click the Cancel button to return to None
  upper right corner × No. return to None
When the input value exceeds the range, a prompt will be given and a new input will be made

import easygui as ac
ac.integerbox(msg='Guess my lucky number', title=' Digital game', default='7', lowerbound=0, upperbound=99, image=None, root=None,)

The program is implemented as follows:

(3)multenterbox() - Multi option input

multenterbox(msg=' ', title=' ', fields=(), values=())

msg: content to be displayed
Title: the title of the window
fields: fill in the item name
values: default content

Return value:
  after entering the content, the return value is the input content, in the form of list
  click the Cancel button to return to None
  upper right corner × No. return to None

import easygui as ac
ac.multenterbox(msg=('Please enter the following information'), title='Account Center  ', fields=(['user name','Real name','Telephone','QQ','Wechat']), values=())

The program is implemented as follows:

Keywords: Python

Added by pradeepknv on Thu, 10 Feb 2022 13:57:15 +0200