[Python编程(第4版)].(Programming.Python.4th.Edition).Mark.Lutz.文字版
Figure 9-25. Scrolled thumbnail image viewer Or simply run the script as is from a command line, by clicking its file icon, or w ...
Scrolling images too: PyPhoto (ahead) Despite its evolutionary twists, the scrollable thumbnail viewer in Example 9-15 still has ...
canvas.bind('', self.onClear) # delete all canvas.bind('', self.onMove) # move latest self.canvas = canvas self.drawn = None sel ...
mouse location, you need a starting point; to delete before a redraw, you also must remember the last drawn object’s identifier. ...
Binding events on specific items Much like we did for the Text widget, it is also possible to bind events for one or more specif ...
the script uses the canvas find_closest method to fetch the object ID of the particular text item clicked (the one closest to th ...
As mentioned in the preceding chapter, input forms are generally best arranged either as grids or as row frames with fixed-width ...
From the perspective of the container window, the label is gridded to column 0 in the current row number (a counter that starts ...
ent.insert(0, 'grid') row += 1 def packbox(parent): "row frames with fixed-width labels" for color in colors: row = Frame(parent ...
ent.grid(row=row, column=1) ent.insert(0, 'grid') We’ll leave further code compaction to the more serious sports fans in the aud ...
frm = Frame(root, bd=5, relief=RAISED) frm.pack(padx=5, pady=5) gridbox(frm) Label(root, text='Pack:').pack() frm = Frame(root, ...
from tkinter import * from grid2 import gridbox, packbox root = Tk() gridbox(root) packbox(root) Button(root, text='Quit', comma ...
row = 1 for color in colors: lab = Label(root, text=color, relief=RIDGE, width=25) ent = Entry(root, bg=color, relief=SUNKEN, wi ...
Figure 9-33. grid and pack windows resized As coded, shrinking the pack window clips items packed last; shrinking the grid win- ...
space. With grid, the sticky option serves the roles of both fill and anchor in the packer. Gridded widgets can optionally be ma ...
For more on input form layout, stay tuned for the form builder utilities we’ll code near the end of Chapter 12 and use again in ...
Example 9-24. PP4E\Gui\Tour\Grid\grid5.py 2D table of input fields, default Tk root window from tkinter import * rows = [] for i ...
rows = [] for i in range(numrow): cols = [] for j in range(numcol): ent = Entry(relief=RIDGE) ent.grid(row=i, column=j, sticky=N ...
Button(text='Clear', command=onClear).grid(row=numrow+1, column=2) Button(text='Quit', command=sys.exit).grid(row=numrow+1, colu ...
self.sums = [] for i in range(numcol): lab = Label(self, text='?', relief=SUNKEN) lab.grid(row=numrow+1, column=i, sticky=NSEW) ...
«
26
27
28
29
30
31
32
33
34
35
»
Free download pdf