-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest4.py
118 lines (103 loc) · 4.34 KB
/
test4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from controllers.crud import assign_item_to_employee, get_all_employees, get_all_employees_ids, get_employee, get_item
from models.models import Employee, EmployeeItem, Item
from utils.search import search_items
from models.database import SessionLocal, session_scope
"""
list_employees = get_all_employees_ids()
for employee in list_employees:
x = assign_item_to_employee(employee, 2, unique_key="-")"""
"""results = search_items("")
for idx, item in enumerate(results, 1):
print(idx, item)
if item['attributes']:
for i, attr in enumerate(item['attributes']):
print(attr)
"""
"""
def add_attribute_row(self, name='', value=''):
row_frame = ctk.CTkFrame(self.attributes_container, fg_color="transparent")
row_frame.pack(fill="x", pady=5)
# Existing attributes dropdown
attribute_combo = ctk.CTkComboBox(
row_frame,
values=["Brand", "Model", "Serial Number", "Create New"],
font=ctk.CTkFont(size=14),
fg_color=COLORS["black"],
border_color=COLORS["ash"],
button_color=COLORS["pink"],
button_hover_color=COLORS["darker_pink"],
dropdown_fg_color=COLORS["black"],
width=200
)
# Attribute name entry (hidden initially)
name_entry = ctk.CTkEntry(
row_frame,
placeholder_text="Attribute Name",
font=ctk.CTkFont(size=14),
fg_color=COLORS["black"],
border_color=COLORS["ash"],
width=200
)
# Value entry
value_entry = ctk.CTkEntry(
row_frame,
placeholder_text="Value",
font=ctk.CTkFont(size=14),
fg_color=COLORS["black"],
border_color=COLORS["ash"],
width=200
)
# Remove button
remove_btn = ctk.CTkButton(
row_frame,
text="×",
width=40,
height=40,
font=ctk.CTkFont(size=16),
fg_color=COLORS["pink"],
hover_color=COLORS["darker_pink"],
command=lambda: self.remove_attribute_row(row_frame)
)
def on_attribute_select(choice):
if choice == "Create New":
attribute_combo.pack_forget()
value_entry.pack_forget()
name_entry.pack(side="left", padx=(0, 10))
value_entry.pack(side="left", padx=(0, 10))
remove_btn.pack_forget()
remove_btn.pack(side="left")
# Update collect_attributes
if attribute_combo in self.collect_attributes:
del self.collect_attributes[attribute_combo]
self.collect_attributes[name_entry] = value_entry
else:
if name_entry.winfo_manager(): # If name_entry is visible
name_entry.pack_forget()
attribute_combo.pack(side="left", padx=(0, 10))
value_entry.pack(side="left", padx=(0, 10))
remove_btn.pack(side="left")
# Update collect_attributes
if name_entry in self.collect_attributes:
del self.collect_attributes[name_entry]
self.collect_attributes[attribute_combo] = value_entry
attribute_combo.configure(command=on_attribute_select)
# If we have existing values, set them up
if name and name in ["Brand", "Model", "Serial Number"]:
attribute_combo.set(name)
attribute_combo.pack(side="left", padx=(0, 10))
value_entry.insert(0, value)
value_entry.pack(side="left", padx=(0, 10))
remove_btn.pack(side="left")
self.collect_attributes[attribute_combo] = value_entry
elif name: # Custom attribute
attribute_combo.set("Create New")
on_attribute_select("Create New")
name_entry.insert(0, name)
value_entry.insert(0, value)
else: # New empty row
attribute_combo.pack(side="left", padx=(0, 10))
value_entry.pack(side="left", padx=(0, 10))
remove_btn.pack(side="left")
self.collect_attributes[attribute_combo] = value_entry
self.attribute_rows.append(row_frame)
"""