我使用'for'循环来创建由'Label'对象制作的表格。除了'divider'之外,每个循环都附加到它自己的二维数组(每列有十三个'标签');我想在每个对象的各个表中给出一个索引位置,这样我就可以引用这些点并改变'Label'的内容。
def stock_append(entry_grid_exp, entry_grid_req):
for Label in entry_grid_exp:
Label.configure(text="test")
提交按钮调用函数'stock_append'并传递'entry_grid_exp'和'entry_grid_req'参数。我读了一篇文章说,将列表放入'for'循环并将列表中的每个项目归为'Label'将允许我调用'configure'函数,但它似乎不起作用。此外,这个循环(如果有效)将配置'entry_grid_exp'中的每个项目而不是一个特定的位置。
from tkinter import *
root = Tk()
Med_font = ("Helvatica", 11)
Small_font = ("Helvatica", 9)
main = Frame(root, bg="#dcdcdc", height=600, width=600)
main.grid()
s_name = StringVar()
s_category = StringVar()
s_description = StringVar()
s_quantity = StringVar()
s_risk = StringVar()
s_ID = StringVar()
def stock_append(entry_grid_exp, entry_grid_req, program):
for item in entry_grid_exp:
Label.configure(program, text="test")
def stock_define(entry_grid_exp, entry_grid_req, program):
stock_frame = Frame(main, bg="#dcdcdc", height=100, width=1000)
stock_frame.grid()
name = Entry(stock_frame, width=15, textvariable=s_name)
name.grid(row=1, column=1, padx=10)
category = Entry(stock_frame, width=15, textvariable=s_category)
category.grid(row=1, column=2, padx=10)
description = Entry(stock_frame, width=15, textvariable=s_description)
description.grid(row=1, column=3, padx=10)
quantity = Entry(stock_frame, width=15, textvariable=s_quantity)
quantity.grid(row=1, column=4, padx=10)
risk = Entry(stock_frame, width=15, textvariable=s_risk)
risk.grid(row=1, column=5, padx=10)
stock_id = Entry(stock_frame, width=15, textvariable=s_ID)
stock_id.grid(row=1, column=6, padx=10)
submit = Button(stock_frame, width=15, text="submit", command=lambda: stock_append(entry_grid_exp, entry_grid_req,
program))
submit.grid(row=1, column=7, padx=10)
def stock_lists():
program = Frame(main, bg="#dcdcdc", height=600, width=600)
program.grid()
title = Label(program, text="MAIN", font=Med_font, bg="#dcdcdc")
title.grid(row=2, column=1)
entry_grid_exp = []
entry_grid_req = []
exp_list = Frame(program, bg="#dcdcdc", height=500, width=600)
exp_list.grid(row=3, column=1)
stock_add = Button(exp_list, bg="#bebebe", width=10, text="ADDSTCK", command=lambda: stock_define(entry_grid_exp,
entry_grid_req,
program))
stock_add.grid(row=4, column=15)
experiment_list = Label(exp_list, width=10, bg="#dcdcdc", fg="#000000", text="Experiment list.")
experiment_list.grid(row=4, column=1)
for i in range(1, 16):
entry_column = []
for x in range(0, 13):
entry_column.append(Label(exp_list, width=15, bg="#FFFFFF", relief=SUNKEN))
entry_column[x].grid(row=x+6, column=i, padx=0, pady=0)
entry_grid_exp.append(entry_column)
for i in range(1, 16):
divider = Label(exp_list, width=10, bg="#dcdcdc", fg="#dcdcdc", text="divider")
divider.grid(row=21, column=i)
request_list = Label(exp_list, width=10, bg="#dcdcdc", fg="#000000", text="Requested list.")
request_list.grid(row=20, column=1)
for i in range(1, 16):
entry_column = []
for x in range(0, 6):
entry_column.append(Label(exp_list, width=15, bg="#FFFFFF", relief=SUNKEN))
entry_column[x].grid(row=x+21, column=i, padx=0, pady=0)
entry_grid_req.append(entry_column)
stock_lists()
mainloop()
我正在尝试完成这个项目而且完全迷失了,并且非常感谢任何帮助,因为我不知道我在做什么。
更新示例
\DB::table('table_name')
->where(function($q){
$q->where('column', 'value1')
->orWhere('column', 'value2');
})
->where('column2', 'LIKE', '%value3%');