itkdb-gtk 0.0.3__py3-none-any.whl → 0.20.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. itkdb_gtk/{sendShipments.py → CreateShipments.py} +74 -78
  2. itkdb_gtk/{getShipments.py → GetShipments.py} +99 -106
  3. itkdb_gtk/GlueWeight.py +45 -66
  4. itkdb_gtk/ITkDB.desktop +8 -0
  5. itkdb_gtk/ITkDB.svg +380 -0
  6. itkdb_gtk/ITkDBlogin.py +10 -6
  7. itkdb_gtk/ITkDButils.py +295 -57
  8. itkdb_gtk/PanelVisualInspection.py +590 -0
  9. itkdb_gtk/QRScanner.py +120 -0
  10. itkdb_gtk/SensorUtils.py +492 -0
  11. itkdb_gtk/ShowAttachments.py +267 -0
  12. itkdb_gtk/ShowComments.py +94 -0
  13. itkdb_gtk/ShowDefects.py +103 -0
  14. itkdb_gtk/UploadModuleIV.py +566 -0
  15. itkdb_gtk/UploadMultipleTests.py +746 -0
  16. itkdb_gtk/UploadTest.py +509 -0
  17. itkdb_gtk/VisualInspection.py +297 -0
  18. itkdb_gtk/WireBondGui.py +1304 -0
  19. itkdb_gtk/__init__.py +38 -12
  20. itkdb_gtk/dashBoard.py +292 -33
  21. itkdb_gtk/dbGtkUtils.py +356 -75
  22. itkdb_gtk/findComponent.py +242 -0
  23. itkdb_gtk/findVTRx.py +36 -0
  24. itkdb_gtk/readGoogleSheet.py +1 -2
  25. itkdb_gtk/untrash_component.py +35 -0
  26. {itkdb_gtk-0.0.3.dist-info → itkdb_gtk-0.20.1.dist-info}/METADATA +21 -12
  27. itkdb_gtk-0.20.1.dist-info/RECORD +30 -0
  28. {itkdb_gtk-0.0.3.dist-info → itkdb_gtk-0.20.1.dist-info}/WHEEL +1 -1
  29. itkdb_gtk-0.20.1.dist-info/entry_points.txt +12 -0
  30. itkdb_gtk/checkComponent.py +0 -131
  31. itkdb_gtk/groundingTest.py +0 -225
  32. itkdb_gtk/readAVSdata.py +0 -565
  33. itkdb_gtk/uploadPetalInformation.py +0 -604
  34. itkdb_gtk/uploadTest.py +0 -384
  35. itkdb_gtk-0.0.3.dist-info/RECORD +0 -19
  36. itkdb_gtk-0.0.3.dist-info/entry_points.txt +0 -7
  37. {itkdb_gtk-0.0.3.dist-info → itkdb_gtk-0.20.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,267 @@
1
+ import sys
2
+ from pathlib import Path
3
+
4
+ try:
5
+ import itkdb_gtk
6
+
7
+ except ImportError:
8
+ from pathlib import Path
9
+ cwd = Path(__file__).parent.parent
10
+ sys.path.append(cwd.as_posix())
11
+
12
+ from itkdb_gtk import dbGtkUtils, ITkDButils
13
+
14
+ import gi
15
+ gi.require_version("Gtk", "3.0")
16
+ from gi.repository import Gtk, Gio, Gdk
17
+
18
+
19
+ def add_attachment_dialog():
20
+ """Create the add attachment dialog."""
21
+ dlg = Gtk.Dialog(title="Add Attachment")
22
+ dlg.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
23
+ Gtk.STOCK_OK, Gtk.ResponseType.OK)
24
+ grid = Gtk.Grid(column_spacing=5, row_spacing=1)
25
+ box = dlg.get_content_area()
26
+ box.add(grid)
27
+
28
+ lbl = Gtk.Label(label="File")
29
+ lbl.set_xalign(0)
30
+ grid.attach(lbl, 0, 0, 1, 1)
31
+
32
+ lbl = Gtk.Label(label="Title")
33
+ lbl.set_xalign(0)
34
+ grid.attach(lbl, 0, 1, 1, 1)
35
+
36
+ lbl = Gtk.Label(label="Description")
37
+ lbl.set_xalign(0)
38
+ grid.attach(lbl, 0, 2, 1, 1)
39
+
40
+ dlg.fC = Gtk.FileChooserButton()
41
+ grid.attach(dlg.fC, 1, 0, 1, 1)
42
+
43
+ dlg.att_title = Gtk.Entry()
44
+ grid.attach(dlg.att_title, 1, 1, 1, 1)
45
+
46
+ dlg.att_desc = Gtk.Entry()
47
+ grid.attach(dlg.att_desc, 1, 2, 1, 1)
48
+
49
+ dlg.show_all()
50
+ return dlg
51
+
52
+
53
+ class ShowAttachments(Gtk.Dialog):
54
+ """Window to show attachments."""
55
+ def __init__(self, title, session, attachments=[], parent=None):
56
+ """Initialization."""
57
+ super().__init__(title=title, transient_for=parent)
58
+ self.session = session
59
+ self.attachments = [A for A in attachments]
60
+ self.init_window()
61
+
62
+ def init_window(self):
63
+ """Prepares the window."""
64
+ self.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
65
+ Gtk.STOCK_OK, Gtk.ResponseType.OK)
66
+
67
+ self.mainBox = self.get_content_area()
68
+ # The "Add attachment" button.
69
+ box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
70
+ self.mainBox.pack_start(box, False, False, 0)
71
+
72
+ dbGtkUtils.add_button_to_container(box, "Add attachment",
73
+ "Click to add a new attachment.",
74
+ self.add_attachment)
75
+
76
+ dbGtkUtils.add_button_to_container(box, "Remove attachment",
77
+ "Click to remove selected attachment.",
78
+ self.remove_attachment)
79
+
80
+ # the list of attachments
81
+ tree_view = self.create_tree_view()
82
+ self.mainBox.pack_start(tree_view, True, True, 0)
83
+ for A in self.attachments:
84
+ self.append_attachment_to_view(A)
85
+
86
+ self.show_all()
87
+
88
+ def create_tree_view(self, size=150):
89
+ """Creates the tree vew with the attachments."""
90
+ model = Gtk.ListStore(str, str, str, str)
91
+ self.tree = Gtk.TreeView(model=model)
92
+ self.tree.connect("button-press-event", self.button_pressed)
93
+
94
+ scrolled = Gtk.ScrolledWindow()
95
+ scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
96
+ scrolled.add(self.tree)
97
+ scrolled.set_size_request(-1, size)
98
+
99
+ renderer = Gtk.CellRendererText()
100
+ column = Gtk.TreeViewColumn("Attachment", renderer, text=0)
101
+ self.tree.append_column(column)
102
+
103
+ renderer = Gtk.CellRendererText()
104
+ column = Gtk.TreeViewColumn("Title", renderer, text=1)
105
+ self.tree.append_column(column)
106
+
107
+ renderer = Gtk.CellRendererText()
108
+ column = Gtk.TreeViewColumn("Description", renderer, text=2)
109
+ self.tree.append_column(column)
110
+
111
+ return scrolled
112
+
113
+ def button_pressed(self, tree, event):
114
+ """Button clicked on top of attachment."""
115
+ # double click shows attachments
116
+ it = None
117
+ model = self.tree.get_model()
118
+ if event.button == 1 and event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS:
119
+ select = self.tree.get_selection()
120
+ model, it = select.get_selected()
121
+ if not it:
122
+ return
123
+
124
+ self.edit_attachment(model, it)
125
+ return
126
+
127
+ if event.button != 3:
128
+ return
129
+
130
+ # Create popup menu
131
+ select = self.tree.get_selection()
132
+ model, it = select.get_selected()
133
+ values = None
134
+ if it:
135
+ values = model[it]
136
+
137
+ else:
138
+ P = tree.get_path_at_pos(event.x, event.y)
139
+ if P:
140
+ it = model.get_iter(P[0])
141
+ values = model[it]
142
+
143
+ if not values:
144
+ return
145
+
146
+ if not it:
147
+ P = self.tree.get_path_at_pos(event.x, event.y)
148
+ if P:
149
+ it = model.get_iter(P[0])
150
+
151
+ if not it:
152
+ return
153
+
154
+ menu = Gtk.Menu()
155
+ item_edit = Gtk.MenuItem(label="Edit")
156
+ item_edit.connect("activate", self.on_edit_attachment, (model, it))
157
+ menu.append(item_edit)
158
+
159
+ item_show = Gtk.MenuItem(label="Show file")
160
+ item_show.connect("activate", self.on_show_file, (model, it))
161
+ menu.append(item_show)
162
+
163
+ menu.show_all()
164
+ menu.popup_at_pointer(event)
165
+
166
+ def edit_attachment(self, model, it):
167
+ """Edit attachment at current row."""
168
+ values = model[it]
169
+ dlg = add_attachment_dialog()
170
+ dlg.fC.set_filename(values[3])
171
+ dlg.att_title.set_text(values[1])
172
+ dlg.att_desc.set_text(values[2])
173
+ rc = dlg.run()
174
+ if rc == Gtk.ResponseType.OK:
175
+ path = Path(dlg.fC.get_filename())
176
+ title = dlg.att_title.get_text()
177
+ desc = dlg.att_desc.get_text()
178
+ model.set_value(it, 0, path.name)
179
+ model.set_value(it, 1, title)
180
+ model.set_value(it, 2, desc)
181
+ model.set_value(it, 3, path.as_posix())
182
+
183
+ dlg.hide()
184
+ dlg.destroy()
185
+
186
+ def on_edit_attachment(self, item, data):
187
+ """Test JSon."""
188
+ model, it = data
189
+ self.edit_attachment(model, it)
190
+
191
+
192
+ def on_show_file(self, item, data):
193
+ """Test JSon."""
194
+ model, it = data
195
+ values = model[it]
196
+ sss = None
197
+ try:
198
+ with open(values[3], "tr", encoding="utf-8") as f:
199
+ sss = f.read()
200
+
201
+ except UnicodeDecodeError:
202
+ dbGtkUtils.complain("Error showing file", "File is not a text file")
203
+ return
204
+
205
+
206
+ dlg = Gtk.Dialog(title="Add Attachment",
207
+ transient_for=self,
208
+ flags=0)
209
+ dlg.add_buttons(Gtk.STOCK_OK, Gtk.ResponseType.OK)
210
+ dlg.set_size_request(300, 200)
211
+ area = dlg.get_content_area()
212
+ box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
213
+ area.add(box)
214
+
215
+ scrolledwindow = Gtk.ScrolledWindow()
216
+ box.pack_start(scrolledwindow, False, True, 0)
217
+
218
+ scrolledwindow.set_hexpand(True)
219
+ scrolledwindow.set_vexpand(True)
220
+ textview = Gtk.TextView()
221
+ textview.get_buffer().set_text(sss)
222
+ scrolledwindow.add(textview)
223
+ dlg.show_all()
224
+ dlg.run()
225
+ dlg.hide()
226
+ dlg.destroy()
227
+
228
+
229
+ def add_attachment(self, *args):
230
+ """Add Attachment button clicked."""
231
+ dlg = add_attachment_dialog()
232
+ rc = dlg.run()
233
+ if rc == Gtk.ResponseType.OK:
234
+ path = Path(dlg.fC.get_filename())
235
+ A = ITkDButils.Attachment(path=path,
236
+ title=dlg.att_title.get_text().strip(),
237
+ desc=dlg.att_desc.get_text().strip())
238
+ self.append_attachment_to_view(A)
239
+ self.attachments.append(A)
240
+
241
+ dlg.hide()
242
+ dlg.destroy()
243
+
244
+ def append_attachment_to_view(self, A):
245
+ """Insert attachment to tree view."""
246
+ model = self.tree.get_model()
247
+ model.append([A.path.name, A.title, A.desc, A.path.as_posix()])
248
+
249
+ def remove_attachment(self, *args):
250
+ """Remove selected attachment."""
251
+ select = self.tree.get_selection()
252
+ model, it = select.get_selected()
253
+ if it:
254
+ values = model[it]
255
+ for a in self.attachments:
256
+ if a.path == values[3]:
257
+ rc = dbGtkUtils.ask_for_confirmation("Remove this attachment ?",
258
+ "{} - {}\n{}".format(a.title, a.desc, values[0]))
259
+ if rc:
260
+ self.attachments.remove(a)
261
+ model.remove(it)
262
+
263
+ break
264
+
265
+ if __name__ == "__main__":
266
+ SA = ShowAttachments("Test Attachments", None)
267
+ SA.run()
@@ -0,0 +1,94 @@
1
+ #!/usr/bin/env python3
2
+ """Shows comments."""
3
+
4
+ try:
5
+ import itkdb_gtk
6
+
7
+ except ImportError:
8
+ import sys
9
+ from pathlib import Path
10
+ cwd = Path(__file__).parent.parent
11
+ sys.path.append(cwd.as_posix())
12
+
13
+ from itkdb_gtk import dbGtkUtils
14
+
15
+ import gi
16
+ gi.require_version("Gtk", "3.0")
17
+ from gi.repository import Gtk, Gio, Gdk
18
+
19
+
20
+ class ShowComments(Gtk.Dialog):
21
+ """Edit comments"""
22
+ def __init__(self, title, comments=[], parent=None):
23
+ """Initialization."""
24
+ super().__init__(title=title, transient_for=parent)
25
+ self.comments = [C for C in comments]
26
+ self.init_window()
27
+
28
+ def init_window(self):
29
+ """Preapare the window."""
30
+ self.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
31
+ Gtk.STOCK_OK, Gtk.ResponseType.OK)
32
+
33
+ self.mainBox = self.get_content_area()
34
+ # The "Add attachment" button.
35
+ box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
36
+ self.mainBox.pack_start(box, False, False, 0)
37
+
38
+ dbGtkUtils.add_button_to_container(box, "Add Comment",
39
+ "Click to add a new comment.",
40
+ self.add_comment)
41
+
42
+ dbGtkUtils.add_button_to_container(box, "Remove Comment",
43
+ "Click to remove selected comment.",
44
+ self.remove_comment)
45
+
46
+ # the list of attachments
47
+ tree_view = self.create_tree_view()
48
+ self.mainBox.pack_start(tree_view, True, True, 0)
49
+ for C in self.comments:
50
+ self.append_comment_to_view(C)
51
+
52
+ self.show_all()
53
+
54
+ def create_tree_view(self, size=150):
55
+ """Create the tree view."""
56
+ model = Gtk.ListStore(str)
57
+ self.tree = Gtk.TreeView(model=model)
58
+ scrolled = Gtk.ScrolledWindow()
59
+ scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
60
+ scrolled.add(self.tree)
61
+ scrolled.set_size_request(-1, size)
62
+
63
+ renderer = Gtk.CellRendererText()
64
+ column = Gtk.TreeViewColumn("Comment", renderer, text=0)
65
+ self.tree.append_column(column)
66
+
67
+ return scrolled
68
+
69
+ def add_comment(self, *args):
70
+ """A new comment."""
71
+ text = dbGtkUtils.get_a_value("Comment", "Add a new comment", True, self)
72
+ self.comments.append(text)
73
+ self.append_comment_to_view(text)
74
+
75
+ def remove_comment(self, *args):
76
+ """Remove a comment."""
77
+ select = self.tree.get_selection()
78
+ model, iter = select.get_selected()
79
+ if iter:
80
+ values = model[iter]
81
+ for C in self.comments:
82
+ if C == values[0]:
83
+ rc = dbGtkUtils.ask_for_confirmation("Remove this Comment ?",
84
+ "{}".format(values[0]))
85
+ if rc:
86
+ self.comments.remove(C)
87
+ model.remove(iter)
88
+
89
+ break
90
+
91
+ def append_comment_to_view(self, C):
92
+ """Append a new comment to the triee view."""
93
+ model = self.tree.get_model()
94
+ model.append([C])
@@ -0,0 +1,103 @@
1
+
2
+ try:
3
+ import itkdb_gtk
4
+
5
+ except ImportError:
6
+ import sys
7
+ from pathlib import Path
8
+ cwd = Path(__file__).parent.parent
9
+ sys.path.append(cwd.as_posix())
10
+
11
+ from itkdb_gtk import dbGtkUtils
12
+
13
+ import gi
14
+ gi.require_version("Gtk", "3.0")
15
+ from gi.repository import Gtk, Gio, Gdk
16
+
17
+
18
+ class ShowDefects(Gtk.Dialog):
19
+ """Edit defects"""
20
+
21
+ def __init__(self, title, defects=None, parent=None):
22
+ """Initialization."""
23
+ super().__init__(title=title, transient_for=parent)
24
+ if defects:
25
+ self.defects = [C for C in defects]
26
+ else:
27
+ self.defects = []
28
+
29
+ self.init_window()
30
+
31
+ def init_window(self):
32
+ """Preapare the window."""
33
+ self.add_buttons(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
34
+ Gtk.STOCK_OK, Gtk.ResponseType.OK)
35
+
36
+ self.mainBox = self.get_content_area()
37
+ # The "Add attachment" button.
38
+ box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
39
+ self.mainBox.pack_start(box, False, False, 0)
40
+
41
+ dbGtkUtils.add_button_to_container(box, "Add Defect",
42
+ "Click to add a new defect.",
43
+ self.add_defect)
44
+
45
+ dbGtkUtils.add_button_to_container(box, "Remove Defect",
46
+ "Click to remove selected defect.",
47
+ self.remove_defect)
48
+
49
+ # the list of attachments
50
+ tree_view = self.create_tree_view()
51
+ self.mainBox.pack_start(tree_view, True, True, 0)
52
+ for C in self.defects:
53
+ self.append_defect_to_view(C)
54
+
55
+ self.show_all()
56
+
57
+ def create_tree_view(self, size=150):
58
+ """Create the tree view."""
59
+ model = Gtk.ListStore(str, str)
60
+ self.tree = Gtk.TreeView(model=model)
61
+ scrolled = Gtk.ScrolledWindow()
62
+ scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
63
+ scrolled.add(self.tree)
64
+ scrolled.set_size_request(-1, size)
65
+
66
+ renderer = Gtk.CellRendererText()
67
+ column = Gtk.TreeViewColumn("Defect Type", renderer, text=0)
68
+ self.tree.append_column(column)
69
+
70
+ renderer = Gtk.CellRendererText()
71
+ column = Gtk.TreeViewColumn("Description", renderer, text=1)
72
+ self.tree.append_column(column)
73
+
74
+ return scrolled
75
+
76
+ def add_defect(self, *args):
77
+ """A new defect."""
78
+ values = dbGtkUtils.get_a_list_of_values("Insert new defect", ("Type", "Description/v"))
79
+ if len(values):
80
+ defect = {"name": values[0], "description": values[1]}
81
+ self.defects.append(defect)
82
+ self.append_defect_to_view(defect)
83
+
84
+ def remove_defect(self, *args):
85
+ """Remove a defect."""
86
+ select = self.tree.get_selection()
87
+ model, iter = select.get_selected()
88
+ if iter:
89
+ values = model[iter]
90
+ for C in self.defects:
91
+ if C["name"] == values[0] and C["description"] == values[1]:
92
+ rc = dbGtkUtils.ask_for_confirmation("Remove this Defect ?",
93
+ "{}\n{}\n".format(values[0], values[1]))
94
+ if rc:
95
+ self.defects.remove(C)
96
+ model.remove(iter)
97
+
98
+ break
99
+
100
+ def append_defect_to_view(self, C):
101
+ """Append a new defect to the triee view."""
102
+ model = self.tree.get_model()
103
+ model.append([C["name"], C["description"]])