#File: toolbar1.py
from Tkinter import *
root = Tk()
def callback():
print "called the callback!"
toolbar = Frame(root)
b = Button(toolbar, text = "New", width = 6, command = callback)
b.pack(side = LEFT, padx = 2, pady = 2)
b = Button(toolbar, text = "open", width = 6, command = callback)
b.pack(side = LEFT, padx = 2, pady = 2)
toolbar.pack(side = TOP, fill = X)
mainloop()
本文介绍了一种使用Python的Tkinter库创建图形用户界面工具栏的方法。通过定义按钮及其回调函数,实现了简单的GUI工具栏功能,展示了如何将按钮放置在窗口顶部并沿X轴填充。
307

被折叠的 条评论
为什么被折叠?



