?? tmpl_tutorial.html
字號:
<html><head><title>Urwid %version% Tutorial</title><style type="text/css"> h1 { text-align: center; } h2 { margin: 40px 0 0 0; padding: 10px; background: #6d96e8;} h3 { margin: 0 0 3px 0; padding: 12px 6px 6px 6px; background: #efef96;} .code { background: #dddddd; padding: 5px; margin: 7px 20px; } .l1 { margin: 12px 0 0 0; } .l2 { margin-left: 20px; } .shot { padding: 5px 20px 5px 0px; float: left; } .back { font-size:small; padding-left: 20px; }</style><body><a name="top"></a><h1>Urwid %version% Tutorial</h1><div style="text-align: center;"><a href="http://excess.org/urwid/">Urwid Home Page</a> /<a href="http://excess.org/urwid/examples.html">Example Screenshots</a> /<a href="http://excess.org/urwid/utf8examples.html">UTF-8 Screenshots</a> /Tutorial /<a href="reference.html">Reference</a></div><br><table width="100%"><tr><td width="50%" valign="top">%toc_left%</td><td width="50%" valign="top">%toc_right%</td></tr></table>{contents}<div style="background:#ffff33; padding: 5px"><h1>Urwid Tutorial Template File</h1>This file is used by <b>docgen_tutorial.py</b> to generate the tutorialdocumentation <b>tutorial.html</b>.<p></div><div style="background:#ffffaa;"><br>Items in the list that follows are parsed by docgen_tutorial.py. Each item has a tag and a name, separated by a tab character. Items without tags are new sections. A --- separates the left and right columns in the table of contents.<pre><b>Tag Section or Item Name</b>{section_data} Hello World Examplemin Minimal Urwid Applicationtext Text and Filler Widgetsattr AttrWrap Widgets and Text Attributesresize Live Resizing Conversation Exampleedit Edit Widgetsfrlb Frame and ListBox Widgetslbcont Modifying ListBox Content Zen of ListBoxlbscr ListBox Focus and Scrollinglbdyn Dynamic ListBox with List Walkerlbfocus Setting the Focus--- Combining Widgetspile Piling Widgetscols Dividing into Columnsgrid GridFlow Arrangementoverlay Overlay Widgets Creating Custom Widgetswmod Modifying Existing Widgetswanat Anatomy of a Widgetwsel Creating Selectable Widgetswcur Widgets Displaying the Cursor{/section_data}</pre></div><p>{toc_section}<div class="l1">%snum%. %name%</div>{/toc_section}<p>{toc_item}<div class="l2"><a href="#%tag%">%snum%.%inum%. %name%</a></div>{/toc_item}<p>{section_head}<h2>%snum%. %name%</h2>{/section_head}<p>{section_body}<h3><a name="%tag%">%snum%.%inum%. %name%</a><span class="back">[<a href="#top">back to top</a>]</span></h3>%content%<br clear="left"><br>{/section_body}<br clear="left"><hr>{body[min]}This program displays the string "Hello World" in the top left cornerof the screen and waits for a keypress before exiting.<pre class="code">%example[0]%</pre><ul><li>The <a href="reference.html#curses_display.Screen">curses_display.Screen</a>class provides access to the curses library. Its member function<a href="reference.html#Screen-run_wrapper">run_wrapper</a> initializescurses full-screen mode and then calls the "run" function passed. It willalso take care of restoring the screen when the "run" function exits.<li>A <a href="reference.html#TextCanvas">TextCanvas</a> is createdcontaining one row with the string "Hello World".<li>The canvas is passed to the <a href="reference.html#Screen-draw_screen">draw_screen</a> function alongwith a fixed screen size of 20 columns and 1 row. If theterminal window this program is run from is larger than 20 by 1 the text will appear in the top left corner.<li>The <a href="reference.html#Screen-get_input">get_input</a> functionis then called until it returns something. It must be called in a loopbecause by default it will time out after one second and return an empty list when there is no input.</ul>Creating canvases directly in this way is generally only done whenwriting custom widget classes. Note that the draw_screenfunction must be passed a canvas and a screen size that matches it,for backwards compatibility.<div align="center">%result[0]%</div>{/body[min]}<br clear="left"><hr>{body[text]}This program displays the string "Hello World" in the center of the screenand waits for a keypress before exiting.<pre class="code">%example[0]%</pre><ul><li><a href="reference.html#Screen-get_cols_rows">get_cols_rows</a>is used to get the dimensions from the terminal and store them as "cols"and "rows".<li>A <a href="reference.html#Text">Text</a> widget is created containingthe string "Hello World". It is set to display with "center" alignment. Text widgets are a kind of <a href="reference.html#FlowWidget">FlowWidget</a>.Flow widgets can fill one or more rows, depending on their content and the number of columns available. Text widgets use more than one row whenthey contain newline characters or when the text must be split across rows.<li>A <a href="reference.html#Filler">Filler</a> widget is created towrap the text widget. Filler widgets are a kind of <a href="reference.html#BoxWidget">BoxWidget</a>. Box widgets have a fixednumber of columns and rows displayed. This widget will pad the "Hello World" text widget until it fills the required number of rows.<li>A canvas is created by calling the <a href="reference.html#Filler-render">render</a> function on the topmostwidget. The filler render function will call the render function of the "Hello World" text widget and combine its canvas withpadding rows to fill the terminal window.</ul>Flow widgets and box widgets are not interchangeable. The first parameterof the render function of a box widget is a two-element tuple (columns,rows) and the first parameter of the render function of a flow widget is a one-element tuple (columns, ). This difference makes sure that when the wrong type of widget is used,such as a box widget inside a filler widget, a ValueError exception will be thrown.<div align="center">%result[0]%</div>{/body[text]}<br clear="left"><hr>{body[attr]}This program displays the string "Hello World" in the center of the screen.It uses different attributes for the text, the space on either sideof the text and the space above and below the text. It waits for a keypress before exiting.<pre class="code">%example[0]%</pre><ul><li>After creating the <a href="reference.html#curses_display.Screen">curses_display.Screen</a> objectand before calling <a href="reference.html#Screen-run_wrapper">run_wrapper</a>,<a href="reference.html#Screen-register_palette">register_palette</a> is calledto set up some attributes: <ul> <li>"banner" is black text on a light gray background, or reversed attributes and underlined in monochrome mode <li>"streak" is black text on a dark red background, or reversed attributes in monochrome mode <li>"bg" is black text on a dark blue background, or normal in monochrome mode </ul><li>A <a href="reference.html#Text">Text</a> widget is created containingthe string " Hello World " with attribute "banner". The attributes of textin a Text widget is set by using a (attribute, text) tuple instead of asimple text string.<li>An <a href="reference.html#AttrWrap">AttrWrap</a> widget is created towrap the text widget with attribute "streak". AttrWrap widgets will set the attribute of everything that they wrap that does not already have anattribute set. In this case the text has an attribute, so only the areasaround the text used for alignment will be have the new attribute.<li>A <a href="reference.html#Filler">Filler</a> widget is created towrap the AttrWrap widget and fill the rows above and below it.<li>A second <a href="reference.html#AttrWrap">AttrWrap</a> widget is created towrap the filler widget with attribute "bg".<li>A canvas is created by calling the <a href="reference.html#AttrWrap-render">render</a> function on the topmostwidget. </ul>AttrWrap widgets will behave like flow widgets or box widgets depending onhow they are called. The filler widget treats the first AttrWrap widget asa flow widget when calling its render function, so the AttrWrap widget calls the text widget's render function the same way. The second AttrWrap isused as the topmost widget and treated as a box widget, so it calls the filler render function in the same way.<div align="center">%result[0]%</div>{/body[attr]}<br clear="left"><hr>{body[resize]}This program displays the string "Hello World" in the center of the screen.It uses different attributes for the text, the space on either sideof the text and the space above and below the text. When the window isresized it will repaint the screen, and it will exit when Q is pressed.<pre class="code">%example[0]%</pre>The <a href="reference.html#Screen-get_input">get_input</a> function willreturn "window resize" among keys pressed when the window is resized. Itis a good idea to check for uppercase and lowercase letters on inputto avoid confusing users.<div class="shot">%result[0]%</div><div class="shot">%result[1]%</div><div class="shot">%result[2]%</div><div class="shot">%result[3]%</div>{/body[resize]}<br clear="left"><hr>{body[edit]}This program asks for your name then responds "Nice to meet you, (your name)."
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -