嗨,我正在尝试创建一个带有标签、文本框、按钮等的 Python GUI,下面是我运行良好的代码。
问题:在我的按钮旁边,其余(标签,tb,列表框)都显示在另一个框架中。有没有办法在一个框架中打开并显示所有内容?
from Tkinter import *
import webbrowser
import tkMessageBox
import Tkinter as Tk
def actionDirectory():
webbrowser.open('C:\AgmPlots')
def actionOpenFile():
print "Done"
win = Tk.Toplevel() #Open up connection and declare button and label
frame = Tk.Frame(master=win).grid(row=1, column=1)
Lb1 = Listbox(win)
Lb1.insert(1, "Python")
Lb1.insert(2, "Perl")
Lb1.insert(3, "C")
Lb1.insert(4, "PHP")
Lb1.insert(5, "JSP")
Lb1.insert(6, "Ruby")
Lb1.pack()
button = Tk.Button(master=frame, text='Open Folder', command=actionDirectory)
button1 = Tk.Button(master=frame, text='Open Text', command=actionOpenFile)
button.pack()
button1.pack()
win.mainloop()