Python EasyGui, pythoneasygui

Source: Internet
Author: User

Python EasyGui, pythoneasygui

Python EasyGui

Preface:

In Windows, you want to use Python to develop some simple interfaces, so you can find an easy-to-use EasyGui library. The following is a simple example.

Reference link: Tutorial

Next, I will demonstrate how to use this module from simplicity to complexity. Hope To Help You With easygui :-)

MsgBox, ccbox, ynbox

# Coding: UTF-8 # _ author _ = 'Mark sinoberg '# _ date _ = '2014/2/25' # _ Desc _ = a Java-like MessageBox small Window import easyguititle = easygui. msgbox (msg = 'info', title = 'title', OK _button = "OOK") msg = easygui. msgbox ('Hello Easy gui') print 'Return value: '+ msgccbox = easygui. ccbox ("here is Continue | Cancel Box! ") Print 'Return value: '+ str (ccbox) ynbox = easygui. ynbox (" Yes Or No Button Box! ") Print 'Return value: '+ str (ynbox)

Bottonbox

# Coding: UTF-8 # _ author _ = 'Mark sinoberg '# _ date _ = '2017/25' # _ Desc _ = a simple interface that allows you to choose from at first, the second parameter is a list of import easygui # choice = easygui. buttonbox ("here is the prompt statement information: \ n", title = 'three choose one ', choices = ['one' \ #, 'two', 'three']) # easygui. msgbox ('selected:' + str (choice) ### choices can have only two parameters. If you select one, 1 is returned. Otherwise, 0 # bool = easygui is returned. boolbox ('msg prompt information', title = 'title', choices = ['A', 'B']) # easygui. msgbox (bool) image = 'me.jpg 'msg = 'Here is my photo, a python fan also 'choices = ['yes', 'no', "Not Sure"] title = 'Am I handsome? 'Easygui. buttonbox (msg, title, image = image, choices = choices)

Choicebox

# Coding: UTF-8 # _ author _ = 'Mark sinoberg '# _ date _ = '2017/25' # _ Desc _ = select one of them from a list, there will be a returned value. import easyguimsg = 'select one of the items in this list. 'title =' must be selected. 'choices = ['1', '2 ', '3', '4', '5', '6', '7'] answer = easygui. choicebox (msg, title, choices) print 'you selected:' + str (answer)

Enterbox

# Coding: UTF-8 # _ author _ = 'Mark sinoberg '# _ date _ = '2017/25' # _ Desc _ = controls that meet user input: import easyguist = easygui. enterbox ("enter a text: \ n") print "you entered:" + str (st)

Mutilchoicebox

# Coding: UTF-8 # _ author _ = 'Mark sinoberg '# _ date _ = '2017/25' # _ Desc _ = a multiple-choice list item. haha, this version seems to be faulty. Import easyguimsg = 'is not really implemented for multiple selections. Select one of your favorite items in this list. 'title =' must be selected. 'choices =, 7, 8, 9) answer1 = easygui. multchoicebox (msg, title, choices) for item in answer1: print item

Intenterbox, passenterbox

# Coding: UTF-8 # _ author _ = 'Mark sinoberg '# _ date _ = '2017/25' # _ Desc _ = a simple input box provided to users, it can only be the range of given numbers import easyguimsg = 'Please enter a number, the range is 0-100 'title = 'and the value type is 'lowerbound = 0 upperbound = default = ''image = 'me.jpg' result = easygui. integerbox (msg, title, default, lowerbound, upperbound, image) print result

Textbox, codebox

# Coding: UTF-8 # _ author _ = 'Mark sinoberg '# _ date _ = '2017/25' # _ Desc _ = easygui also provides support for a large number of texts., and support for Code Text import easyguimsg = 'Big text support 'title = 'text Code' Text = 'plain-/' textContent = easygui. textbox (msg, title, text) codeContent = easygui. codebox (msg, title,) print textContentprint codeContent # D: \ Software \ Python2 \ python.exe E:/Code/Python/M YTestSet/easygui _/text_codebox.py # examples-/# public class HelloWorld {# public static void main (String [] args) {# System. out. println ("Hello World! "); #}### Process finished with exit code 0

Diropenbox

# Coding: UTF-8 # _ author _ = 'Mark sinoberg '# _ date _ = '2017/25' # _ Desc _ = this function is used to provide a dialog box, returns the name of the selected Directory, which has a complete path # If Cancel is selected, the returned value is Noneimport easyguimsg = 'by default, the complete directory of the file will be returned. The 'title = 'file selection dialog box 'default = r'f: \ flappy-Bird' full _ file_path = easygui. diropenbox (msg, title, default) print 'the complete path of the selected file is:' + str (full_file_path) # D: \ Software \ Python2 \ python.exe E: /Code/Python/MyTestSet/easygui _/diropenbox. py # The complete path of the selected file is: F: \ flappy-bird # Process finished with exit code 0

Fileopenbox

# Coding: UTF-8 # _ author _ = 'Mark sinoberg '# _ date _ = '2017/25' # _ Desc _ = this method is used to provide a dialog box, return the selected file name with the complete path. Select Cancel to return None # default = "c:/fishc /*. py shows all Python files in the C: \ fishc folder. # Default = "c:/fishc/test *. py": displays all Python files whose names start with test in the C: \ fishc folder. # The filetypes parameter is a list of strings containing the file mask. Remember it as a list. For example, filetypes = ["*. css ",["*. htm ","*. html "," HTML files "] import easyguimsg = 'return the complete path of the selected file. If you select Cancel, None 'title =' file selector 'default = 'e: /Code/Python/MyTestSet/easygui /*. py 'opened _ files = easygui. fileopenbox (msg, title, default, multiple = True) for item in opened_files: print item # D: \ Software \ Python2 \ python.exe E: /Code/Python/MyTestSet/easygui _/fileopenbox. py # E: \ Code \ Python \ MyTestSet \ easygui _ \ me.jpg # E: \ Code \ Python \ MyTestSet \ easygui _ \ buttonbox. py # E: \ Code \ Python \ MyTestSet \ easygui _ \ choicesbox. py # E: \ Code \ Python \ MyTestSet \ easygui _ \ diropenbox. py # E: \ Code \ Python \ MyTestSet \ easygui _ \ enterbox. py # E: \ Code \ Python \ MyTestSet \ easygui _ \ fileopenbox. py # E: \ Code \ Python \ MyTestSet \ easygui _ \ integerbox. py ## Process finished with exit code 0

Filesavebox

# Coding: UTF-8 # _ author _ = 'Mark sinoberg '# _ date _ = '2017/25' # _ Desc _ = This function provides a dialog box, let the user select the path to save the file (with the complete path) and select Cancel to return None # The default parameter should contain a file name (for example, the file name to be saved ), of course, you can also set it to null or include a wildcard with a file format mask. # For filetypes, see the preceding fileopenboximport easyguimsg = 'save your file' title = "to Save file" default = 'e:/Code/Python/MyTestSet/easygui/newFile. * 'savedfile = easygui. filesavebox (msg, title, default) print savedfileprint 'Of course, this is just a complete path with a file name, and will not be really saved as a file, to save the file, you must use another library '# D: \ Software \ Python2 \ python.exe E:/Code/Python/MyTestSet/easygui _/filesavebox. py # E: \ Code \ Python \ MyTestSet \ easygui _ \ newFile.doc # Of course, this is just a complete path with a file name and won't be saved as a file, other libraries are required to save the file # Process finished with exit code 0

Predictionbox

# Coding: UTF-8 # _ author _ = 'Mark sinoberg '# _ date _ = '2017/25' # _ Desc _ = This is a very useful dialog box, when an application Exception occurs, you can use this to give a user-friendly interface with the prompt import easyguitry: int ('exception') handle T: easygui. predictionbox ('int type data conversion error! Check your data type! ') # An interface is displayed. You can customize the content, as shown in the preceding figure. The following content is the error information tracked # Traceback (most recent call last): # File "E:/Code/Python/MyTestSet/easygui _/exceptionbox. py ", line 10, in <module> # int ('exception') # ValueError: invalid literal for int () with base 10: 'exception'

Summary

After reading these examples, I must be confident in easygui's simple desktop applets. (^__ ^) Xi ......

However, it is far from enough to grasp the complex tasks. Therefore, we need to explore other Python-related modules. In this way, you can select the most appropriate module for development based on the difficulty of the task.

Thank you for reading this article. I hope it will help you. Thank you for your support for this site!

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.