|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
现在我写的code效果是两个button并排,且靠左。
求解,怎么才能让这两个button上下排列呢?(还是靠左)
- import tkinter as tk
- def pressed():
- """
- Button callback function (command).
- You may alter what this function does if you wish, but you must not rename
- or delete it.
- """
- print("Button Pressed!")
- def create_layout(frame):
- """
- Add two buttons to the frame.
- Both buttons should have the callback (command) pressed, and they should
- have the labels "Button1" and "Button2".
- The layout in the frame after running this function will be:
- +-----------------------+
- |[Button1][Button2] |
- +-----------------------+
- Args:
- frame (tk.Frame): The frame to create the two buttons in.
- """
- button1 = tk.Button(frame, text = "Button1", command = pressed)
- button1.pack(side = tk.LEFT)
- button2 = tk.Button(frame, text = "Button2", command = pressed)
- button2.pack(side = tk.LEFT)
复制代码
这样的么?
可以参考以下代码:
- # 界面部分
- openButton = Button(root, text="打开文件", command=openFile).pack()
- vopen = StringVar()
- vopen.set("未选定任何文件")
- openLabel = Label(root, textvariable=vopen).pack()
- vupdate = StringVar()
- vupdate.set("暂无任何更新")
- updateButton = Button(root, text="更新文件", command=updateFile).pack()
- updateLabel =Label(root, textvariable=vupdate).pack()
复制代码
|
|