⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 listwin.py

📁 minimal python variant for small footprint apps like embedded apps
💻 PY
字号:
# Module 'listwin'# List windows, a subclass of gwinimport gwinimport stdwindef maxlinewidth(a): # Compute maximum textwidth of lines in a sequence	max = 0	for line in a:		width = stdwin.textwidth(line)		if width > max: max = width	return maxdef action(w, string, i, detail): # Default item selection method	passdef mup(w, detail): # Mouse up method	(h, v), clicks, button, mask = detail	i = divmod(v, w.lineheight)[0]	if 0 <= i < len(w.data):		w.action(w, w.data[i], i, detail)def draw(w, ((left, top), (right, bottom))): # Text window draw method	data = w.data	d = w.begindrawing()	lh = w.lineheight	itop = top/lh	ibot = (bottom-1)/lh + 1	if itop < 0: itop = 0	if ibot > len(data): ibot = len(data)	for i in range(itop, ibot): d.text((0, i*lh), data[i])def open(title, data): # Display a list of texts in a window	lineheight = stdwin.lineheight()	h, v = maxlinewidth(data), len(data)*lineheight	h0, v0 = h + stdwin.textwidth(' '), v + lineheight	if h0 > stdwin.textwidth(' ')*80: h0 = 0	if v0 > stdwin.lineheight()*24: v0 = 0	stdwin.setdefwinsize(h0, v0)	w = gwin.open(title)	w.setdocsize(h, v)	w.lineheight = lineheight	w.data = data	w.draw = draw	w.action = action	w.mup = mup	return w

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -