[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
In short, tkinter’s Text and other text-related widgets such as Entry support display of International character sets for both s ...
>>> >>> print(T.get('1.0', 'end')) Bytesfileline1 Textfileline1 Textfileline2 Bytesfileline2 This makes it eas ...
>>> s = b.decode('utf8') UnicodeDecodeError: 'utf8' codec can't decode bytes in position 1-2: invalid dat... >>&g ...
>>> x 'AÄBäC' >>> x = s.encode('utf-8').decode('latin-1') # decoding works, result is garbage >>> x U ...
Unicode text in files Now, the same rules apply to text files, because Unicode strings are stored in files as encoded bytes. Whe ...
>>> t = Text() >>> t.insert('1.0', open('udata', 'rb').read()) >>> t.pack() # string appears in GUI O ...
exceptions or try alternative schemes; this is especially true on platforms where ASCII may be the default platform encoding. Th ...
Tcl attempts to convert byte strings to its internal UTF-8 format, and generally supports translation using the platform and lo ...
displayed. The following avoids the extra end-of-line spaces—we open for input in binary mode for undecoded bytes, but drop \r: ...
open’s encoding on saves, and even internal program values (parsed from email head- ers, for instance). These sources are attemp ...
text = Text() text.config(font=('courier', 15, 'normal')) # set font for all text.config(width=20, height=12) text.pack(expand=Y ...
construction. As you can probably tell, though, the Text widget offers more GUI pro- gramming options than we have space to list ...
When run, this script draws the window captured in Figure 9-23. We saw how to place a photo on canvas and size a canvas for a ph ...
increase to the right and down, respectively. To draw and embed objects within a can- vas, you supply one or more (X,Y) coordina ...
Object identifiers and operations Although not used by the canvas1 script, every object you put on a canvas has an iden- tifier, ...
canvas.addtag_withtag('bubbles', objectId) canvas.move('bubbles', diffx, diffy) This makes three ovals and moves them at the sam ...
self.canvas = canv def fillContent(self, canv): # override me below for i in range(10): canv.create_text(150, 50+(i*100), text=' ...
Sizes are given as configuration options. To specify a view area size, use canvas width and height options. To specify an overal ...
Scrollable Canvases and Image Thumbnails At the end of Chapter 8, we looked at a collection of scripts that display thumbnail im ...
hbar.pack(side=BOTTOM, fill=X) # so clipped first canvas.pack(side=TOP, fill=BOTH, expand=YES) vbar.config(command=canvas.yview) ...
«
25
26
27
28
29
30
31
32
33
34
»
Free download pdf