itkdb-gtk 0.10.7__py3-none-any.whl → 0.10.9__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.

Potentially problematic release.


This version of itkdb-gtk might be problematic. Click here for more details.

itkdb_gtk/UploadTest.py CHANGED
@@ -78,7 +78,7 @@ def check_data(data):
78
78
  class UploadTest(dbGtkUtils.ITkDBWindow):
79
79
  """Collects information to upload a test and its attachments."""
80
80
 
81
- def __init__(self, session, payload=None, attachment=None, help=None):
81
+ def __init__(self, session, payload=None, attachment=None, help_link=None):
82
82
  """Initialization.
83
83
 
84
84
  Args:
@@ -107,7 +107,7 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
107
107
 
108
108
  global gtk_runs
109
109
  if gtk_runs:
110
- super().__init__(session=session, title="Upload Test", gtk_runs=gtk_runs, help=help)
110
+ super().__init__(session=session, title="Upload Test", gtk_runs=gtk_runs, help_link=help_link)
111
111
  self.init_window()
112
112
 
113
113
  def init_window(self):
@@ -366,7 +366,7 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
366
366
  else:
367
367
  the_path = Path(A["path"]).expanduser().resolve()
368
368
 
369
- self.attachments.append(ITkDButils.Attachment(the_path, A["title"], A["description"]))
369
+ self.attachments.append(ITkDButils.Attachment(path=the_path, title=A["title"], desc=A["description"]))
370
370
 
371
371
  if len(self.attachments) > 0:
372
372
  self.btn_attch.set_label("Attachments ({})".format(len(self.attachments)))
@@ -444,7 +444,7 @@ class UploadTest(dbGtkUtils.ITkDBWindow):
444
444
  self.data["comments"] = self.comments
445
445
  self.data["defects"] = self.defects
446
446
 
447
- rc = ITkDButils.upload_test(self.session, self.data, self.attachments)
447
+ rc = ITkDButils.upload_test(self.session, self.data, self.attachments, check_runNumber=True)
448
448
  if rc:
449
449
  ipos = rc.find("The following details may help:")
450
450
  msg = rc[ipos:]
@@ -482,9 +482,9 @@ def main():
482
482
  # Start GUI
483
483
  UpT = UploadTest(client,
484
484
  payload=args.test_file,
485
- attachment=ITkDButils.Attachment(args.attachment,
486
- args.attach_title,
487
- args.attach_desc))
485
+ attachment=ITkDButils.Attachment(path=args.attachment,
486
+ title=args.attach_title,
487
+ desc=args.attach_desc))
488
488
 
489
489
  if gtk_runs:
490
490
  UpT.present()
itkdb_gtk/WireBondGui.py CHANGED
@@ -6,7 +6,7 @@ import json
6
6
  import gi
7
7
 
8
8
  gi.require_version("Gtk", "3.0")
9
- from gi.repository import Gtk, Gio, GLib
9
+ from gi.repository import Gtk, Gio, Gdk
10
10
 
11
11
  try:
12
12
  import itkdb_gtk
@@ -16,7 +16,7 @@ except ImportError:
16
16
  cwd = Path(__file__).parent.parent
17
17
  sys.path.append(cwd.as_posix())
18
18
  import itkdb_gtk
19
-
19
+
20
20
  __HELP_LINK__="https://itkdb-gtk.docs.cern.ch/wirebondTest.html"
21
21
 
22
22
  from itkdb_gtk import dbGtkUtils
@@ -173,7 +173,7 @@ class HybridHoles:
173
173
 
174
174
  Returns:
175
175
  True if added, False otherwise.
176
-
176
+
177
177
  """
178
178
  first_chan = self.param[irow][0]
179
179
  last_chan = self.param[irow][1]
@@ -310,13 +310,13 @@ class SensorHoles:
310
310
 
311
311
  def get_sensor_holes(self):
312
312
  """Return holes sensor.
313
-
313
+
314
314
  Return a list of [sensor, hybrid, segment, ichan, width]
315
315
  """
316
316
  holes = []
317
317
  for hyb in self.hybrids:
318
318
  H = hyb.get_sensor_holes()
319
- for _, ih, isegment, ichan, width in H:
319
+ for _, ih, isegment, ichan, width in H:
320
320
  holes.append([self.id, ih, isegment, ichan, width])
321
321
 
322
322
  return holes
@@ -360,7 +360,7 @@ class ModuleHoles:
360
360
  """
361
361
  holes = []
362
362
  for S in self.sensors:
363
- for _, ihyb, isegment, ichan, width in S.get_sensor_holes():
363
+ for _, ihyb, isegment, ichan, width in S.get_sensor_holes():
364
364
  holes.append([S.id, ihyb, isegment, ichan, width])
365
365
 
366
366
  return holes
@@ -416,9 +416,9 @@ def get_module_param(SN):
416
416
  class WireBond(dbGtkUtils.ITkDBWindow):
417
417
  """Main window."""
418
418
 
419
- def __init__(self, session, title="", help=__HELP_LINK__):
419
+ def __init__(self, session, title="", help_link=__HELP_LINK__):
420
420
  """Initialization."""
421
- super().__init__(title=title, session=session, help=help)
421
+ super().__init__(title=title, session=session, help_link=help_link)
422
422
  self.pdb = None
423
423
  self.models = {}
424
424
  self.holes = {}
@@ -426,6 +426,8 @@ class WireBond(dbGtkUtils.ITkDBWindow):
426
426
  self.inst_combo = None
427
427
  self.module_SN = None
428
428
  self.alternativeID = None
429
+ self.combo = None
430
+ self.tree = None
429
431
  self.init_window()
430
432
 
431
433
  def init_window(self):
@@ -460,7 +462,7 @@ class WireBond(dbGtkUtils.ITkDBWindow):
460
462
 
461
463
  # Data panel
462
464
  grid = Gtk.Grid(column_spacing=5, row_spacing=1)
463
-
465
+
464
466
  # The shipment receiver
465
467
  institute = self.create_institute_combo()
466
468
  institute.connect("changed", self.on_institute)
@@ -469,8 +471,8 @@ class WireBond(dbGtkUtils.ITkDBWindow):
469
471
  grid.attach(Gtk.Label(label="Institute"), 0, 0, 1, 1)
470
472
  grid.attach(institute, 1, 0, 1, 1)
471
473
  self.inst_combo = institute
472
-
473
-
474
+
475
+
474
476
  for i, tit in enumerate(["Operator", "Bond Machine", "Wire Batch", "SN", "Date"]):
475
477
  lbl = Gtk.Label(label=tit)
476
478
  lbl.set_xalign(0)
@@ -480,12 +482,13 @@ class WireBond(dbGtkUtils.ITkDBWindow):
480
482
  self.machine = dbGtkUtils.new_small_text_entry()
481
483
  self.batch = dbGtkUtils.new_small_text_entry()
482
484
  #self.SN = dbGtkUtils.new_small_text_entry()
483
-
485
+
484
486
  self.SN = itkdb_gtk.dbGtkUtils.TextEntry(small=True)
485
487
  self.SN.connect("text-changed", self.on_SN_changed)
486
488
 
487
-
489
+
488
490
  self.date = dbGtkUtils.TextEntry(small=True)
491
+ self.date.entry.set_text(ITkDButils.get_db_date())
489
492
  self.date.connect("text_changed", self.new_date)
490
493
 
491
494
  grid.attach(self.operator, 1, 1, 1, 1)
@@ -510,10 +513,14 @@ class WireBond(dbGtkUtils.ITkDBWindow):
510
513
 
511
514
  box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
512
515
  self.mainBox.pack_start(box, False, False, 0)
513
- dbGtkUtils.add_button_to_container(box, "Add Item",
514
- "Click to add a new item.",
516
+ dbGtkUtils.add_button_to_container(box, "Add Bond",
517
+ "Click to add a new bond.",
515
518
  self.add_item)
516
519
 
520
+ dbGtkUtils.add_button_to_container(box, "Remove Bond",
521
+ "Click to remove selected bond.",
522
+ self.remove_item)
523
+
517
524
  #
518
525
  # The text view and buffer
519
526
  #
@@ -525,7 +532,7 @@ class WireBond(dbGtkUtils.ITkDBWindow):
525
532
  name = self.get_institute_from_combo(combo)
526
533
  if name:
527
534
  self.institute = name
528
-
535
+
529
536
  def on_SN_changed(self, entry, value):
530
537
  """New SN given. Ask in PDB,"""
531
538
  if len(value) <= 0:
@@ -629,9 +636,52 @@ class WireBond(dbGtkUtils.ITkDBWindow):
629
636
  if d is not None:
630
637
  self.date.set_text(d)
631
638
 
632
- def button_pressed(self, *args):
639
+ def button_pressed(self, tree, event):
633
640
  """Button pressed."""
634
- pass
641
+ # double click shows attachments
642
+ if event.button == 1 and event.type == Gdk.EventType.DOUBLE_BUTTON_PRESS:
643
+ #self.write_message("This is a double click.\n")
644
+ return
645
+
646
+ if event.button != 3:
647
+ return
648
+
649
+ # Create popup menu
650
+ select = self.tree.get_selection()
651
+ model, lv_iter = select.get_selected()
652
+ values = None
653
+ if lv_iter:
654
+ values = model[lv_iter]
655
+
656
+ else:
657
+ P = tree.get_path_at_pos(event.x, event.y)
658
+ if P:
659
+ lv_iter = model.get_iter(P[0])
660
+ values = model[lv_iter]
661
+
662
+ if not values:
663
+ return
664
+
665
+ menu = Gtk.Menu()
666
+
667
+ item_show = Gtk.MenuItem(label="Delete")
668
+ item_show.connect("activate", self.on_delete_item, (model, lv_iter, values))
669
+ menu.append(item_show)
670
+
671
+ menu.show_all()
672
+ menu.popup_at_pointer(event)
673
+
674
+ def on_delete_item(self, item, data):
675
+ """Delete bond in list view."""
676
+ model, lv_iter, _ = data
677
+ model.remove(lv_iter)
678
+
679
+ def remove_item(self, *args):
680
+ """REmoves selected bond."""
681
+ select = self.tree.get_selection()
682
+ model, lv_iter = select.get_selected()
683
+ if lv_iter:
684
+ model.remove(lv_iter)
635
685
 
636
686
  def add_item(self, *args):
637
687
  """Adds a new item in the current model."""
@@ -655,7 +705,7 @@ class WireBond(dbGtkUtils.ITkDBWindow):
655
705
  param = get_module_param(self.SN.get_text())
656
706
  except ValueError as E:
657
707
  dbGtkUtils.complain("Wrong SN number", str(E))
658
-
708
+
659
709
  M = ModuleHoles(param=param)
660
710
 
661
711
  for test in test_parameters.values():
@@ -700,10 +750,10 @@ class WireBond(dbGtkUtils.ITkDBWindow):
700
750
  self.write_message("{}\n".format(str(H)))
701
751
  if H[-1] > mxW:
702
752
  mxW = H[-1]
703
-
753
+
704
754
  if mxW > 0:
705
755
  self.write_message("Max width: {}". format(mxW))
706
-
756
+
707
757
  out["MAX_UNCON_SENSOR_CHAN"] = mxW
708
758
  nstrips = 0
709
759
  for v in unconnected:
@@ -754,7 +804,7 @@ class WireBond(dbGtkUtils.ITkDBWindow):
754
804
  dbGtkUtils.set_combo_iter(self.inst_combo, data["institution"])
755
805
  except KeyError:
756
806
  self.write_message("institution value is not in the loaded file.")
757
-
807
+
758
808
  self.operator.set_text(data["properties"]["OPERATOR"])
759
809
  self.machine.set_text(data["properties"]["BOND_MACHINE"])
760
810
  self.batch.set_text(data["properties"]["BONDWIRE_BATCH"])
@@ -771,14 +821,14 @@ class WireBond(dbGtkUtils.ITkDBWindow):
771
821
  def get_list_of_channels(self, data):
772
822
  """Creates the lists of channels."""
773
823
  for key, model in self.models.items():
774
- iter = model.get_iter_first()
824
+ lv_iter = model.get_iter_first()
775
825
  out = {}
776
- while iter:
777
- chan, comm = model[iter]
826
+ while lv_iter:
827
+ chan, comm = model[lv_iter]
778
828
  if len(chan) > 0:
779
829
  out[chan] = comm
780
830
 
781
- iter = model.iter_next(iter)
831
+ lv_iter = model.iter_next(lv_iter)
782
832
 
783
833
  data["results"][key] = out
784
834
 
@@ -851,7 +901,7 @@ class WireBond(dbGtkUtils.ITkDBWindow):
851
901
  data["institution"] = self.institute
852
902
  if data["runNumber"] == "-1":
853
903
  data["runNumber"] = "1"
854
-
904
+
855
905
  data["date"] = self.date.get_text()
856
906
 
857
907
 
@@ -894,7 +944,7 @@ def main():
894
944
 
895
945
  client.user_gui = dlg
896
946
 
897
-
947
+
898
948
  win = WireBond(client, title="WireBond")
899
949
  win.connect("destroy", Gtk.main_quit)
900
950
  win.show_all()
@@ -905,6 +955,6 @@ def main():
905
955
  print("Arrrgggg!!!")
906
956
 
907
957
  dlg.die()
908
-
958
+
909
959
  if __name__ == "__main__":
910
960
  main()
itkdb_gtk/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """ itkdb-gtk python module
2
2
  """
3
- __version__ = "0.10.7"
3
+ __version__ = "0.10.9"
4
4
 
5
5
 
6
6
  def dash_board():
@@ -57,3 +57,8 @@ def uploadPetalInformation():
57
57
  """Read files from AVS nd create Petal core in PDB."""
58
58
  from .UploadPetalInformation import main
59
59
  main()
60
+
61
+ def panelVisualInspection():
62
+ """Visual inspection of PWB or HYB panels."""
63
+ from .PanelVisualInspection import main
64
+ main()
itkdb_gtk/dashBoard.py CHANGED
@@ -21,6 +21,7 @@ from itkdb_gtk import UploadMultipleTests
21
21
  from itkdb_gtk import GlueWeight
22
22
  from itkdb_gtk import UploadModuleIV
23
23
  from itkdb_gtk import WireBondGui
24
+ from itkdb_gtk import PanelVisualInspection
24
25
 
25
26
 
26
27
  HAS_PETALQC=False
@@ -51,12 +52,14 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
51
52
  GLUE_WEIGHT = 6
52
53
  MOD_IV = 7
53
54
  WIRE_BOND = 8
54
- PETAL_CORE_METRO=9
55
- PETAL_CORE_THERMAL=10
55
+ PANEL_VI = 9
56
+ PETAL_CORE_METRO = 10
57
+ PETAL_CORE_THERMAL = 11
58
+
56
59
 
57
60
  def __init__(self, session):
58
61
  """Initialization."""
59
- super().__init__(title="ITkDB Dashboard", session=session, help=HELP_LINK)
62
+ super().__init__(title="ITkDB Dashboard", session=session, help_link=HELP_LINK)
60
63
  self.mask = 0
61
64
 
62
65
  # set border width
@@ -103,16 +106,22 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
103
106
  btnWireBond.connect("clicked", self.wire_bond)
104
107
  grid.attach(btnWireBond, 1, irow, 1, 1)
105
108
 
109
+ irow += 1
110
+ btnModIV = Gtk.Button(label="Panel Visual Insp.")
111
+ btnModIV.connect("clicked", self.panel_VI)
112
+ grid.attach(btnModIV, 0, irow, 1, 1)
113
+
114
+
106
115
  if HAS_PETALQC:
107
116
  irow +=1
108
117
  btnPetalMetrology = Gtk.Button(label="Petal Core Metrology")
109
118
  btnPetalMetrology.connect("clicked", self.petal_metrology)
110
119
  grid.attach(btnPetalMetrology, 0, irow, 1, 1)
111
-
120
+
112
121
  btnPetalThermal = Gtk.Button(label="Petal Core Thermal")
113
122
  btnPetalThermal.connect("clicked", self.petal_thermal)
114
123
  grid.attach(btnPetalThermal, 1, irow, 1, 1)
115
-
124
+
116
125
 
117
126
  irow += 1
118
127
  grid.attach(Gtk.Label(), 0, irow, 1, 1)
@@ -144,7 +153,7 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
144
153
  return
145
154
 
146
155
  self.mask |= bt
147
- W = UploadTest.UploadTest(self.session, help=HELP_LINK)
156
+ W = UploadTest.UploadTest(self.session, help_link=HELP_LINK)
148
157
  W.connect("destroy", self.app_closed, bitn)
149
158
 
150
159
  def upload_multiple_tests(self, *args):
@@ -155,7 +164,7 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
155
164
  return
156
165
 
157
166
  self.mask |= bt
158
- W = UploadMultipleTests.UploadMultipleTests(self.session, help=HELP_LINK)
167
+ W = UploadMultipleTests.UploadMultipleTests(self.session, help_link=HELP_LINK)
159
168
  W.connect("destroy", self.app_closed, bitn)
160
169
 
161
170
  def create_shipment(self, *args):
@@ -166,7 +175,7 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
166
175
  return
167
176
 
168
177
  self.mask |= bt
169
- W = CreateShipments.CreateShipments(self.session, help=HELP_LINK)
178
+ W = CreateShipments.CreateShipments(self.session, help_link=HELP_LINK)
170
179
  W.connect("destroy", self.app_closed, bitn)
171
180
 
172
181
  def receive_shipment(self, *args):
@@ -177,7 +186,7 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
177
186
  return
178
187
 
179
188
  self.mask |= bt
180
- W = GetShipments.ReceiveShipments(self.session, help=HELP_LINK)
189
+ W = GetShipments.ReceiveShipments(self.session, help_link=HELP_LINK)
181
190
  W.connect("destroy", self.app_closed, bitn)
182
191
 
183
192
  def petal_gnd(self, *args):
@@ -188,7 +197,7 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
188
197
  return
189
198
 
190
199
  self.mask |= bt
191
- W = PetalReceptionTests.PetalReceptionTests(self.session, help=HELP_LINK)
200
+ W = PetalReceptionTests.PetalReceptionTests(self.session, help_link=HELP_LINK)
192
201
  W.connect("destroy", self.app_closed, bitn)
193
202
 
194
203
  def glue_weight(self, *args):
@@ -199,7 +208,7 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
199
208
  return
200
209
 
201
210
  self.mask |= bt
202
- W = GlueWeight.GlueWeight(self.session, help=HELP_LINK)
211
+ W = GlueWeight.GlueWeight(self.session, help_link=HELP_LINK)
203
212
  W.connect("destroy", self.app_closed, bitn)
204
213
 
205
214
  def module_IV(self, *args):
@@ -210,7 +219,7 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
210
219
  return
211
220
 
212
221
  self.mask |= bt
213
- W = UploadModuleIV.IVwindow(self.session, help=HELP_LINK)
222
+ W = UploadModuleIV.IVwindow(self.session, help_link=HELP_LINK)
214
223
  W.connect("destroy", self.app_closed, bitn)
215
224
 
216
225
  def wire_bond(self, *args):
@@ -221,10 +230,23 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
221
230
  return
222
231
 
223
232
  self.mask |= bt
224
- W = WireBondGui.WireBond(session=self.session, title="Wirebond", help=HELP_LINK)
233
+ W = WireBondGui.WireBond(session=self.session, title="Wirebond", help_link=HELP_LINK)
234
+ W.connect("destroy", self.app_closed, bitn)
235
+ W.show_all()
236
+
237
+ def panel_VI(self, *args):
238
+ """Panel VI tests."""
239
+ bitn = DashWindow.PANEL_VI
240
+ bt = 1 << bitn
241
+ if self.mask & bt:
242
+ return
243
+
244
+ self.mask |= bt
245
+ W = PanelVisualInspection.PanelVisualInspection(session=self.session, title="Panel Visual Inspection", help_link=HELP_LINK)
225
246
  W.connect("destroy", self.app_closed, bitn)
226
247
  W.show_all()
227
248
 
249
+
228
250
  def petal_metrology(self, *args):
229
251
  """Do petal metrology"""
230
252
  if not HAS_PETALQC:
@@ -269,6 +291,7 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
269
291
 
270
292
 
271
293
  def main():
294
+ """main entry."""
272
295
  # DB login
273
296
  dlg = ITkDBlogin.ITkDBlogin()
274
297
  client = dlg.get_client()
itkdb_gtk/dbGtkUtils.py CHANGED
@@ -69,6 +69,10 @@ def parse_date_as_string(txt):
69
69
  def is_a_date(txt):
70
70
  """check tha the input string is a date."""
71
71
  try:
72
+ tl = txt.lower()
73
+ if len(txt)<5 and (tl!="now" and tl!="today"):
74
+ return False
75
+
72
76
  dateutil.parser.parse(txt, fuzzy=False)
73
77
  return True
74
78
 
@@ -94,7 +98,7 @@ def set_entry_style(container):
94
98
  css = "{} {{ min-height: {}px; }}".format(container.get_name(), font_size)
95
99
  provider.load_from_data(css.encode())
96
100
  style_context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_SETTINGS)
97
- return container
101
+ return container
98
102
 
99
103
  def set_button_color(btn, bg_color, fg_color="white"):
100
104
  """Set button color"""
@@ -103,18 +107,18 @@ def set_button_color(btn, bg_color, fg_color="white"):
103
107
  provider.load_from_data(css.encode())
104
108
  style_context = btn.get_style_context()
105
109
  style_context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
106
-
110
+
107
111
  def set_combo_iter(combo, txt, col=0):
108
112
  """Set scombo active iter to that containing txt in column col."""
109
113
  model = combo.get_model()
110
- iter = model.get_iter_first()
111
- while iter:
112
- val = model.get_value(iter, col)
114
+ lv_iter = model.get_iter_first()
115
+ while lv_iter:
116
+ val = model.get_value(lv_iter, col)
113
117
  if val == txt:
114
- combo.set_active_iter(iter)
118
+ combo.set_active_iter(lv_iter)
115
119
  break
116
120
 
117
- iter = model.iter_next(iter)
121
+ lv_iter = model.iter_next(lv_iter)
118
122
 
119
123
 
120
124
  def is_iterable(obj):
@@ -247,7 +251,7 @@ class TextEntry(GObject.GObject):
247
251
  self.widget = new_small_text_entry()
248
252
  else:
249
253
  self.widget = Gtk.Entry()
250
-
254
+
251
255
  self.widget.connect("focus-in-event", self.on_enter)
252
256
  self.widget.connect("focus-out-event", self.on_leave)
253
257
 
@@ -480,7 +484,7 @@ class MessagePanel(object):
480
484
 
481
485
  self.textbuffer.insert(end, msg)
482
486
  GLib.idle_add(self.scroll_to_end)
483
-
487
+
484
488
  def write(self, txt):
485
489
  """A write method."""
486
490
  self.write_message(txt, write_date=False)
@@ -489,7 +493,7 @@ class MessagePanel(object):
489
493
  class ITkDBWindow(Gtk.Window):
490
494
  """Base class for GUI main windows."""
491
495
 
492
- def __init__(self, title="", session=None, show_search=None, help=None, gtk_runs=True, panel_size=100):
496
+ def __init__(self, title="", session=None, show_search=None, help_link=None, gtk_runs=True, panel_size=100):
493
497
  """Initialization.
494
498
 
495
499
  Args:
@@ -505,13 +509,13 @@ class ITkDBWindow(Gtk.Window):
505
509
  self.inst2code = {}
506
510
  self.code2inst = {}
507
511
  self.message_panel = None
508
- self.help = help
512
+ self.help = help_link
509
513
 
510
514
  if gtk_runs:
511
515
  super().__init__(title=title)
512
- self.prepare_window(show_search, panel_size)
516
+ self.prepare_window(title, show_search, panel_size)
513
517
 
514
- def prepare_window(self, show_search, panel_size):
518
+ def prepare_window(self, title, show_search, panel_size):
515
519
  """Inititalizes GUI."""
516
520
  # Prepare HeaderBar
517
521
  self.hb = Gtk.HeaderBar()
@@ -533,7 +537,7 @@ class ITkDBWindow(Gtk.Window):
533
537
  button.set_tooltip_text(show_search)
534
538
  button.connect("clicked", self.query_db)
535
539
  self.hb.pack_end(button)
536
-
540
+
537
541
  if self.help:
538
542
  button = Gtk.Button()
539
543
  icon = Gio.ThemedIcon(name="help-browser-symbolic")
@@ -541,13 +545,20 @@ class ITkDBWindow(Gtk.Window):
541
545
  button.add(image)
542
546
  button.connect("clicked", self.show_help)
543
547
  self.hb.pack_end(button)
544
-
548
+
545
549
 
546
550
  # Create main content box
547
551
  self.mainBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
548
552
  self.mainBox.set_property("margin-left", 6)
549
553
  self.mainBox.set_property("margin-right", 6)
550
554
 
555
+ if len(title)>0:
556
+ lbl = Gtk.Label()
557
+ lbl.set_markup("<big><b>{}\n</b></big>".format(title))
558
+ lbl.set_xalign(0.5)
559
+ self.mainBox.pack_start(lbl, True, True, 2)
560
+
561
+
551
562
  self.add(self.mainBox)
552
563
 
553
564
  # The text view and buffer
@@ -570,7 +581,7 @@ class ITkDBWindow(Gtk.Window):
570
581
  def show_help(self, *args):
571
582
  """Show help"""
572
583
  webbrowser.open(self.help)
573
-
584
+
574
585
  def query_db(self, *args):
575
586
  """Search button clicked."""
576
587
  pass
@@ -580,7 +591,7 @@ class ITkDBWindow(Gtk.Window):
580
591
  if msg == "<OK>":
581
592
  if hasattr(self.session, "user_gui"):
582
593
  self.session = self.session.user_gui.get_client()
583
-
594
+
584
595
  if self.userLabel.get_child():
585
596
  self.userLabel.get_child().set_text(self.session.user.name)
586
597
 
@@ -725,7 +736,7 @@ class DictDialog(Gtk.Grid):
725
736
  else:
726
737
  if itm[last_key] is None:
727
738
  itm[last_key] = txt
728
- else:
739
+ else:
729
740
  tp = type(itm[last_key])
730
741
  itm[last_key] = tp(txt)
731
742
 
@@ -765,6 +776,7 @@ class DictDialog(Gtk.Grid):
765
776
  css = "entry {{ min-height: {}px; }}".format(font_size)
766
777
  provider.load_from_data(css.encode())
767
778
  style_context.add_provider(provider, Gtk.STYLE_PROVIDER_PRIORITY_SETTINGS)
779
+ container.connect("populate-popup", self.add_insert_path)
768
780
 
769
781
  if name:
770
782
  container.set_name(name)
@@ -775,6 +787,28 @@ class DictDialog(Gtk.Grid):
775
787
 
776
788
  return container
777
789
 
790
+ def add_insert_path(self, entry, menu, *args):
791
+ """Adds a new item in the pop-up menu."""
792
+ item = Gtk.MenuItem(label="Get file path")
793
+ item.connect("activate", self.on_set_path, entry)
794
+ menu.append(item)
795
+ menu.show_all()
796
+
797
+ def on_set_path(self, menu_item, entry):
798
+ """Sets the path to the entry."""
799
+ fdlg = Gtk.FileChooserNative(action=Gtk.FileChooserAction.OPEN, accept_label="Select")
800
+ response = fdlg.run()
801
+ if response == Gtk.ResponseType.ACCEPT:
802
+ ifiles = [ipath for ipath in fdlg.get_filenames()]
803
+ if len(ifiles)<1:
804
+ return
805
+ if len(ifiles) > 1:
806
+ complain("More than one file selected","Choosing first.")
807
+
808
+ fnam = ifiles[0]
809
+ entry.set_text(fnam)
810
+ self.on_leave(entry, None, None, entry.get_name())
811
+
778
812
  def set_value(self, key, value):
779
813
  """Set value of a container and key."""
780
814
  try:
@@ -815,7 +849,7 @@ class DictDialog(Gtk.Grid):
815
849
  self.show_values()
816
850
  self.show_all()
817
851
  self.queue_draw()
818
-
852
+
819
853
  @staticmethod
820
854
  def create_json_data_editor(data):
821
855
  """Create a dialog to show the JSon file."""
@@ -835,7 +869,7 @@ class DictDialog(Gtk.Grid):
835
869
  rc = dlg.run()
836
870
  dlg.hide()
837
871
  dlg.destroy()
838
-
872
+
839
873
  return value.values, rc
840
874
 
841
875
 
@@ -844,7 +878,7 @@ def create_scrolled_dictdialog(the_dict, hidden=("component", "testType")):
844
878
 
845
879
  Args:
846
880
  the_dict: the input dictionary with values.
847
-
881
+
848
882
  Returns:
849
883
  scrolled: the scrolled window
850
884
  gM: the DictDialog
@@ -857,7 +891,8 @@ def create_scrolled_dictdialog(the_dict, hidden=("component", "testType")):
857
891
  return scrolled, gM
858
892
 
859
893
 
860
- if __name__ == "__main__":
894
+ def main():
895
+ """Main entry."""
861
896
  result = {
862
897
  "component": "the_serial_nukber",
863
898
  "testType": "METROLOGY_AVS",
@@ -919,3 +954,6 @@ if __name__ == "__main__":
919
954
 
920
955
  win.show_all()
921
956
  Gtk.main()
957
+
958
+ if __name__ == "__main__":
959
+ main()