文件操作 - index.html
返回文件管理
返回主菜单
删除本文件
文件: /usr/share/doc/python2-easygui-0.96/cookbook/index.html
编辑文件内容
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.0//EN" "html.dtd"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> <META NAME="resource-type" CONTENT="document"> <TITLE>EasyGui Cookbook</TITLE> <STYLE REL="stylesheet" TYPE="text/css"> <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ BEGIN easygui_webpage.css style for EasyGui web pages. Uses sans-serif fonts for screen readability. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> html { font-family: FreeSans /* for Linux browsers */ , "Lucida Sans Unicode" , "Verdana" , "Tahoma" , "Helvetica" , "arial" , "sans-serif" , "proportional" ; color: rgb(56,56,56); background-color: rgb(230,230,230); } h1 {text-align: center} h2, h3, h4, h5 {text-align: left} .subtitle {text-align:center;} h1 {text-align: center} note {font-size: small} td.heading{text-align:center} td {text-align: left; vertical-align:top} th {text-align:center; vertical-align:top} hr { background-color: #D2B48C; /* #D2B48C = tan */ border-color: #D2B48C; width: 100%; height: 0.5em; border-style: solid; } pre{ background-color:#FFFFFF; margin:10px; padding: 10px } <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ END easygui_webpage.css ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> </STYLE> </HEAD> <BODY> <H1>EasyGui Cookbook</H1> <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MENUBAR begin ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> <TABLE WIDTH="100%" CELLPADDING="5" CELLSPACING="0"> <TR><TD BGCOLOR="lightgrey" VALIGN="TOP" align="left"> <A HREF="http://easygui.sourceforge.net">EasyGui Home</A> <A HREF="../index.html">Version Home</A> <A HREF="../pydoc/easygui_pydoc.html">Pydoc Docs</A> <A HREF="../epydoc/index.html">Epydoc Docs</A> <A HREF="../tutorial/index.html">Tutorial</A> <A HREF="../cookbook/index.html">Cookbook</A> <A HREF="../faq/index.html">FAQs</A> <A HREF="http://www.ferg.org/contact_info/index.html">Contact</A> </TD></tr></table> <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ MENUBAR end ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --> <DIV CLASS="table_of_contents"> <!-- ~~~~~~~~~~~~~~~~~~~~ BEGIN TABLE OF CONTENTS ~~~~~~~~~~~~~~~~~~~~ --> <!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Table of contents was automatically generated by program: pyhat.py. Generation date/time: 2008-08-15 16:40:46 For more information: visit www.ferg.org/pyhat ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> <A ID="contents_item_0"></A> <H2>Table of Contents</H2> <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0"> <TR> <TD WIDTH="4%"></TD><TD WIDTH="4%"></TD><TD WIDTH="4%"></TD><TD WIDTH="4%"></TD><TD WIDTH="4%"></TD><TD WIDTH="80%"></TD> </TR> <TR><TD COLSPAN="1"> </TD><TD COLSPAN="5"> <DIV STYLE="text-align:left; text-indent:-3em; margin-left:3em; font-family: sans-serif"><A HREF="#contents_item_0">1</A> <A HREF="#contents_item_1" ID="table_of_contents_1">Introduction</A></DIV></TD> </TR> <TR><TD COLSPAN="1"> </TD><TD COLSPAN="5"> <DIV STYLE="text-align:left; text-indent:-3em; margin-left:3em; font-family: sans-serif"><A HREF="#contents_item_0">2</A> <A HREF="#contents_item_2" ID="table_of_contents_2">Simple demo program</A></DIV></TD> </TR> <TR><TD COLSPAN="1"> </TD><TD COLSPAN="5"> <DIV STYLE="text-align:left; text-indent:-3em; margin-left:3em; font-family: sans-serif"><A HREF="#contents_item_0">3</A> <A HREF="#contents_item_3" ID="table_of_contents_3">Controlling the order of items in choicebox</A></DIV></TD> </TR> </TABLE> <!-- ~~~~~~~~~~~~~~~~~~~~ _END_ TABLE OF CONTENTS ~~~~~~~~~~~~~~~~~~~~ --> </DIV> <H2><SPAN CLASS="contents_item"><A HREF="#table_of_contents_1" ID="contents_item_1"> 1</A> </SPAN>Introduction</H2> <P>This page is still under development. Its purpose will be to hold easygui code snippets and recipes.</P> <H2><SPAN CLASS="contents_item"><A HREF="#table_of_contents_2" ID="contents_item_2"> 2</A> </SPAN>Simple demo program</H2> <P> Here is a simple demo program using easygui. The screens that it produces are shown on the <A HREF="index.html">easygui home page</A>.</P> <PRE> from easygui import * import sys while 1: msgbox("Hello, world!") msg ="What is your favorite flavor?" title = "Ice Cream Survey" choices = ["Vanilla", "Chocolate", "Strawberry", "Rocky Road"] choice = choicebox(msg, title, choices) # note that we convert choice to string, in case # the user cancelled the choice, and we got None. msgbox("You chose: " + str(choice), "Survey Result") msg = "Do you want to continue?" title = "Please Confirm" if ccbox(msg, title): # show a Continue/Cancel dialog pass # user chose Continue else: sys.exit(0) # user chose Cancel</PRE> <H2 ID="choicebox_order"><SPAN CLASS="contents_item"><A HREF="#table_of_contents_3" ID="contents_item_3"> 3</A> </SPAN>Controlling the order of items in choicebox</H2> <P>In a choicebox, the choices must be in sort order so that the keyboard "jump to" feature (jump down in the list by pressing keyboard keys) will work. But it often happens that a sort of first-cut listing of choices doesn't sort in a user-friendly order. So what can you do to control the order of the items displayed in a choicebox?</P> <P>A useful technique is to specify keys for the items in the choicebox. For example, suppose you want a choicebox to display View, Update, Delete, Exit. If you specified your choices this way:</P> <PRE>choices = ["View", "Update", "Delete", "Exit"]</PRE> <P>you'd get this:</P> <PRE>Delete Exit Update View</PRE> <P>It is definitely in alphabetic order, but not very user-friendly. But if you specified keys for your choices this way:</P> <PRE>choices = ["V View", "U Update", "D elete", "X Exit"]</PRE> <P>you'd get this (with "X" appearing at the bottom):</P> <PRE>D Delete U Update V View X Exit </PRE> <P>Suppose you wanted to force <B>View</B> to the top, so it is the easiest choice to select. You could change its key from "V" to "A"</P> <PRE>choices = ["A View", "U Update", "D elete", "X Exit"]</PRE> <P>and you'd get this:</P> <PRE>A View D Delete U Update X Exit</PRE> <P>Another technique is to prepend a space to the choice. Since space characters always sorts before a non-space character, you can use this trick to force something like "V View" to the top of the list.</P> <PRE>choices = [" V View", "U Update", "D Delete", "X Exit"]</PRE> <P>produces this:</P> <PRE> V View D Delete U Update X Exit</PRE> <P>In the proportional font used by choicebox, the space before the "V" is almost imperceptible.</P> <P>Personally, I prefer to use alphabetic keys rather than numeric keys for choicebox items— it is easier to navigate the choices using alpha keys on the keyboard than by using the number keys.</P> <P>And it is possible to use multi-character keys, like this:</P> <PRE>L1 Log old version L2 Log new version</PRE> <P>Using keys for choices also makes it relatively easy to check for the user's selection.</P> <PRE>choices = [" V View", "U Update", "D elete", "X Exit"] choice = choicebox(msg,title,choices) if choice == None: return reply = choice.split()[0] # reply = the first word of the choice if reply == "X": return elif reply == "V": processView() elif reply == "L1": saveLog(version="old") elif reply == "L2": saveLog(version="new") .... </PRE> </BODY> </HTML>
修改文件时间
将文件时间修改为当前时间的前一年
删除文件