|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
做一个界面,为什么滚动条不能用?弄了5天了,实在解决不了,求大神帮助,谢谢,代码如下:
import tkinter as tk
from tkinter import ttk
def cbBegin(self):
pass
def sel_result():
pass
def get_result():
pass
def get_data(filename):
pass
mb_col = ['A','B','C','D','E','F','G','H','I','J','K']
xx_col = ['A','B','C','D','E']
root = tk.Tk() # 创建一个窗口
root.title('AAAA') # 窗口标题
root.geometry("430x300+370+150")
srb = ttk.Scrollbar(root)
frm = tk.Text(root, height='8', width='20')
global listC
listC = []
tk.Label(root, text='AAAAAAAA', height=1, width=20, \
padx=0,pady=10,background='green', foreground='white').grid(row=0,column=0)
tk.Label(root, text='DDDDDDDD', height=1, width=20, \
padx=0,pady=10,background='green', foreground='white').grid(row=0,column=1)
for i, m in enumerate(mb_col):
lab = ttk.Label(frm, text=m, width=20)
frm.window_create(tk.INSERT,window=lab)
lab.grid(row=i + 1,column=0, padx=5, pady=5, columnspan=2)
cv = tk.StringVar()
cmb = ttk.Combobox(frm, values= xx_col, textvariable=cv, width=30)
frm.window_create(tk.INSERT,window=cmb)
listC.append(cmb)
cmb.grid(row=i + 1, column=4, padx=5, pady=5, columnspan=3)
cmb.bind('<FocusIn>', cbBegin) # 得到焦点时执行
srb.config(command=frm.yview)
frm.config(yscrollcommand=srb.set)
srb.grid(row=1, column=2, rowspan=i, sticky=tk.S + tk.N)
frm.grid(row=1,column=0,columnspan=2, sticky=tk.S + tk.N)
tk.Button(root, text="确定", command=get_result, height=1, width=7, \
padx=10, pady=1, bg='orange').grid(row=i+1,column=0,padx=5, pady=5)
tk.Button(root, text="退出", command=root.quit, height=1, width=7, \
padx=10, pady=1, bg='orange').grid(row=i+1,column=1, padx=5, pady=5)
root.mainloop()
import tkinter as tk
from tkinter import ttk
def cbBegin(self):
pass
def sel_result():
pass
def get_result():
pass
def get_data(filename):
pass
mb_col = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N']
xx_col = ['A','B','C','D','E']
root = tk.Tk() # 创建一个窗口
root.title('AAAA') # 窗口标题
frm = tk.Text(root,height='28', width='61')
listC = []
tk.Label(root, text='AAAAAAAA', height=1, width=20, \
padx=0,pady=10,background='green', foreground='white').grid(row=0,column=0)
tk.Label(root, text='DDDDDDDD', height=1, width=20, \
padx=0,pady=10,background='green', foreground='white').grid(row=0,column=1)
for i, m in enumerate(mb_col):
lab = tk.Label(frm, text=m, width=20)
frm.window_create(tk.INSERT,window=lab)
cv = tk.StringVar()
cmb = ttk.Combobox(frm, values= xx_col, textvariable=cv, width=30)
frm.window_create(tk.INSERT,window=cmb)
listC.append(cmb)
cmb.bind('<FocusIn>', cbBegin) # 得到焦点时执行
frm.insert(tk.END,'\n\n')
srb = tk.Scrollbar()
srb.grid(columnspan=3,sticky=tk.E+tk.N+tk.S)
srb.config(command=frm.yview)
frm.config(yscrollcommand=srb.set,state=tk.DISABLED)
frm.grid(row=1,column=0,columnspan=3, sticky=tk.S + tk.N)
tk.Button(root, text="确定", command=get_result, height=1, width=7, \
padx=10, pady=1, bg='orange').grid(row=i+1,column=0,padx=5, pady=5)
tk.Button(root, text="退出", command=root.quit, height=1, width=7, \
padx=10, pady=1, bg='orange').grid(row=i+1,column=1, padx=5, pady=5)
root.mainloop()
|
|