本文整理汇总了Python中Tkinter.Tk.wm_iconname方法的典型用法代码示例。如果您正苦于以下问题:Python Tk.wm_iconname方法的具体用法?Python Tk.wm_iconname怎么用?Python Tk.wm_iconname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tkinter.Tk
的用法示例。
在下文中一共展示了Tk.wm_iconname方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from Tkinter import Tk [as 别名]
# 或者: from Tkinter.Tk import wm_iconname [as 别名]
def test():
app = Tk()
app.wm_title("CropGUI -- lossless cropping and rotation of jpeg files")
app.wm_iconname("CropGUI")
preview = Label(app)
do_crop = Button(app, text="Crop")
info = Label(app)
preview.pack(side="bottom")
do_crop.pack(side="left")
info.pack(side="left")
max_h = app.winfo_screenheight() - 64 - 32
max_w = app.winfo_screenwidth() - 64
drag = DragManager(app, preview, do_crop, info)
app.wm_protocol('WM_DELETE_WINDOW', drag.close)
def image_names():
if len(sys.argv) > 1:
for i in sys.argv[1:]:
yield i
else:
while 1:
names = askopenfilename(
master=app,
defaultextension=".jpg", multiple=1, parent=app,
filetypes=(
("JPEG Image Files", ".jpg .JPG .jpeg .JPEG"),
("All files", "*"),
),
title="Select images to crop")
if not names:
break
for name in names:
yield name
pids = set()
def reap():
global pids
pids = set(p for p in pids if p.poll() is None)
for image_name in image_names():
img = Image.open(image_name)
iw, ih = img.size
scale = 1
while iw > max_w or ih > max_h:
iw /= 2
ih /= 2
scale *= 2
img.thumbnail((iw, ih))
drag.image = img
drag.round = max(1, 8/scale)
if not drag.wait():
continue # user hit "next" (tba) without cropping
base, ext = os.path.splitext(image_name)
t, l, r, b = drag.top, drag.left, drag.right, drag.bottom
t *= scale
l *= scale
r *= scale
b *= scale
cropspec = "%dx%d+%d+%d" % (r-l, b-t, l, t)
target = base + "-crop" + ext
target = open(target, "wb")
pids.add(subprocess.Popen(
['jpegtran', '-optimize', '-progressive', '-crop', cropspec, image_name],
stdout=target))
target.close()
while pids:
reap()
sys.stdout.write("Waiting for %d children to exit. \r" % len(pids))
sys.stdout.flush()
time.sleep(.1)
sys.stdout.write(" "*79 + "\r")