tvaLib
Public Member Functions | Public Attributes | List of all members
lib.draw.DataEntry Class Reference

Data entering tools. More...

Inheritance diagram for lib.draw.DataEntry:
lib.draw.CamDataEntry lib.draw.SeqsDataEntry

Public Member Functions

def __init__ (self, instructions='', instructions2='', submit_label='Enter', cancel_label='Cancel', rows={}, sites=None, config=None, sites_selection_depth=1, dropdowns={}, multiSelectionListBoxes={})
 
def submitCallback (self)
 
def cancelCallback (self)
 
def getEntries (self)
 
def getDropDowns (self)
 
def getMSLBs (self)
 
def getSiteSelection (self)
 
def getCamViewSelection (self)
 
def getSequenceSelection (self)
 
def getSelectedSite (self)
 
def getSelectedCamView (self)
 
def setEntry (self, label, value)
 
def updateCameraOptions (self, index, value, op)
 
def updateSequenceOptions (self, index, value, op)
 
def drawButtonFrame (self, cancel_label, submit_label)
 

Public Attributes

 root
 
 style
 Style. More...
 
 ttk_style
 
 config
 Data. More...
 
 sites
 
 sites_selection_depth
 
 submit
 
 labels
 Handle regular entries. More...
 
 entryVals
 
 ddlabels
 Handle dropdown menu items. More...
 
 ddVals
 
 mslblabels
 Handle multi-selection lists. More...
 
 mslbVals
 
 mslbScrolls
 
 mslbValsContents
 
 site_option
 
 site_option_menu
 
 camview_option
 
 camview_option_menu
 
 sequence_option
 
 sequence_option_menu
 
 buttonframe
 

Detailed Description

Data entering tools.

Definition at line 753 of file draw.py.

Constructor & Destructor Documentation

◆ __init__()

def lib.draw.DataEntry.__init__ (   self,
  instructions = '',
  instructions2 = '',
  submit_label = 'Enter',
  cancel_label = 'Cancel',
  rows = {},
  sites = None,
  config = None,
  sites_selection_depth = 1,
  dropdowns = {},
  multiSelectionListBoxes = {} 
)
Create data entry form

    Input
    =====
    instructions:  printed  at top of form
    instructions2: printed  at bottom of form
    rows:          ordinary text fields, as a dict, where keys are labels and values are defaults
    dropdowns:     drop-down selection fields, as a dict, where keys are labels, and values are dicts with keys as options and values as indeces.
    multiSelectionListBoxes: multiple-selection list box fields, as a dict, where keys are labels, and values are dicts with keys as options and values as indeces.
    sites:         if this is passed, an interactive site selection dialogue will be printed
    sites_selection_depth: 1=only select site; 2=select site and camera; 3=select site, camera, sequence

Definition at line 754 of file draw.py.

754  def __init__(self, instructions='', instructions2='', submit_label='Enter', cancel_label='Cancel', rows={}, sites=None, config=None, sites_selection_depth=1, dropdowns={}, multiSelectionListBoxes={}):
755  ''' Create data entry form
756 
757  Input
758  =====
759  instructions: printed at top of form
760  instructions2: printed at bottom of form
761  rows: ordinary text fields, as a dict, where keys are labels and values are defaults
762  dropdowns: drop-down selection fields, as a dict, where keys are labels, and values are dicts with keys as options and values as indeces.
763  multiSelectionListBoxes: multiple-selection list box fields, as a dict, where keys are labels, and values are dicts with keys as options and values as indeces.
764  sites: if this is passed, an interactive site selection dialogue will be printed
765  sites_selection_depth: 1=only select site; 2=select site and camera; 3=select site, camera, sequence
766  '''
767  from Tkinter import Tk, Label, Entry, Button, StringVar, OptionMenu, Listbox, W, E, N, S, Frame, Scrollbar, VERTICAL, END, LEFT
768  from interface import Style
769  from ttk import Combobox
770  from ttk import Style as ttk_Style
771  self.root = Tk()
772  self.root.title('Data entry')
773 
774  self.style = Style()
775  self.ttk_style = ttk_Style()
776  self.ttk_style.theme_create('combostyle', parent='alt',
777  settings = {'TCombobox':
778  {'configure':
779  {'fieldbackground': self.style.bgdark,
780  'background': self.style.bgdark
781  }}}
782  )
783  self.ttk_style.theme_use('combostyle')
784 
785  self.config = config
786  self.sites = sites
787  self.sites_selection_depth = sites_selection_depth
788  self.root.configure(bg=self.style.bglight)
789  self.submit = False
790  Label(self.root, text=instructions, font='-weight bold -size 8', foreground=self.style.fg, bg=self.style.bglight, wraplength=320, justify=LEFT).grid(columnspan=2, sticky=W)
791 
792  self.labels = []
793  self.entryVals = []
794  rowIx = 1
795  for row in rows:
796  Label(self.root, text=row, foreground=self.style.fg, bg=self.style.bglight).grid(row=rowIx, sticky=E)
797  self.labels.append(row)
798  self.entryVals.append(StringVar())
799  self.entryVals[-1].set(rows[row])
800  Entry(self.root, bd=5, width=30, textvariable=self.entryVals[-1], foreground=self.style.fg, bg=self.style.bgdark, highlightbackground=self.style.bglight).grid(row=rowIx, column=1, sticky=W)
801  rowIx += 1
802 
803  self.ddlabels = []
804  self.ddVals = []
805  for dropdown in dropdowns:
806  Label(self.root, text=dropdown, foreground=self.style.fg, bg=self.style.bglight).grid(row=rowIx, sticky=E)
807  self.ddlabels.append(dropdown)
808  self.ddVals.append(StringVar(self.root))
809  for ddval in dropdowns[dropdown]:
810  self.ddVals[-1].set(ddval)
811  break
812  #w = OptionMenu(self.root, self.ddVals[-1], *[x for x in dropdowns[dropdown]])
813  w = Combobox(self.root, textvariable=self.ddVals[-1], values=[x for x in dropdowns[dropdown]], state='readonly')
814  w.config(foreground=self.style.fg, background=self.style.bgdark)
815  w.grid(row=rowIx, column=1, sticky=W)
816  rowIx += 1
817 
818  self.mslblabels = []
819  self.mslbVals = []
820  self.mslbScrolls = []
821  self.mslbValsContents = multiSelectionListBoxes
822  for multiSelectionListBox in multiSelectionListBoxes:
823  Label(self.root, text=multiSelectionListBox, foreground=self.style.fg, bg=self.style.bglight).grid(row=rowIx, sticky=E)
824  self.mslblabels.append(multiSelectionListBox)
825  self.mslbScrolls.append(Scrollbar(self.root, orient=VERTICAL, troughcolor=self.style.fg, bg=self.style.bgdark, highlightbackground=self.style.bglight))
826  self.mslbVals.append(Listbox(self.root, width=31, height=10, selectmode='multiple', yscrollcommand=self.mslbScrolls[-1].set, foreground=self.style.fg, bg=self.style.bgdark, highlightbackground=self.style.bglight))
827  for mslbVal in multiSelectionListBoxes[multiSelectionListBox]:
828  self.mslbVals[-1].insert(END, mslbVal)
829  self.mslbVals[-1].grid(row=rowIx, column=1, sticky=W)
830  self.mslbScrolls[-1].config(command=self.mslbVals[-1].yview)
831  self.mslbScrolls[-1].grid(row=rowIx, column=2, sticky=N+S)
832  rowIx += 1
833 
834  if(sites):
835  self.site_option = StringVar(self.root)
836  self.site_option.trace('w', self.updateCameraOptions)
837  self.site_option_menu = Combobox(self.root, textvariable=self.site_option, values=[str(site.idx)+': '+site.name for site in sites])
838  self.camview_option = StringVar(self.root)
839  self.camview_option.trace('w', self.updateSequenceOptions)
840  self.camview_option_menu = Combobox(self.root, textvariable=self.camview_option, values=[str(cam.idx)+': '+cam.name for cam in sites[0]])
841  self.sequence_option = StringVar(self.root)
842  try: self.sequence_option_menu = Combobox(self.root, textvariable=self.sequence_option, values=[str(seq.idx)+': '+seq.name for seq in sites[0][0]])
843  except: self.sequence_option_menu = Combobox(self.root, textvariable=self.sequence_option, values=['**No sequences found**'])
844  if(self.sites_selection_depth > 0):
845  Label(self.root, text='site', foreground=self.style.fg, bg=self.style.bglight).grid(row=rowIx, sticky=E)
846  self.site_option.set(str(sites[0].idx)+': '+sites[0].name)
847  self.site_option_menu.grid(row=rowIx, column=1, sticky=W)
848  self.site_option_menu.config(foreground=self.style.fg, background=self.style.bgdark)
849  rowIx += 1
850  if(self.sites_selection_depth > 1):
851  Label(self.root, text='camera', foreground=self.style.fg, bg=self.style.bglight).grid(row=rowIx, sticky=E)
852  self.camview_option.set(str(sites[0][0].idx)+': '+sites[0][0].name)
853  self.camview_option_menu.grid(row=rowIx, column=1, sticky=W)
854  self.camview_option_menu.config(foreground=self.style.fg, background=self.style.bgdark)
855  rowIx += 1
856  if(self.sites_selection_depth > 2):
857  Label(self.root, text='sequence', foreground=self.style.fg, bg=self.style.bglight).grid(row=rowIx, sticky=E)
858  self.sequence_option.set(str(sites[0][0][0].idx)+': '+sites[0][0][0].name)
859  self.sequence_option_menu.grid(row=rowIx, column=1, sticky=W)
860  self.sequence_option_menu.config(foreground=self.style.fg, background=self.style.bgdark)
861  rowIx += 1
862  if(instructions2): Label(self.root, text=instructions2, font='-weight bold -size 8', foreground=self.style.fg, bg=self.style.bglight, wraplength=320, justify=LEFT).grid(columnspan=2, sticky=W)
863  self.drawButtonFrame(cancel_label, submit_label)
864  self.root.mainloop()
865 
config
Definition: main.py:889

Member Function Documentation

◆ cancelCallback()

def lib.draw.DataEntry.cancelCallback (   self)

Definition at line 869 of file draw.py.

869  def cancelCallback(self): self.root.quit()
870 

◆ drawButtonFrame()

def lib.draw.DataEntry.drawButtonFrame (   self,
  cancel_label,
  submit_label 
)

Definition at line 893 of file draw.py.

893  def drawButtonFrame(self, cancel_label, submit_label):
894  from Tkinter import Button, Frame
895  self.buttonframe = Frame(self.root)
896  self.buttonframe.grid(columnspan=2)
897  Button(self.buttonframe, text=cancel_label, command=self.cancelCallback, foreground=self.style.fg, bg=self.style.bgdark).grid(row=0, column=0)
898  Button(self.buttonframe, text=submit_label, command=self.submitCallback, foreground=self.style.fg, bg=self.style.bgdark).grid(row=0, column=1)
899 

◆ getCamViewSelection()

def lib.draw.DataEntry.getCamViewSelection (   self)

Definition at line 875 of file draw.py.

875  def getCamViewSelection(self): return int(self.camview_option.get().split(':')[0])

◆ getDropDowns()

def lib.draw.DataEntry.getDropDowns (   self)

Definition at line 872 of file draw.py.

872  def getDropDowns(self): return dict((label, x.get()) for label,x in zip(self.ddlabels, self.ddVals))

◆ getEntries()

def lib.draw.DataEntry.getEntries (   self)

Definition at line 871 of file draw.py.

871  def getEntries(self): return dict((label, x.get()) for label,x in zip(self.labels, self.entryVals))

◆ getMSLBs()

def lib.draw.DataEntry.getMSLBs (   self)

Definition at line 873 of file draw.py.

873  def getMSLBs(self): return dict((label, str([self.mslbValsContents[label].items()[int(y)][1] for y in x.curselection()])) for label,x in zip(self.mslblabels, self.mslbVals))

◆ getSelectedCamView()

def lib.draw.DataEntry.getSelectedCamView (   self)

Definition at line 878 of file draw.py.

878  def getSelectedCamView(self): return [y for y in self.getSelectedSite() if y.idx==self.getCamViewSelection()][0]

◆ getSelectedSite()

def lib.draw.DataEntry.getSelectedSite (   self)

Definition at line 877 of file draw.py.

877  def getSelectedSite(self): return [x for x in self.sites if x.idx==self.getSiteSelection()][0]

◆ getSequenceSelection()

def lib.draw.DataEntry.getSequenceSelection (   self)

Definition at line 876 of file draw.py.

876  def getSequenceSelection(self): return int(self.sequence_option.get().split(':')[0])

◆ getSiteSelection()

def lib.draw.DataEntry.getSiteSelection (   self)

Definition at line 874 of file draw.py.

874  def getSiteSelection(self): return int(self.site_option.get().split(':')[0])

◆ setEntry()

def lib.draw.DataEntry.setEntry (   self,
  label,
  value 
)

Definition at line 879 of file draw.py.

879  def setEntry(self, label, value):
880  for l,x in zip(self.labels, self.entryVals):
881  if(l == label): x.set(value)
882 

◆ submitCallback()

def lib.draw.DataEntry.submitCallback (   self)

Definition at line 866 of file draw.py.

866  def submitCallback(self):
867  self.submit = True
868  self.root.quit()

◆ updateCameraOptions()

def lib.draw.DataEntry.updateCameraOptions (   self,
  index,
  value,
  op 
)

Definition at line 883 of file draw.py.

883  def updateCameraOptions(self, index, value, op):
884  if(self.sites_selection_depth > 1):
885  self.camview_option_menu['values'] = [str(cam.idx)+': '+cam.name for cam in self.getSelectedSite()]
886  self.camview_option.set(str(self.getSelectedSite()[0].idx)+': '+self.getSelectedSite()[0].name)
887 

◆ updateSequenceOptions()

def lib.draw.DataEntry.updateSequenceOptions (   self,
  index,
  value,
  op 
)

Definition at line 888 of file draw.py.

888  def updateSequenceOptions(self, index, value, op):
889  if(self.sites_selection_depth > 2):
890  self.sequence_option_menu['values'] = [str(seq.idx)+': '+seq.name for seq in self.getSelectedCamView()]
891  self.sequence_option.set(str(self.getSelectedCamView()[0].idx)+': '+self.getSelectedCamView()[0].name)
892 

Member Data Documentation

◆ buttonframe

lib.draw.DataEntry.buttonframe

Definition at line 895 of file draw.py.

◆ camview_option

lib.draw.DataEntry.camview_option

Definition at line 838 of file draw.py.

◆ camview_option_menu

lib.draw.DataEntry.camview_option_menu

Definition at line 840 of file draw.py.

◆ config

lib.draw.DataEntry.config

Data.

Definition at line 785 of file draw.py.

◆ ddlabels

lib.draw.DataEntry.ddlabels

Handle dropdown menu items.

Definition at line 803 of file draw.py.

◆ ddVals

lib.draw.DataEntry.ddVals

Definition at line 804 of file draw.py.

◆ entryVals

lib.draw.DataEntry.entryVals

Definition at line 793 of file draw.py.

◆ labels

lib.draw.DataEntry.labels

Handle regular entries.

Definition at line 792 of file draw.py.

◆ mslblabels

lib.draw.DataEntry.mslblabels

Handle multi-selection lists.

Definition at line 818 of file draw.py.

◆ mslbScrolls

lib.draw.DataEntry.mslbScrolls

Definition at line 820 of file draw.py.

◆ mslbVals

lib.draw.DataEntry.mslbVals

Definition at line 819 of file draw.py.

◆ mslbValsContents

lib.draw.DataEntry.mslbValsContents

Definition at line 821 of file draw.py.

◆ root

lib.draw.DataEntry.root

Definition at line 771 of file draw.py.

◆ sequence_option

lib.draw.DataEntry.sequence_option

Definition at line 841 of file draw.py.

◆ sequence_option_menu

lib.draw.DataEntry.sequence_option_menu

Definition at line 842 of file draw.py.

◆ site_option

lib.draw.DataEntry.site_option

Definition at line 835 of file draw.py.

◆ site_option_menu

lib.draw.DataEntry.site_option_menu

Definition at line 837 of file draw.py.

◆ sites

lib.draw.DataEntry.sites

Definition at line 786 of file draw.py.

◆ sites_selection_depth

lib.draw.DataEntry.sites_selection_depth

Definition at line 787 of file draw.py.

◆ style

lib.draw.DataEntry.style

Style.

Definition at line 774 of file draw.py.

◆ submit

lib.draw.DataEntry.submit

Definition at line 789 of file draw.py.

◆ ttk_style

lib.draw.DataEntry.ttk_style

Definition at line 775 of file draw.py.


The documentation for this class was generated from the following file: