[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
if key in db: record = db[key] # update existing record else: # or make/store new rec record = Person(name='?', age='?') # eval: ...
age => 55 job => None pay => None Key? => Step 5: Adding a GUI The console-based interface approach of the preceding ...
You can launch this example in IDLE, from a console command line, or by clicking its icon—the same way you can run other Python ...
on buttons instead of text), but part of the power of tkinter is that we need to set only the options we are interested in tailo ...
Example 1-26. PP4E\Preview\attachgui.py from tkinter import * from tkinter102 import MyGui main app window mainwin = Tk() Label( ...
class CustomGui(MyGui): # inherit init def reply(self): # replace reply showinfo(title='popup', message='Ouch!') if name == 'mai ...
Example 1-28. PP4E\Preview\tkinter103.py from tkinter import * from tkinter.messagebox import showinfo def reply(name): showinfo ...
Python tkinter GUIs and provide an even more professional look and feel. To hint at what is to come, let’s put tkinter to work o ...
def makeWidgets(): global entries window = Tk() window.title('People Shelve') form = Frame(window) form.pack() entries = {} for ...
Notice how the end of this script opens the shelve as a global variable and starts the GUI; the shelve remains open for the life ...
Notice how we’re using repr again to display field values fetched from the shelve and eval to convert field values to Python obj ...
More usefully, we could pass in the fieldnames tuple as an input parameter to the functions here to allow them to be used for o ...
Other GUI toolkits for Python have pros and cons of their own, discussed later in this book. For example, some exchange code sim ...
keeps changing the color used in the main window, and another that keeps expanding the main window label’s font. Be careful if y ...
the form or the address used to contact the server, is run on the server and produces another HTML page as a reply. Along the wa ...
HTML file, this Python script resides on the same machine as the web server; it’s run on the server machine to handle the inputs ...
Also note that the CGI script in Example 1-31 isn’t printing complete HTML: the and tags of the static HTML file in Example 1- ...
CGI-capable and portable HTTP web server in just 8 lines of code (and a whopping 16 if we include comments and blank lines). As ...
and server (web server) are just different processes running at the same time on the same computer. Though not meant for enterpr ...
far or by sending the server an explicit URL (Internet address) string that contains inputs at the end. Such an explicit URL can ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf