def __init__(self, WithinFactor): wx.Frame.__init__(self, None, wx.ID_ANY, size=(200, 250), title="Factor Definition") # Specify relevant variables self.WithinFactor = WithinFactor self.LabelNames = WithinFactor.dataTable['labels'] self.Subject = '' # Panel: Left Input Area PanelInput = wx.Panel(self, wx.ID_ANY) sizerInput = wx.BoxSizer(wx.HORIZONTAL) self.ListInput = wx.ListBox(PanelInput, wx.ID_ANY, choices=self.LabelNames, style=wx.LB_EXTENDED) sizerInput.Add(self.ListInput, 0, wx.EXPAND) self.ListInput.SetSelection(0) # Panel: Right Definition Area PanelDef = wx.Panel(PanelInput, wx.ID_ANY) sizerDef = wx.BoxSizer(wx.VERTICAL) # Subject Panel Area PanelSubject = wx.Panel(PanelDef, wx.ID_ANY) sizerSubject = wx.BoxSizer(wx.HORIZONTAL) PanelSubjectButton = wx.Panel(PanelSubject, wx.ID_ANY) sizerSubjectButton = wx.BoxSizer(wx.VERTICAL) self.ButtonSubjectAdd = wx.Button(PanelSubjectButton, wx.ID_ANY, label='>') self.ButtonSubjectRm = wx.Button(PanelSubjectButton, wx.ID_ANY, label='<') sizerSubjectButton.Add(self.ButtonSubjectAdd, 0, wx.EXPAND) sizerSubjectButton.Add(self.ButtonSubjectRm, 0, wx.EXPAND) self.ButtonSubjectAdd.Enable() self.ButtonSubjectRm.Disable() PanelSubjectButton.SetSizer(sizerSubjectButton) PanelSubjectVariable = wx.Panel(PanelSubject, wx.ID_ANY) sizerSubjectVariable = wx.BoxSizer(wx.VERTICAL) TextSubject = wx.StaticText(PanelSubjectVariable, wx.ID_ANY, label="Subject Variable", style=wx.ALIGN_CENTER) sizerSubjectVariable.Add(TextSubject, 0, wx.EXPAND) self.SubjectVariable = wx.TextCtrl(PanelSubjectVariable, wx.ID_ANY, value="", size=(180, 25), style=wx.TE_READONLY) sizerSubjectVariable.Add(self.SubjectVariable, 0, wx.EXPAND) PanelSubjectVariable.SetSizer(sizerSubjectVariable) sizerSubject.Add(PanelSubjectButton, 0, wx.wx.EXPAND) sizerSubject.Add(PanelSubjectVariable, 0, wx.wx.EXPAND) PanelSubject.SetSizer(sizerSubject) # Within Panel Area PanelWithin = wx.Panel(PanelDef, wx.ID_ANY) sizerWithin = wx.BoxSizer(wx.HORIZONTAL) PanelWithinButton = wx.Panel(PanelWithin, wx.ID_ANY) sizerWithinButton = wx.BoxSizer(wx.VERTICAL) self.ButtonWithinAdd = wx.Button(PanelWithinButton, wx.ID_ANY, label='>') self.ButtonWithinRm = wx.Button(PanelWithinButton, wx.ID_ANY, label='<') sizerWithinButton.Add(self.ButtonWithinAdd, 0, wx.EXPAND) sizerWithinButton.Add(self.ButtonWithinRm, 0, wx.EXPAND) self.ButtonWithinAdd.Enable() self.ButtonWithinRm.Disable() PanelWithinButton.SetSizer(sizerWithinButton) PanelWithinVariable = wx.Panel(PanelWithin, wx.ID_ANY) sizerWithinVariable = wx.BoxSizer(wx.VERTICAL) # Check if within factors were specified if WithinFactor.Factor == []: textTitle = "Data" factorLabels = ['_?_(1)'] supportext = '' else: textTitle = "Within Subject Factor(s)" iterationFactor = [range(1, e + 1) for e in WithinFactor.Level] iterList = list(itertools.product(*iterationFactor)) factorLabels = [ '_?_%s' % str(e).replace(' ', '') if len(e) > 1 else '_?_(%s)' % str(e[0]) for e in iterList ] supportext = '(%s)' % ', '.join(WithinFactor.Factor) TextWithin = wx.StaticText(PanelWithinVariable, wx.ID_ANY, label=textTitle, style=wx.ALIGN_CENTER) sizerWithinVariable.Add(TextWithin, 0, wx.EXPAND) TextSupport = wx.StaticText(PanelWithinVariable, wx.ID_ANY, label=supportext, style=wx.ALIGN_CENTER) sizerWithinVariable.Add(TextSupport, 0, wx.EXPAND) self.ListWithin = wx.ListBox(PanelWithinVariable, wx.ID_ANY, choices=factorLabels, size=(180, 300), style=wx.LB_EXTENDED) sizerWithinVariable.Add(self.ListWithin, 0, wx.EXPAND) PanelWithinVariable.SetSizer(sizerWithinVariable) sizerWithin.Add(PanelWithinButton, 0, wx.wx.ALIGN_CENTRE) sizerWithin.Add(PanelWithinVariable, 0, wx.wx.ALIGN_RIGHT) PanelWithin.SetSizer(sizerWithin) # Between Panel Area PanelBetween = wx.Panel(PanelDef, wx.ID_ANY) sizerBetween = wx.BoxSizer(wx.HORIZONTAL) PanelBetweenButton = wx.Panel(PanelBetween, wx.ID_ANY) sizerBetweenButton = wx.BoxSizer(wx.VERTICAL) self.ButtonBetweenAdd = wx.Button(PanelBetweenButton, wx.ID_ANY, label='>') self.ButtonBetweenRm = wx.Button(PanelBetweenButton, wx.ID_ANY, label='<') sizerBetweenButton.Add(self.ButtonBetweenAdd, 0, wx.EXPAND) sizerBetweenButton.Add(self.ButtonBetweenRm, 0, wx.EXPAND) self.ButtonBetweenAdd.Enable() self.ButtonBetweenRm.Disable() PanelBetweenButton.SetSizer(sizerBetweenButton) PanelBetweenVariable = wx.Panel(PanelBetween, wx.ID_ANY) sizerBetweenVariable = wx.BoxSizer(wx.VERTICAL) TextBetween = wx.StaticText(PanelBetweenVariable, wx.ID_ANY, label="Between Subject Factor(s)", style=wx.ALIGN_CENTER) sizerBetweenVariable.Add(TextBetween, 0, wx.EXPAND) self.ListBetween = wx.ListBox(PanelBetweenVariable, wx.ID_ANY, size=(180, 100), style=wx.LB_EXTENDED) sizerBetweenVariable.Add(self.ListBetween, 0, wx.EXPAND) PanelBetweenVariable.SetSizer(sizerBetweenVariable) sizerBetween.Add(PanelBetweenButton, 0, wx.ALIGN_CENTRE) sizerBetween.Add(PanelBetweenVariable, 0, wx.ALIGN_RIGHT) PanelBetween.SetSizer(sizerBetween) # Covariate Panel Area PanelCovariate = wx.Panel(PanelDef, wx.ID_ANY) sizerCovariate = wx.BoxSizer(wx.HORIZONTAL) PanelCovariateButton = wx.Panel(PanelCovariate, wx.ID_ANY) sizerCovariateButton = wx.BoxSizer(wx.VERTICAL) self.ButtonCovariateAdd = wx.Button(PanelCovariateButton, wx.ID_ANY, label='>') self.ButtonCovariateRm = wx.Button(PanelCovariateButton, wx.ID_ANY, label='<') sizerCovariateButton.Add(self.ButtonCovariateAdd, 0, wx.EXPAND) sizerCovariateButton.Add(self.ButtonCovariateRm, 0, wx.EXPAND) self.ButtonCovariateAdd.Enable() self.ButtonCovariateRm.Disable() PanelCovariateButton.SetSizer(sizerCovariateButton) PanelCovariateVariable = wx.Panel(PanelCovariate, wx.ID_ANY) sizerCovariateVariable = wx.BoxSizer(wx.VERTICAL) TextCovariate = wx.StaticText(PanelCovariateVariable, wx.ID_ANY, label="Covariate(s)", style=wx.ALIGN_CENTER) sizerCovariateVariable.Add(TextCovariate, 0, wx.EXPAND) self.ListCovariate = wx.ListBox(PanelCovariateVariable, wx.ID_ANY, size=(180, 100), style=wx.LB_EXTENDED) sizerCovariateVariable.Add(self.ListCovariate, 0, wx.EXPAND) PanelCovariateVariable.SetSizer(sizerCovariateVariable) sizerCovariate.Add(PanelCovariateButton, 0, wx.ALIGN_CENTRE) sizerCovariate.Add(PanelCovariateVariable, 0, wx.ALIGN_RIGHT) PanelCovariate.SetSizer(sizerCovariate) # Resize everything and create the input area sizerDef.AddSpacer(3) sizerDef.Add(PanelSubject, 0, wx.EXPAND) sizerDef.AddSpacer(5) sizerDef.Add(PanelWithin, 0, wx.EXPAND) sizerDef.AddSpacer(5) sizerDef.Add(PanelBetween, 0, wx.EXPAND) sizerDef.AddSpacer(5) sizerDef.Add(PanelCovariate, 0, wx.EXPAND) PanelDef.SetSizer(sizerDef) sizerInput.Add(PanelDef, 0, wx.EXPAND) PanelInput.SetSizer(sizerInput) # Panel: OK and previous window Button PanelButtons = wx.Panel(self, wx.ID_ANY) sizerButtons = wx.BoxSizer(wx.HORIZONTAL) ButtonPrevious = wx.Button(PanelButtons, wx.ID_ANY, label='Change Within Subject Factors') sizerButtons.Add(ButtonPrevious, 0, wx.ALIGN_LEFT) sizerButtons.AddSpacer(27) sizerButtons.AddSpacer(27) ButtonOK = wx.Button(PanelButtons, wx.ID_ANY, label='&OK') sizerButtons.Add(ButtonOK, 0, wx.ALIGN_RIGHT) PanelButtons.SetSizer(sizerButtons) # Resize everything and create the window FrameSizer = wx.BoxSizer(wx.VERTICAL) FrameSizer.Add(PanelInput, 0, wx.EXPAND) FrameSizer.AddSpacer(5) FrameSizer.Add(PanelButtons, 0, wx.EXPAND) FrameSizer.AddSpacer(3) self.SetSizerAndFit(FrameSizer) # Specification of events wx.EVT_BUTTON(self, self.ButtonSubjectAdd.Id, self.addSubject) wx.EVT_BUTTON(self, self.ButtonSubjectRm.Id, self.rmSubject) wx.EVT_BUTTON(self, self.ButtonWithinAdd.Id, self.addWithin) wx.EVT_BUTTON(self, self.ButtonWithinRm.Id, self.rmWithin) wx.EVT_BUTTON(self, self.ButtonBetweenAdd.Id, self.addBetween) wx.EVT_BUTTON(self, self.ButtonBetweenRm.Id, self.rmBetween) wx.EVT_BUTTON(self, self.ButtonCovariateAdd.Id, self.addCovariate) wx.EVT_BUTTON(self, self.ButtonCovariateRm.Id, self.rmCovariate) wx.EVT_BUTTON(self, ButtonPrevious.Id, self.onClose) wx.EVT_BUTTON(self, ButtonOK.Id, self.finishFactors) wx.EVT_LISTBOX(self, self.ListInput.Id, self.inputListSelected) wx.EVT_LISTBOX(self, self.ListWithin.Id, self.withinListSelected) wx.EVT_LISTBOX(self, self.ListBetween.Id, self.betweenListSelected) wx.EVT_LISTBOX(self, self.ListCovariate.Id, self.covariateListSelected) self.Bind(wx.EVT_CHAR_HOOK, self.onKeyDown) self.Bind(wx.EVT_CLOSE, self.onClose) # Fill in table if dataset already exists if self.WithinFactor.DataPanel.MainFrame.Dataset != {}: self.loadDataset()
def makeAdminBox(self, parent): #make the box for the controls boxLabel = wx.StaticBox(parent, -1, 'Choose Monitor') boxLabel.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.NORMAL)) adminBox = wx.StaticBoxSizer(boxLabel) #build the controls self.ctrlMonList = wx.ListBox(parent, idCtrlMonList, choices=['iiyama571', 'sonyG500'], size=(100, 100)) wx.EVT_LISTBOX(self, idCtrlMonList, self.onChangeMonSelection) monButtonsBox = wx.BoxSizer(wx.VERTICAL) self.btnNewMon = wx.Button(parent, idBtnNewMon, 'New...') wx.EVT_BUTTON(self, idBtnNewMon, self.onNewMon) monButtonsBox.Add(self.btnNewMon) self.btnNewMon.SetToolTipString("Create a new monitor") self.btnSaveMon = wx.Button(parent, idBtnSaveMon, 'Save') wx.EVT_BUTTON(self, idBtnSaveMon, self.onSaveMon) monButtonsBox.Add(self.btnSaveMon) self.btnSaveMon.SetToolTipString( "Save all calibrations for this monitor") self.btnDeleteMon = wx.Button(parent, idBtnDeleteMon, 'Delete') wx.EVT_BUTTON(self, idBtnDeleteMon, self.onDeleteMon) monButtonsBox.Add(self.btnDeleteMon) self.btnDeleteMon.SetToolTipString("Delete this monitor entirely") self.ctrlCalibList = wx.ListBox(parent, idCtrlCalibList, choices=[''], size=(150, 100)) wx.EVT_LISTBOX(self, idCtrlCalibList, self.onChangeCalibSelection) calibButtonsBox = wx.BoxSizer(wx.VERTICAL) self.btnCopyCalib = wx.Button(parent, idBtnCopyCalib, 'Copy...') wx.EVT_BUTTON(self, idBtnCopyCalib, self.onCopyCalib) calibButtonsBox.Add(self.btnCopyCalib) self.btnCopyCalib.SetToolTipString( "Creates a new calibration entry for this monitor") self.btnDeleteCalib = wx.Button(parent, idBtnDeleteCalib, 'Delete') wx.EVT_BUTTON(self, idBtnDeleteCalib, self.onDeleteCalib) calibButtonsBox.Add(self.btnDeleteCalib) self.btnDeleteCalib.SetToolTipString( "Remove this calibration entry (finalised when monitor is saved)") #add controls to box adminBoxMainSizer = wx.FlexGridSizer(cols=2, hgap=6, vgap=6) adminBoxMainSizer.AddMany([ (1, 10), (1, 10), #a pair of empty boxes each 1x10pix self.ctrlMonList, monButtonsBox, self.ctrlCalibList, calibButtonsBox, ]) adminBox.Add(adminBoxMainSizer) return adminBox
def __init__(self, mainwindow, parent): wx.Panel.__init__(self, parent, -1) self._main_window=mainwindow self._data={} self._data_map={} # main box sizer vbs=wx.BoxSizer(wx.VERTICAL) # horizontal sizer for the listbox and tabs hbs=wx.BoxSizer(wx.HORIZONTAL) # the list box self._item_list=wx.ListBox(self, wx.NewId(), style=wx.LB_SINGLE|wx.LB_HSCROLL|wx.LB_NEEDED_SB) hbs.Add(self._item_list, 1, wx.EXPAND|wx.BOTTOM, border=5) # the detailed info pane vbs1=wx.BoxSizer(wx.VERTICAL) self._items=( (GeneralEditor, 0, None), (cal_editor.CategoryEditor, 1, 'category'), (pb_editor.MemoEditor, 1, 'memo') ) self._w=[] for n in self._items: w=n[0](self, -1) vbs1.Add(w, n[1], wx.EXPAND|wx.ALL, 5) self._w.append(w) if n[2]: widgets_list.append((w.static_box, n[2])) hbs.Add(vbs1, 3, wx.EXPAND|wx.ALL, border=5) self._general_editor_w=self._w[0] self._cat_editor_w=self._w[1] self._memo_editor_w=self._w[2] # the bottom buttons hbs1=wx.BoxSizer(wx.HORIZONTAL) self._save_btn=wx.Button(self, wx.ID_SAVE) self._revert_btn=wx.Button(self, wx.ID_REVERT_TO_SAVED) help_btn=wx.Button(self, wx.ID_HELP) hbs1.Add(self._save_btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5) hbs1.Add(help_btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5) hbs1.Add(self._revert_btn, 0, wx.ALIGN_CENTRE|wx.ALL, 5) # all done vbs.Add(hbs, 1, wx.EXPAND|wx.ALL, 5) vbs.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.TOP|wx.BOTTOM, 5) vbs.Add(hbs1, 0, wx.ALIGN_CENTRE|wx.ALL, 5) self.SetSizer(vbs) self.SetAutoLayout(True) vbs.Fit(self) # event handlers wx.EVT_LISTBOX(self, self._item_list.GetId(), self._OnListBoxItem) wx.EVT_BUTTON(self, self._save_btn.GetId(), self._OnSave) wx.EVT_BUTTON(self, self._revert_btn.GetId(), self._OnRevert) wx.EVT_BUTTON(self, wx.ID_HELP, lambda _: wx.GetApp().displayhelpid(helpids.ID_TAB_MEMO)) # DIRTY UI Event handlers for w in self._w: pb_editor.EVT_DIRTY_UI(self, w.GetId(), self.OnMakeDirty) # populate data self._populate() # turn on dirty flag self.ignoredirty=False self.setdirty(False) # register for Today selection today.bind_notification_event(self.OnTodaySelection, today.Today_Group_Memo) # color code editable labels field_color.reload_color_info(self, widgets_list) pubsub.subscribe(self.OnPhoneChanged, pubsub.PHONE_MODEL_CHANGED)
def __init__(self, parent, id, title, clip_object, mergeList=None): # If no Merge List is passed in ... if mergeList == None: # ... use the default Clip Properties Dialog size passed in from the config object. (This does NOT get saved.) size = TransanaGlobal.configData.clipPropertiesSize # ... we can enable Clip Change Propagation propagateEnabled = True HelpContext = 'Clip Properties' # If we DO have a merge list ... else: # ... increase the size of the dialog to allow for the list of mergeable clips. size = (TransanaGlobal.configData.clipPropertiesSize[0], TransanaGlobal.configData.clipPropertiesSize[1] + 130) # ... and Clip Change Propagation should be disabled propagateEnabled = False HelpContext = 'Clip Merge' # Make the Keyword Edit List resizable by passing wx.RESIZE_BORDER style. Signal that Propogation is included. Dialogs.GenForm.__init__(self, parent, id, title, size=size, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, propagateEnabled=propagateEnabled, useSizers=True, HelpContext=HelpContext) if mergeList == None: # Define the minimum size for this dialog as the initial size minWidth = 750 minHeight = 570 else: # Define the minimum size for this dialog as the initial size minWidth = 750 minHeight = 650 # Remember the Parent Window self.parent = parent # Remember the original Clip Object passed in self.obj = clip_object # Add a placeholder to the clip object for the merge clip number self.obj.mergeNumber = 0 # Remember the merge list, if one is passed in self.mergeList = mergeList # Initialize the merge item as unselected self.mergeItemIndex = -1 # if Keywords that server as Keyword Examples are removed, we will need to remember them. # Then, when OK is pressed, the Keyword Example references in the Database Tree can be removed. # We can't remove them immediately in case the whole Clip Properties Edit process is cancelled. self.keywordExamplesToDelete = [] # Initialize a variable to hold merged keyword examples. self.mergedKeywordExamples = [] # Create the form's main VERTICAL sizer mainSizer = wx.BoxSizer(wx.VERTICAL) # If we're merging Clips ... if self.mergeList != None: # ... display a label for the Merge Clips ... lblMergeClip = wx.StaticText(self.panel, -1, _("Clip to Merge")) mainSizer.Add(lblMergeClip, 0) # Add a vertical spacer to the main sizer mainSizer.Add((0, 3)) # Create a HORIZONTAL sizer for the merge information mergeSizer = wx.BoxSizer(wx.HORIZONTAL) # ... display a ListCtrl for the Merge Clips ... self.mergeClips = wx.ListCtrl(self.panel, -1, size=(300, 100), style=wx.LC_REPORT | wx.LC_SINGLE_SEL) # Add the element to the sizer mergeSizer.Add(self.mergeClips, 1, wx.EXPAND) # ... bind the Item Selected event for the List Control ... self.mergeClips.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected) # ... define the columns for the Merge Clips ... self.mergeClips.InsertColumn(0, _('Clip Name')) self.mergeClips.InsertColumn(1, _('Collection')) self.mergeClips.InsertColumn(2, _('Start Time')) self.mergeClips.InsertColumn(3, _('Stop Time')) self.mergeClips.SetColumnWidth(0, 244) self.mergeClips.SetColumnWidth(1, 244) # ... and populate the Merge Clips list from the mergeList data for (ClipNum, ClipID, CollectNum, CollectID, ClipStart, ClipStop, transcriptCount) in self.mergeList: index = self.mergeClips.InsertStringItem(sys.maxint, ClipID) self.mergeClips.SetStringItem(index, 1, CollectID) self.mergeClips.SetStringItem( index, 2, Misc.time_in_ms_to_str(ClipStart)) self.mergeClips.SetStringItem(index, 3, Misc.time_in_ms_to_str(ClipStop)) # Add the row sizer to the main vertical sizer mainSizer.Add(mergeSizer, 3, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Create a HORIZONTAL sizer for the first row r1Sizer = wx.BoxSizer(wx.HORIZONTAL) # Create a VERTICAL sizer for the next element v1 = wx.BoxSizer(wx.VERTICAL) # Clip ID self.id_edit = self.new_edit_box(_("Clip ID"), v1, self.obj.id, maxLen=100) # Add the element to the sizer r1Sizer.Add(v1, 1, wx.EXPAND) # Add a horizontal spacer to the row sizer r1Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v2 = wx.BoxSizer(wx.VERTICAL) # Collection ID collection_edit = self.new_edit_box(_("Collection ID"), v2, self.obj.GetNodeString(False)) # Add the element to the sizer r1Sizer.Add(v2, 2, wx.EXPAND) collection_edit.Enable(False) # Add the row sizer to the main vertical sizer mainSizer.Add(r1Sizer, 0, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Create a HORIZONTAL sizer for the next row r2Sizer = wx.BoxSizer(wx.HORIZONTAL) # Create a VERTICAL sizer for the next element v3 = wx.BoxSizer(wx.VERTICAL) # Library ID series_edit = self.new_edit_box(_("Library ID"), v3, self.obj.series_id) # Add the element to the sizer r2Sizer.Add(v3, 1, wx.EXPAND) series_edit.Enable(False) # Add a horizontal spacer to the row sizer r2Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v4 = wx.BoxSizer(wx.VERTICAL) # Episode ID episode_edit = self.new_edit_box(_("Episode ID"), v4, self.obj.episode_id) # Add the element to the sizer r2Sizer.Add(v4, 1, wx.EXPAND) episode_edit.Enable(False) # Add the row sizer to the main vertical sizer mainSizer.Add(r2Sizer, 0, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Media Filename(s) [label] txt = wx.StaticText(self.panel, -1, _("Media Filename(s)")) mainSizer.Add(txt, 0) # Add a vertical spacer to the main sizer mainSizer.Add((0, 3)) # Create a HORIZONTAL sizer for the next row r3Sizer = wx.BoxSizer(wx.HORIZONTAL) # Media Filename(s) # If the media filename path is not empty, we should normalize the path specification if self.obj.media_filename == '': filePath = self.obj.media_filename else: filePath = os.path.normpath(self.obj.media_filename) # Initialize the list of media filenames with the first one. self.filenames = [filePath] # For each additional Media file ... for vid in self.obj.additional_media_files: # ... add it to the filename list self.filenames.append(vid['filename']) self.fname_lb = wx.ListBox(self.panel, -1, wx.DefaultPosition, wx.Size(180, 60), self.filenames) r3Sizer.Add(self.fname_lb, 1, wx.EXPAND) self.fname_lb.SetDropTarget(ListBoxFileDropTarget(self.fname_lb)) # Add the row sizer to the main vertical sizer mainSizer.Add(r3Sizer, 3, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Create a HORIZONTAL sizer for the next row r4Sizer = wx.BoxSizer(wx.HORIZONTAL) # Create a VERTICAL sizer for the next element v5 = wx.BoxSizer(wx.VERTICAL) # Clip Start. Convert to HH:MM:SS.mm self.clip_start_edit = self.new_edit_box( _("Clip Start"), v5, Misc.time_in_ms_to_str(self.obj.clip_start)) # Add the element to the sizer r4Sizer.Add(v5, 1, wx.EXPAND) # For merging, we need to remember the merged value of Clip Start self.clip_start = self.obj.clip_start self.clip_start_edit.Enable(False) # Add a horizontal spacer to the row sizer r4Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v6 = wx.BoxSizer(wx.VERTICAL) # Clip Stop. Convert to HH:MM:SS.mm self.clip_stop_edit = self.new_edit_box( _("Clip Stop"), v6, Misc.time_in_ms_to_str(self.obj.clip_stop)) # Add the element to the sizer r4Sizer.Add(v6, 1, wx.EXPAND) # For merging, we need to remember the merged value of Clip Stop self.clip_stop = self.obj.clip_stop self.clip_stop_edit.Enable(False) # Add a horizontal spacer to the row sizer r4Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v7 = wx.BoxSizer(wx.VERTICAL) # Clip Length. Convert to HH:MM:SS.mm self.clip_length_edit = self.new_edit_box( _("Clip Length"), v7, Misc.time_in_ms_to_str(self.obj.clip_stop - self.obj.clip_start)) # Add the element to the sizer r4Sizer.Add(v7, 1, wx.EXPAND) self.clip_length_edit.Enable(False) # Add the row sizer to the main vertical sizer mainSizer.Add(r4Sizer, 0, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Create a HORIZONTAL sizer for the next row r5Sizer = wx.BoxSizer(wx.HORIZONTAL) # Create a VERTICAL sizer for the next element v8 = wx.BoxSizer(wx.VERTICAL) # Comment comment_edit = self.new_edit_box(_("Comment"), v8, self.obj.comment, maxLen=255) # Add the element to the sizer r5Sizer.Add(v8, 1, wx.EXPAND) # Add the row sizer to the main vertical sizer mainSizer.Add(r5Sizer, 0, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Create a HORIZONTAL sizer for the next row r6Sizer = wx.BoxSizer(wx.HORIZONTAL) self.text_edit = [] # Notebook for holding Transcripts # ... we need to display them within a notebook ... self.notebook = wx.Notebook(self.panel, -1) # Add the element to the sizer r6Sizer.Add(self.notebook, 2, wx.EXPAND) # Initialize a list of notebook pages self.notebookPage = [] # Initialize a counter for notebood pages counter = 0 # Initialize the TRANSCRIPT start and stop time variables self.transcript_clip_start = [] self.transcript_clip_stop = [] # Iterate through the clip transcripts for tr in self.obj.transcripts: # Initialize the transcript start and stop time values for the individual transcripts self.transcript_clip_start.append(tr.clip_start) self.transcript_clip_stop.append(tr.clip_stop) # Create a panel for each notebook page self.notebookPage.append(wx.Panel(self.notebook)) # Add the notebook page to the notebook ... self.notebook.AddPage(self.notebookPage[counter], _('Transcript') + " %d" % (counter + 1)) # ... and use this page as the transcript object's parent transcriptParent = self.notebookPage[counter] # Clip Text # Load the Transcript into an RTF Control so the RTF Encoding won't show. # We use a list of edit controls to handle multiple transcripts. if TransanaConstants.USESRTC: self.text_edit.append( TranscriptEditor_RTC.TranscriptEditor(transcriptParent)) else: self.text_edit.append( TranscriptEditor_STC.TranscriptEditor(transcriptParent)) ## DKW EXPERIMENT 4/5/2011 self.text_edit[len(self.text_edit) - 1].load_transcript( self.obj.transcripts[counter]) self.text_edit[len(self.text_edit) - 1].SetReadOnly(False) self.text_edit[len(self.text_edit) - 1].Enable(True) # Increment the counter counter += 1 # Add the row sizer to the main vertical sizer mainSizer.Add(r6Sizer, 6, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Create a HORIZONTAL sizer for the next row r7Sizer = wx.BoxSizer(wx.HORIZONTAL) # Create a VERTICAL sizer for the next element v9 = wx.BoxSizer(wx.VERTICAL) # Keyword Group [label] txt = wx.StaticText(self.panel, -1, _("Keyword Group")) v9.Add(txt, 0, wx.BOTTOM, 3) # Keyword Group [list box] # Create an empty Keyword Group List for now. We'll populate it later (for layout reasons) self.kw_groups = [] self.kw_group_lb = wx.ListBox(self.panel, -1, choices=self.kw_groups) v9.Add(self.kw_group_lb, 1, wx.EXPAND) # Add the element to the sizer r7Sizer.Add(v9, 1, wx.EXPAND) # Create an empty Keyword List for now. We'll populate it later (for layout reasons) self.kw_list = [] wx.EVT_LISTBOX(self, self.kw_group_lb.GetId(), self.OnGroupSelect) # Add a horizontal spacer r7Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v10 = wx.BoxSizer(wx.VERTICAL) # Keyword [label] txt = wx.StaticText(self.panel, -1, _("Keyword")) v10.Add(txt, 0, wx.BOTTOM, 3) # Keyword [list box] self.kw_lb = wx.ListBox(self.panel, -1, choices=self.kw_list, style=wx.LB_EXTENDED) v10.Add(self.kw_lb, 1, wx.EXPAND) wx.EVT_LISTBOX_DCLICK(self, self.kw_lb.GetId(), self.OnAddKW) # Add the element to the sizer r7Sizer.Add(v10, 1, wx.EXPAND) # Add a horizontal spacer r7Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v11 = wx.BoxSizer(wx.VERTICAL) # Keyword transfer buttons add_kw = wx.Button(self.panel, wx.ID_FILE2, ">>", wx.DefaultPosition) v11.Add(add_kw, 0, wx.EXPAND | wx.TOP, 20) wx.EVT_BUTTON(self, wx.ID_FILE2, self.OnAddKW) rm_kw = wx.Button(self.panel, wx.ID_FILE3, "<<", wx.DefaultPosition) v11.Add(rm_kw, 0, wx.EXPAND | wx.TOP, 10) wx.EVT_BUTTON(self, wx.ID_FILE3, self.OnRemoveKW) kwm = wx.BitmapButton(self.panel, wx.ID_FILE4, TransanaImages.KWManage.GetBitmap()) v11.Add(kwm, 0, wx.EXPAND | wx.TOP, 10) # Add a spacer to increase the height of the Keywords section ## v11.Add((0, 60)) kwm.SetToolTipString(_("Keyword Management")) wx.EVT_BUTTON(self, wx.ID_FILE4, self.OnKWManage) # Add the element to the sizer r7Sizer.Add(v11, 0) # Add a horizontal spacer r7Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v12 = wx.BoxSizer(wx.VERTICAL) # Clip Keywords [label] txt = wx.StaticText(self.panel, -1, _("Clip Keywords")) v12.Add(txt, 0, wx.BOTTOM, 3) # Clip Keywords [list box] # Create an empty ListBox. We'll populate it later for layout reasons. self.ekw_lb = wx.ListBox(self.panel, -1, style=wx.LB_EXTENDED) v12.Add(self.ekw_lb, 1, wx.EXPAND) self.ekw_lb.Bind(wx.EVT_KEY_DOWN, self.OnKeywordKeyDown) # Add the element to the sizer r7Sizer.Add(v12, 2, wx.EXPAND) # Add the row sizer to the main vertical sizer mainSizer.Add(r7Sizer, 8, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Create a sizer for the buttons btnSizer = wx.BoxSizer(wx.HORIZONTAL) # Add the buttons self.create_buttons(sizer=btnSizer) # Add the button sizer to the main sizer mainSizer.Add(btnSizer, 0, wx.EXPAND) # Because of the way Clips are created (with Drag&Drop / Cut&Paste functions), we have to trap the missing # ID error here. Therefore, we need to override the EVT_BUTTON for the OK Button. # Since we don't have an object for the OK Button, we use FindWindowById to find it based on its ID. self.Bind(wx.EVT_BUTTON, self.OnOK, self.FindWindowById(wx.ID_OK)) # We also need to intercept the Cancel button. self.Bind(wx.EVT_BUTTON, self.OnCancel, self.FindWindowById(wx.ID_CANCEL)) self.Bind(wx.EVT_SIZE, self.OnSize) # Set the PANEL's main sizer self.panel.SetSizer(mainSizer) # Tell the PANEL to auto-layout self.panel.SetAutoLayout(True) # Lay out the Panel self.panel.Layout() # Lay out the panel on the form self.Layout() # Resize the form to fit the contents self.Fit() # Get the new size of the form (width, height) = self.GetSizeTuple() # Determine which monitor to use and get its size and position if TransanaGlobal.configData.primaryScreen < wx.Display.GetCount(): primaryScreen = TransanaGlobal.configData.primaryScreen else: primaryScreen = 0 rect = wx.Display(primaryScreen).GetClientArea() # Reset the form's size to be at least the specified minimum width self.SetSize( wx.Size(max(minWidth, width), min(max(minHeight, height), rect[3]))) # Define the minimum size for this dialog as the current size self.SetSizeHints(max(minWidth, width), min(max(minHeight, height), rect[3])) # Center the form on screen TransanaGlobal.CenterOnPrimary(self) # We need to set some minimum sizes so the sizers will work right self.kw_group_lb.SetSizeHints(minW=50, minH=20) self.kw_lb.SetSizeHints(minW=50, minH=20) self.ekw_lb.SetSizeHints(minW=50, minH=20) # We populate the Keyword Groups, Keywords, and Clip Keywords lists AFTER we determine the Form Size. # Long Keywords in the list were making the form too big! self.kw_groups = DBInterface.list_of_keyword_groups() for keywordGroup in self.kw_groups: self.kw_group_lb.Append(keywordGroup) # Populate the Keywords ListBox # Load the parent Collection in order to determine the default Keyword Group tempCollection = Collection.Collection(self.obj.collection_num) # Select the Collection Default Keyword Group in the Keyword Group list if (tempCollection.keyword_group != '') and (self.kw_group_lb.FindString( tempCollection.keyword_group) != wx.NOT_FOUND): self.kw_group_lb.SetStringSelection(tempCollection.keyword_group) # If no Default Keyword Group is defined, select the first item in the list else: # but only if there IS a first item. if len(self.kw_groups) > 0: self.kw_group_lb.SetSelection(0) # If there's a selected keyword group ... if self.kw_group_lb.GetSelection() != wx.NOT_FOUND: # populate the Keywords list self.kw_list = \ DBInterface.list_of_keywords_by_group(self.kw_group_lb.GetStringSelection()) else: # If not, create a blank one self.kw_list = [] for keyword in self.kw_list: self.kw_lb.Append(keyword) # Populate the Clip Keywords ListBox # If the clip object has keywords ... for clipKeyword in self.obj.keyword_list: # ... add them to the keyword list self.ekw_lb.Append(clipKeyword.keywordPair) # If we have a Notebook of text controls ... if self.notebookPage: # ... interate through the text controls ... for textCtrl in self.text_edit: # ... and set them to the size of the notebook page. textCtrl.SetSize(self.notebookPage[0].GetSizeTuple()) # Set initial focus to the Clip ID self.id_edit.SetFocus()
def __init__(self, parent, id, title, ep_object): # Make the Keyword Edit List resizable by passing wx.RESIZE_BORDER style Dialogs.GenForm.__init__(self, parent, id, title, (550,435), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, useSizers = True, HelpContext='Episode Properties') # Remember the Parent Window self.parent = parent self.obj = ep_object # Create the form's main VERTICAL sizer mainSizer = wx.BoxSizer(wx.VERTICAL) # Create a HORIZONTAL sizer for the first row r1Sizer = wx.BoxSizer(wx.HORIZONTAL) # Create a VERTICAL sizer for the next element v1 = wx.BoxSizer(wx.VERTICAL) # Episode ID self.id_edit = self.new_edit_box(_("Episode ID"), v1, self.obj.id, maxLen=100) # Add the element to the sizer r1Sizer.Add(v1, 1, wx.EXPAND) # Add the row sizer to the main vertical sizer mainSizer.Add(r1Sizer, 0, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Create a HORIZONTAL sizer for the next row r2Sizer = wx.BoxSizer(wx.HORIZONTAL) # Create a VERTICAL sizer for the next element v2 = wx.BoxSizer(wx.VERTICAL) # Library ID layout series_edit = self.new_edit_box(_("Library ID"), v2, self.obj.series_id) # Add the element to the sizer r2Sizer.Add(v2, 2, wx.EXPAND) series_edit.Enable(False) # Add a horizontal spacer to the row sizer r2Sizer.Add((10, 0)) # Dialogs.GenForm does not provide a Masked text control, so the Date # Field is handled differently than other fields. # Create a VERTICAL sizer for the next element v3 = wx.BoxSizer(wx.VERTICAL) # Date [label] date_lbl = wx.StaticText(self.panel, -1, _("Date (MM/DD/YYYY)")) v3.Add(date_lbl, 0, wx.BOTTOM, 3) # Date # Use the Masked Text Control (Requires wxPython 2.4.2.4 or later) # TODO: Make Date autoformat localizable self.dt_edit = wx.lib.masked.TextCtrl(self.panel, -1, '', autoformat='USDATEMMDDYYYY/') v3.Add(self.dt_edit, 0, wx.EXPAND) # If a Date is know, load it into the control if (self.obj.tape_date != None) and (self.obj.tape_date != '') and (self.obj.tape_date != '01/01/0'): self.dt_edit.SetValue(self.obj.tape_date) # Add the element to the sizer r2Sizer.Add(v3, 1, wx.EXPAND) # Add a horizontal spacer to the row sizer r2Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v4 = wx.BoxSizer(wx.VERTICAL) # Length self.len_edit = self.new_edit_box(_("Length"), v4, self.obj.tape_length_str()) # Add the element to the sizer r2Sizer.Add(v4, 1, wx.EXPAND) self.len_edit.Enable(False) # Add the row sizer to the main vertical sizer mainSizer.Add(r2Sizer, 0, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Media Filename(s) [label] txt = wx.StaticText(self.panel, -1, _("Media Filename(s)")) mainSizer.Add(txt, 0, wx.BOTTOM, 3) # Create a HORIZONTAL sizer for the next row r3Sizer = wx.BoxSizer(wx.HORIZONTAL) # Media Filename(s) # If the media filename path is not empty, we should normalize the path specification if self.obj.media_filename == '': filePath = self.obj.media_filename else: filePath = os.path.normpath(self.obj.media_filename) # Initialize the list of media filenames with the first one. self.filenames = [filePath] # For each additional Media file ... for vid in self.obj.additional_media_files: # ... add it to the filename list self.filenames.append(vid['filename']) self.fname_lb = wx.ListBox(self.panel, -1, wx.DefaultPosition, wx.Size(180, 60), self.filenames) # Add the element to the sizer r3Sizer.Add(self.fname_lb, 5, wx.EXPAND) self.fname_lb.SetDropTarget(ListBoxFileDropTarget(self.fname_lb, self.obj)) # Add a horizontal spacer to the row sizer r3Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v4 = wx.BoxSizer(wx.VERTICAL) # Add File button layout addFile = wx.Button(self.panel, wx.ID_FILE1, _("Add File"), wx.DefaultPosition) v4.Add(addFile, 0, wx.EXPAND | wx.BOTTOM, 3) wx.EVT_BUTTON(self, wx.ID_FILE1, self.OnBrowse) # Remove File button layout removeFile = wx.Button(self.panel, -1, _("Remove File"), wx.DefaultPosition) v4.Add(removeFile, 0, wx.EXPAND | wx.BOTTOM, 3) wx.EVT_BUTTON(self, removeFile.GetId(), self.OnRemoveFile) if TransanaConstants.proVersion: # SynchronizeFiles button layout synchronize = wx.Button(self.panel, -1, _("Synchronize"), wx.DefaultPosition) v4.Add(synchronize, 0, wx.EXPAND) synchronize.Bind(wx.EVT_BUTTON, self.OnSynchronize) # Add the element to the sizer r3Sizer.Add(v4, 1, wx.EXPAND) # If Mac ... if 'wxMac' in wx.PlatformInfo: # ... add a spacer to avoid control clipping r3Sizer.Add((2, 0)) # Add the row sizer to the main vertical sizer mainSizer.Add(r3Sizer, 0, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Create a HORIZONTAL sizer for the next row r4Sizer = wx.BoxSizer(wx.HORIZONTAL) # Create a VERTICAL sizer for the next element v5 = wx.BoxSizer(wx.VERTICAL) # Comment comment_edit = self.new_edit_box(_("Comment"), v5, self.obj.comment, maxLen=255) # Add the element to the sizer r4Sizer.Add(v5, 1, wx.EXPAND) # Add the row sizer to the main vertical sizer mainSizer.Add(r4Sizer, 0, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Create a HORIZONTAL sizer for the next row r5Sizer = wx.BoxSizer(wx.HORIZONTAL) # Create a VERTICAL sizer for the next element v6 = wx.BoxSizer(wx.VERTICAL) # Keyword Group [label] txt = wx.StaticText(self.panel, -1, _("Keyword Group")) v6.Add(txt, 0, wx.BOTTOM, 3) # Keyword Group [list box] kw_groups_id = wx.NewId() # Create an empty Keyword Group List for now. We'll populate it later (for layout reasons) self.kw_groups = [] self.kw_group_lb = wx.ListBox(self.panel, kw_groups_id, wx.DefaultPosition, wx.DefaultSize, self.kw_groups) v6.Add(self.kw_group_lb, 1, wx.EXPAND) # Add the element to the sizer r5Sizer.Add(v6, 1, wx.EXPAND) self.kw_list = [] wx.EVT_LISTBOX(self, kw_groups_id, self.OnGroupSelect) # Add a horizontal spacer r5Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v7 = wx.BoxSizer(wx.VERTICAL) # Keyword [label] txt = wx.StaticText(self.panel, -1, _("Keyword")) v7.Add(txt, 0, wx.BOTTOM, 3) # Keyword [list box] self.kw_lb = wx.ListBox(self.panel, -1, wx.DefaultPosition, wx.DefaultSize, self.kw_list, style=wx.LB_EXTENDED) v7.Add(self.kw_lb, 1, wx.EXPAND) wx.EVT_LISTBOX_DCLICK(self, self.kw_lb.GetId(), self.OnAddKW) # Add the element to the sizer r5Sizer.Add(v7, 1, wx.EXPAND) # Add a horizontal spacer r5Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v8 = wx.BoxSizer(wx.VERTICAL) # Keyword transfer buttons add_kw = wx.Button(self.panel, wx.ID_FILE2, ">>", wx.DefaultPosition) v8.Add(add_kw, 0, wx.EXPAND | wx.TOP, 20) wx.EVT_BUTTON(self.panel, wx.ID_FILE2, self.OnAddKW) rm_kw = wx.Button(self.panel, wx.ID_FILE3, "<<", wx.DefaultPosition) v8.Add(rm_kw, 0, wx.EXPAND | wx.TOP, 10) wx.EVT_BUTTON(self, wx.ID_FILE3, self.OnRemoveKW) kwm = wx.BitmapButton(self.panel, wx.ID_FILE4, TransanaImages.KWManage.GetBitmap()) v8.Add(kwm, 0, wx.EXPAND | wx.TOP, 10) # Add a spacer to increase the height of the Keywords section v8.Add((0, 60)) kwm.SetToolTipString(_("Keyword Management")) wx.EVT_BUTTON(self, wx.ID_FILE4, self.OnKWManage) # Add the element to the sizer r5Sizer.Add(v8, 0) # Add a horizontal spacer r5Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v9 = wx.BoxSizer(wx.VERTICAL) # Episode Keywords [label] txt = wx.StaticText(self.panel, -1, _("Episode Keywords")) v9.Add(txt, 0, wx.BOTTOM, 3) # Episode Keywords [list box] # Create an empty ListBox self.ekw_lb = wx.ListBox(self.panel, -1, wx.DefaultPosition, wx.DefaultSize, style=wx.LB_EXTENDED) v9.Add(self.ekw_lb, 1, wx.EXPAND) self.ekw_lb.Bind(wx.EVT_KEY_DOWN, self.OnKeywordKeyDown) # Add the element to the sizer r5Sizer.Add(v9, 2, wx.EXPAND) # Add the row sizer to the main vertical sizer mainSizer.Add(r5Sizer, 5, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Create a sizer for the buttons btnSizer = wx.BoxSizer(wx.HORIZONTAL) # Core Data button layout CoreData = wx.Button(self.panel, -1, _("Core Data")) # If Mac ... if 'wxMac' in wx.PlatformInfo: # ... add a spacer to avoid control clipping btnSizer.Add((2, 0)) btnSizer.Add(CoreData, 0) wx.EVT_BUTTON(self, CoreData.GetId(), self.OnCoreDataClick) # Add the buttons self.create_buttons(sizer=btnSizer) # Add the button sizer to the main sizer mainSizer.Add(btnSizer, 0, wx.EXPAND) # If Mac ... if 'wxMac' in wx.PlatformInfo: # ... add a spacer to avoid control clipping mainSizer.Add((0, 2)) # Set the PANEL's main sizer self.panel.SetSizer(mainSizer) # Tell the PANEL to auto-layout self.panel.SetAutoLayout(True) # Lay out the Panel self.panel.Layout() # Lay out the panel on the form self.Layout() # Resize the form to fit the contents self.Fit() # Get the new size of the form (width, height) = self.GetSizeTuple() # Reset the form's size to be at least the specified minimum width self.SetSize(wx.Size(max(550, width), max(435, height))) # Define the minimum size for this dialog as the current size self.SetSizeHints(max(550, width), max(435, height)) # Center the form on screen TransanaGlobal.CenterOnPrimary(self) # We need to set some minimum sizes so the sizers will work right self.kw_group_lb.SetSizeHints(minW = 50, minH = 20) self.kw_lb.SetSizeHints(minW = 50, minH = 20) self.ekw_lb.SetSizeHints(minW = 50, minH = 20) # We populate the Keyword Groups, Keywords, and Clip Keywords lists AFTER we determine the Form Size. # Long Keywords in the list were making the form too big! self.kw_groups = DBInterface.list_of_keyword_groups() for keywordGroup in self.kw_groups: self.kw_group_lb.Append(keywordGroup) # Load the parent Library in order to determine the default Keyword Group tempLibrary = Library.Library(self.obj.series_id) # Select the Library Default Keyword Group in the Keyword Group list if (tempLibrary.keyword_group != '') and (self.kw_group_lb.FindString(tempLibrary.keyword_group) != wx.NOT_FOUND): self.kw_group_lb.SetStringSelection(tempLibrary.keyword_group) # If no Default Keyword Group is defined, select the first item in the list else: # but only if there IS a first item in the list. if len(self.kw_groups) > 0: self.kw_group_lb.SetSelection(0) if self.kw_group_lb.GetSelection() != wx.NOT_FOUND: self.kw_list = \ DBInterface.list_of_keywords_by_group(self.kw_group_lb.GetStringSelection()) else: self.kw_list = [] for keyword in self.kw_list: self.kw_lb.Append(keyword) # Populate the ListBox for episodeKeyword in self.obj.keyword_list: self.ekw_lb.Append(episodeKeyword.keywordPair) self.id_edit.SetFocus()
def __init__(self, parent): global widgets_list wx.Dialog.__init__(self, parent, -1, 'Calendar Entry Editor', wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) # the parent is the BPCalenda widget, save it self.cw = parent # also the BPCalendar object # Tracking of the entries in the listbox. Each entry is a dict. Entries are just the # entries in a random order. entrymap maps from the order in the listbox to a # specific entry self.entries = [] self.entrymap = [] self._current_entry = None # Dirty tracking. We restrict what the user can do while editting an # entry to only be able to edit that entry. 'dirty' gets fired when # they make any updates. Annoyingly, controls generate change events # when they are updated programmatically as well as by user interaction. # ignoredirty is set when we are programmatically updating controls self.dirty = None self.ignoredirty = True # overall container vbs = wx.BoxSizer(wx.VERTICAL) self._prev_btn = wx.BitmapButton(self, wx.NewId(), wx.ArtProvider.GetBitmap( guihelper.ART_ARROW_LEFT), name="Previous Day") self._next_btn = wx.BitmapButton(self, wx.NewId(), wx.ArtProvider.GetBitmap( guihelper.ART_ARROW_RIGHT), name="Next Day") self.title = wx.StaticText(self, -1, "Date here", style=wx.ALIGN_CENTRE | wx.ST_NO_AUTORESIZE) # top row container hbs1 = wx.BoxSizer(wx.HORIZONTAL) hbs1.Add(self._prev_btn, 0, wx.EXPAND) hbs1.Add(self.title, 1, wx.EXPAND) hbs1.Add(self._next_btn, 0, wx.EXPAND) vbs.Add(hbs1, 0, wx.TOP | wx.EXPAND, 10) # list box and two buttons below self.listbox = wx.ListBox(self, wx.NewId(), style=wx.LB_SINGLE | wx.LB_HSCROLL | wx.LB_NEEDED_SB) self._add_btn = wx.Button(self, wx.ID_NEW) hbs2 = wx.BoxSizer(wx.HORIZONTAL) hbs2.Add(self._add_btn, 1, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT, border=5) # sizer for listbox lbs = wx.BoxSizer(wx.VERTICAL) lbs.Add(self.listbox, 1, wx.EXPAND | wx.BOTTOM, border=5) lbs.Add(hbs2, 0, wx.EXPAND) # right hand bit with all fields self._nb = wx.Notebook(self, -1) self._widgets = [] for i, (name, key, klass, color_name) in enumerate(self._items): if name in ('Ringtones', 'Wallpapers'): self._widgets.append(klass(self._nb, parent, False)) else: self._widgets.append(klass(self._nb, parent)) self._nb.AddPage(self._widgets[i], name) if color_name: widgets_list.append((self._widgets[i].static_box, color_name)) # buttons below fields self._delete_btn = wx.Button(self, wx.ID_DELETE) self._revert_btn = wx.Button(self, wx.ID_REVERT_TO_SAVED) self._save_btn = wx.Button(self, wx.ID_SAVE) hbs4 = wx.BoxSizer(wx.HORIZONTAL) hbs4.Add(self._delete_btn, 1, wx.ALIGN_CENTRE | wx.LEFT, border=10) hbs4.Add(self._revert_btn, 1, wx.ALIGN_CENTRE | wx.LEFT | wx.RIGHT, border=10) hbs4.Add(self._save_btn, 1, wx.ALIGN_CENTRE | wx.RIGHT, border=10) # fields and buttons together vbs2 = wx.BoxSizer(wx.VERTICAL) vbs2.Add(self._nb, 1, wx.EXPAND | wx.BOTTOM, border=5) vbs2.Add(hbs4, 0, wx.EXPAND | wx.ALIGN_CENTRE) # container for everything below title row hbs3 = wx.BoxSizer(wx.HORIZONTAL) hbs3.Add(lbs, 1, wx.EXPAND | wx.ALL, 5) hbs3.Add(vbs2, 2, wx.EXPAND | wx.ALL, 5) vbs.Add(hbs3, 1, wx.EXPAND) # the standard buttons vbs.Add(wx.StaticLine(self, -1, style=wx.LI_HORIZONTAL), 0, wx.EXPAND | wx.ALL, 5) vbs.Add(self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.HELP), 0, wx.ALIGN_CENTRE | wx.ALL, 5) self.SetSizer(vbs) self.SetAutoLayout(True) vbs.Fit(self) # delete is disabled until an item is selected self._delete_btn.Enable(False) wx.EVT_LISTBOX(self, self.listbox.GetId(), self.OnListBoxItem) wx.EVT_LISTBOX_DCLICK(self, self.listbox.GetId(), self.OnListBoxItem) wx.EVT_BUTTON(self, wx.ID_SAVE, self.OnSaveButton) wx.EVT_BUTTON(self, wx.ID_REVERT_TO_SAVED, self.OnRevertButton) wx.EVT_BUTTON(self, wx.ID_NEW, self.OnNewButton) wx.EVT_BUTTON(self, wx.ID_DELETE, self.OnDeleteButton) wx.EVT_BUTTON(self, self._prev_btn.GetId(), self.OnPrevDayButton) wx.EVT_BUTTON(self, self._next_btn.GetId(), self.OnNextDayButton) # callbacks for the standard buttons wx.EVT_BUTTON(self, wx.ID_OK, self.OnOk) wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel) wx.EVT_BUTTON( self, wx.ID_HELP, lambda _: wx.GetApp().displayhelpid( helpids.ID_EDITING_CALENDAR_EVENTS)) # DIRTY UI Event handlers for w in self._widgets: pb_editor.EVT_DIRTY_UI(self, w.GetId(), self.OnMakeDirty) self.ignoredirty = False self.setdirty(False) guiwidgets.set_size("CalendarEntryEditor", self, 52, 1.0) field_color.reload_color_info(self, widgets_list) pubsub.subscribe(self.OnPhoneChanged, pubsub.PHONE_MODEL_CHANGED)
def __init__(self, parent, id, title, obj, keywords): # Make the Keyword Edit List resizable by passing wx.RESIZE_BORDER style Dialogs.GenForm.__init__(self, parent, id, title, size=TransanaGlobal.configData.keywordListEditSize, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER, useSizers = True, HelpContext='Edit Keywords') # Remember the parent Window self.parent = parent self.obj = obj # if Keywords that server as Keyword Examples are removed, we will need to remember them. # Then, when OK is pressed, the Keyword Example references in the Database Tree can be removed. # We can't remove them immediately in case the whole Clip Properties Edit process is cancelled. self.keywordExamplesToDelete = [] # COPY the keyword list, rather than just pointing to it, so that the list on this form will # be independent of the original list. That way, pressing CANCEL does not cause the list to # be changed anyway, though it means that if OK is pressed, you must copy the list to update # it in the calling routine. self.keywords = [] for kws in keywords: self.keywords.append(kws) # Create the form's main VERTICAL sizer mainSizer = wx.BoxSizer(wx.VERTICAL) # Create a HORIZONTAL sizer for the first row r1Sizer = wx.BoxSizer(wx.HORIZONTAL) # Create a VERTICAL sizer for the next element v1 = wx.BoxSizer(wx.VERTICAL) # Keyword Group [label] txt = wx.StaticText(self.panel, -1, _("Keyword Group")) v1.Add(txt, 0, wx.BOTTOM, 3) # Keyword Group layout [list box] # Create an empty Keyword Group List for now. We'll populate it later (for layout reasons) self.kw_groups = [] self.kw_group_lb = wx.ListBox(self.panel, 101, wx.DefaultPosition, wx.DefaultSize, self.kw_groups) v1.Add(self.kw_group_lb, 1, wx.EXPAND) # Add the element to the sizer r1Sizer.Add(v1, 1, wx.EXPAND) self.kw_list = [] wx.EVT_LISTBOX(self, 101, self.OnGroupSelect) # Add a horizontal spacer r1Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v2 = wx.BoxSizer(wx.VERTICAL) # Keyword [label] txt = wx.StaticText(self.panel, -1, _("Keyword")) v2.Add(txt, 0, wx.BOTTOM, 3) # Keyword [list box] self.kw_lb = wx.ListBox(self.panel, -1, wx.DefaultPosition, wx.DefaultSize, self.kw_list, style=wx.LB_EXTENDED) v2.Add(self.kw_lb, 1, wx.EXPAND) wx.EVT_LISTBOX_DCLICK(self, self.kw_lb.GetId(), self.OnAddKW) # Add the element to the sizer r1Sizer.Add(v2, 1, wx.EXPAND) # Add a horizontal spacer r1Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v3 = wx.BoxSizer(wx.VERTICAL) # Keyword transfer buttons add_kw = wx.Button(self.panel, wx.ID_FILE2, ">>", wx.DefaultPosition) v3.Add(add_kw, 0, wx.EXPAND | wx.TOP, 20) wx.EVT_BUTTON(self, wx.ID_FILE2, self.OnAddKW) rm_kw = wx.Button(self.panel, wx.ID_FILE3, "<<", wx.DefaultPosition) v3.Add(rm_kw, 0, wx.EXPAND | wx.TOP, 10) wx.EVT_BUTTON(self, wx.ID_FILE3, self.OnRemoveKW) kwm = wx.BitmapButton(self.panel, wx.ID_FILE4, TransanaImages.KWManage.GetBitmap()) v3.Add(kwm, 0, wx.EXPAND | wx.TOP, 10) # Add a spacer to increase the height of the Keywords section v3.Add((0, 60)) kwm.SetToolTipString(_("Keyword Management")) wx.EVT_BUTTON(self, wx.ID_FILE4, self.OnKWManage) # Add the element to the sizer r1Sizer.Add(v3, 0) # Add a horizontal spacer r1Sizer.Add((10, 0)) # Create a VERTICAL sizer for the next element v4 = wx.BoxSizer(wx.VERTICAL) # Keywords [label] txt = wx.StaticText(self.panel, -1, _("Keywords")) v4.Add(txt, 0, wx.BOTTOM, 3) # Keywords [list box] # Create an empty ListBox self.ekw_lb = wx.ListBox(self.panel, -1, wx.DefaultPosition, wx.DefaultSize, style=wx.LB_EXTENDED) v4.Add(self.ekw_lb, 1, wx.EXPAND) self.ekw_lb.Bind(wx.EVT_KEY_DOWN, self.OnKeywordKeyDown) # Add the element to the sizer r1Sizer.Add(v4, 2, wx.EXPAND) # Add the row sizer to the main vertical sizer mainSizer.Add(r1Sizer, 1, wx.EXPAND) # Add a vertical spacer to the main sizer mainSizer.Add((0, 10)) # Create a sizer for the buttons btnSizer = wx.BoxSizer(wx.HORIZONTAL) # Add the buttons self.create_buttons(sizer=btnSizer) # Add the button sizer to the main sizer mainSizer.Add(btnSizer, 0, wx.EXPAND) # If Mac ... if 'wxMac' in wx.PlatformInfo: # ... add a spacer to avoid control clipping mainSizer.Add((0, 2)) # Set the PANEL's main sizer self.panel.SetSizer(mainSizer) # Tell the PANEL to auto-layout self.panel.SetAutoLayout(True) # Lay out the Panel self.panel.Layout() # Lay out the panel on the form self.Layout() # Resize the form to fit the contents self.Fit() # Get the new size of the form (width, height) = self.GetSizeTuple() # Reset the form's size to be at least the specified minimum width self.SetSize(wx.Size(max(600, width), max(385, height))) # Define the minimum size for this dialog as the current size self.SetSizeHints(max(600, width), max(385, height)) # Center the form on screen TransanaGlobal.CenterOnPrimary(self) # We need to set some minimum sizes so the sizers will work right self.kw_group_lb.SetSizeHints(minW = 50, minH = 20) self.kw_lb.SetSizeHints(minW = 50, minH = 20) self.ekw_lb.SetSizeHints(minW = 50, minH = 20) # We need to capture the OK and Cancel button clicks locally. We'll use FindWindowByID to locate the correct widgets. self.Bind(wx.EVT_BUTTON, self.OnOK, self.FindWindowById(wx.ID_OK)) self.Bind(wx.EVT_BUTTON, self.OnCancel, self.FindWindowById(wx.ID_CANCEL)) # We populate the Keyword Groups, Keywords, and Clip Keywords lists AFTER we determine the Form Size. # Long Keywords in the list were making the form too big! # Obtain the list of Keyword Groups self.kw_groups = DBInterface.list_of_keyword_groups() for keywordGroup in self.kw_groups: self.kw_group_lb.Append(keywordGroup) if self.kw_group_lb.GetCount() > 0: self.kw_group_lb.EnsureVisible(0) # Get the Parent Object, so we can know the Default Keyword Group if isinstance(self.obj, Episode.Episode): objParent = Library.Library(self.obj.series_num) elif isinstance(self.obj, Document.Document): objParent = Library.Library(self.obj.library_num) elif isinstance(self.obj, Clip.Clip) or isinstance(self.obj, Snapshot.Snapshot) or isinstance(self.obj, Quote.Quote): objParent = Collection.Collection(self.obj.collection_num) if len(self.kw_groups) > 0: # Set the Keyword Group to the Default keyword Group if self.kw_group_lb.FindString(objParent.keyword_group) != wx.NOT_FOUND: self.kw_group_lb.SetStringSelection(objParent.keyword_group) else: self.kw_group_lb.SetSelection(0) # Obtain the list of Keywords for the intial Keyword Group self.kw_list = DBInterface.list_of_keywords_by_group(self.kw_group_lb.GetStringSelection()) else: self.kw_list = [] for keyword in self.kw_list: self.kw_lb.Append(keyword) if self.kw_lb.GetCount() > 0: self.kw_lb.EnsureVisible(0) # Populate the ListBox for clipKeyword in self.keywords: self.ekw_lb.Append(clipKeyword.keywordPair) if self.ekw_lb.GetCount() > 0: self.ekw_lb.EnsureVisible(0) self.kw_group_lb.SetFocus()
def __init__(self, parent, port=None): ToolPane.__init__(self, parent, port) '''project variables''' self.curpose = "" #initial name of pose self.saveReq = False self.go_live = False #@todo this she be held in project, check to make sure project variables = 5 #phantom x only uses 5 dynamixels self.parent.project.count = 5 self.dynamixels = [0] * 5 #holds the values of the dynamixels (0-1024) self.oldmixels = [0] * self.parent.project.count #should handle this in parent self.parent.Move((0, 0)) #open window in upper left corner self.figure = Figure() #create a matplot figure self.canvas = FigCanvas(self, -1, self.figure) # You must set up the canvas before creating the 3D axes self.axes = Axes3D(self.figure) self.axes.azim = 150 #initial azimuth view is looking at home position in degrees # slider settings self.slider_SP = [150, 60, 80, -45, 512] #starting position a0,w,z,ga,g self.slider_minL = [0, -20, -60, -90, 0] self.slider_maxL = [300, 310, 310, 90, 1023] self.label_list = [ "Rotation a0: ", "Extension w: ", "Height z: ", "Gripper angle ", "Gripper: " ] self.datagen = Robot_Cord( self.slider_SP ) #data gen object handles positioning of servo,(x,y,z)...ect self.draw_plot() #draw the plot at the top of the frame #handy timer is there a app timer? self.t1 = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.OnTest1Timer) self.box = wx.BoxSizer(wx.VERTICAL) #a box to add sliders too self.box.Add(self.canvas, 1, flag=wx.LEFT | wx.TOP | wx.GROW) sizer = wx.GridBagSizer(5, 5) # main sizer edit,list,buttons temp = wx.StaticBox(self, wx.NewId(), 'edit Picher arm') temp.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)) editBox = wx.StaticBoxSizer(temp, orient=wx.VERTICAL | wx.GROW) poseEditSizer = wx.GridBagSizer(0, 0) # edit pose sizer box poseEditSizer.AddGrowableCol(0) #allow sliders to expand in column 1 # a box of slider panels self.sliders = list() # the editors in the window for i in range(self.parent.project.count): temp = wx.Panel(self, -1) hbox = wx.BoxSizer(wx.HORIZONTAL) temp.text = wx.StaticText(temp, i, self.label_list[i]) #name is i temp.position = wx.Slider( temp, i, self.slider_SP[i], self.slider_minL[i], self.slider_maxL[i], wx.DefaultPosition, (325, -1), wx.SL_HORIZONTAL | wx.SL_LABELS | wx.EXPAND | wx.GROW) #put the panel in the sizer hbox.Add(temp.text, flag=wx.ALL | wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) hbox.Add(temp.position, flag=wx.EXPAND | wx.ALL | wx.ALIGN_LEFT | wx.GROW) temp.SetSizerAndFit(hbox) poseEditSizer.Add(temp, (i, 0), span=(1, 1), flag=wx.EXPAND | wx.ALL | wx.ALIGN_LEFT | wx.GROW, border=2) temp.Disable( ) # servo editors start out disabled, enabled when a pose is selected self.sliders.append(temp) #build a list of servo panels self.servos = self.datagen.sliders_to_dynamixels(self.sliders) # grid it editBox.Add(poseEditSizer) sizer.Add(editBox, (0, 0), wx.GBSpan(1, 1), wx.EXPAND | wx.GROW) # list of poses self.posebox = wx.ListBox(self, self.ID_POSE_BOX, choices=self.parent.project.poses.keys()) sizer.Add(self.posebox, pos=(0, 1), span=(1, 1), flag=wx.EXPAND | wx.ALL) # and buttons hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(wx.Button(self, self.BT_POSE_ADD, 'add')) hbox.Add(wx.Button(self, self.BT_POSE_REM, 'remove')) hbox.Add(wx.Button(self, self.BT_POSE_RENAME, 'rename')) sizer.Add(hbox, (1, 1), wx.GBSpan(1, 1), wx.ALIGN_CENTER) # toolbar toolbar = wx.Panel(self, -1) toolbarsizer = wx.BoxSizer(wx.HORIZONTAL) self.toggle_live = wx.ToggleButton(toolbar, self.BT_LIVE, "live") toolbarsizer.Add(self.toggle_live, 1) # delta-T for interpolation self.deltaTButton = wx.Button(toolbar, self.BT_DELTA_T, 'delta-T') self.deltaTButton.Disable() toolbarsizer.Add(self.deltaTButton, 1) self.deltaT = 2000 if port != None and port.hasInterpolation == True: self.deltaTButton.Enable() #add buttons to the sizer toolbarsizer.Add(wx.Button(toolbar, self.BT_RELAX, 'relax'), 1) toolbarsizer.Add(wx.Button(toolbar, self.BT_CAPTURE, 'capture'), 1) toolbarsizer.Add(wx.Button(toolbar, self.BT_SET, 'set'), 1) toolbar.SetSizer(toolbarsizer) sizer.Add(toolbar, (1, 0), wx.GBSpan(1, 1), wx.ALIGN_CENTER) #bind slider self.Bind(wx.EVT_SLIDER, self.updatePose) self.Bind(wx.EVT_CHECKBOX, self.relaxServo) wx.EVT_BUTTON(self, self.BT_RELAX, self.parent.doRelax) wx.EVT_BUTTON(self, self.BT_CAPTURE, self.capturePose) wx.EVT_BUTTON(self, self.BT_SET, self.setPose) wx.EVT_BUTTON(self, self.BT_POSE_ADD, self.addPose) wx.EVT_BUTTON(self, self.BT_POSE_REM, self.remPose) wx.EVT_BUTTON(self, self.BT_POSE_RENAME, self.renamePose) wx.EVT_BUTTON(self, self.BT_DELTA_T, self.doDeltaT) wx.EVT_LISTBOX(self, self.ID_POSE_BOX, self.doPose) # key accelerators aTable = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('S'), self.BT_CAPTURE), # capture Servos (wx.ACCEL_CTRL, ord('R'), self.BT_RELAX), # Relax (wx.ACCEL_CTRL, ord('A'), self.BT_POSE_ADV), # Advance ]) self.SetAcceleratorTable(aTable) self.Bind(wx.EVT_TOGGLEBUTTON, self.live_bt, id=self.BT_LIVE) self.Bind(wx.EVT_MENU, self.capturePose, id=self.BT_CAPTURE) self.Bind(wx.EVT_MENU, self.parent.doRelax, id=self.BT_RELAX) self.Bind(wx.EVT_MENU, self.advancePose, id=self.BT_POSE_ADV) self.box.Add(sizer, 0, wx.ALL | wx.EXPAND | wx.GROW) #add the sizer to the box self.SetSizerAndFit(self.box) #add the box to the panel self.box.Fit(self.parent) #expand to fit Frame
def __init__(self, parent, traceDimension, isFrom, envName=''): wx.Dialog.__init__(self, parent, TRACE_ID, 'Contributions', style=wx.DEFAULT_DIALOG_STYLE | wx.MAXIMIZE_BOX | wx.THICK_FRAME | wx.RESIZE_BORDER, size=(800, 300)) b = Borg() self.dbProxy = b.dbProxy self.theTraceDimension = traceDimension self.isFromIndicator = isFrom self.theSelectedValue = '' self.theToDimension = '' self.theLabel = '' self.theEnvironmentName = envName mainSizer = wx.BoxSizer(wx.VERTICAL) frameSizer = wx.BoxSizer(wx.HORIZONTAL) mainSizer.Add(frameSizer, 1, wx.EXPAND) dimensionSizer = wx.BoxSizer(wx.VERTICAL) frameSizer.Add(dimensionSizer, 0, wx.EXPAND) dimensionLabel = wx.StaticText(self, -1, 'Dimension:') dimensionSizer.Add(dimensionLabel) dimensions = self.dbProxy.getTraceDimensions(self.theTraceDimension, self.isFromIndicator) self.dimensionList = wx.ListBox(self, TRACE_LISTDIM_ID, choices=dimensions, style=wx.LB_SINGLE) dimensionSizer.Add(self.dimensionList, 1, wx.EXPAND) valueSizer = wx.BoxSizer(wx.VERTICAL) frameSizer.Add(valueSizer, 1, wx.EXPAND) valueLabel = wx.StaticText(self, -1, 'Value:') valueSizer.Add(valueLabel) self.valueList = wx.ListBox(self, TRACE_LISTVALUES_ID, style=wx.LB_SINGLE) valueSizer.Add(self.valueList, 1, wx.EXPAND) labelBox = wx.StaticBox(self, -1, 'Label') labelBoxSizer = wx.StaticBoxSizer(labelBox, wx.HORIZONTAL) mainSizer.Add(labelBoxSizer, 0, wx.EXPAND) self.labelCtrl = wx.TextCtrl(self, TRACE_TEXTLABEL_ID, '') labelBoxSizer.Add(self.labelCtrl, 1, wx.EXPAND) self.labelCtrl.Disable() buttonSizer = wx.BoxSizer(wx.HORIZONTAL) mainSizer.Add(buttonSizer, 0, wx.ALIGN_CENTER) addButton = wx.Button(self, TRACE_BUTTONADD_ID, "Add") buttonSizer.Add(addButton) cancelButton = wx.Button(self, wx.ID_CANCEL, "Cancel") buttonSizer.Add(cancelButton) self.SetSizer(mainSizer) wx.EVT_LISTBOX(self.dimensionList, TRACE_LISTDIM_ID, self.onDimItemSelected) wx.EVT_LISTBOX(self.valueList, TRACE_LISTVALUES_ID, self.onValueItemSelected) wx.EVT_BUTTON(self, TRACE_BUTTONADD_ID, self.onAdd) wx.EVT_BUTTON(self, wx.ID_CANCEL, self.onClose)
def __init__ (self, parent, pos, size, callback): wx.ListBox.__init__(self, parent, -1, pos, size, style=wx.LB_SINGLE | wx.LB_NEEDED_SB) self.callback = callback self.alive = 1 # 0=dead, 1=alive, 2=must die wx.EVT_LISTBOX (self, self.GetId(), self.OnList)
def __init__(self, parent, port=None): ToolPane.__init__(self, parent, port) self.curpose = "" self.saveReq = False self.live = self.parent.live.IsChecked() sizer = wx.GridBagSizer(10, 10) # pose editor, goes in a box: temp = wx.StaticBox(self, -1, 'edit pose') temp.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD)) editBox = wx.StaticBoxSizer(temp, orient=wx.VERTICAL) poseEditSizer = wx.GridBagSizer(5, 5) # build servo editors self.servos = list() # the editors in the window for i in range(self.parent.project.count): temp = wx.Panel(self, -1) hbox = wx.BoxSizer(wx.HORIZONTAL) if (i + 1) < 10: temp.enable = wx.CheckBox(temp, i, "ID 0" + str(i + 1)) else: temp.enable = wx.CheckBox(temp, i, "ID " + str(i + 1)) temp.enable.SetValue(True) temp.position = wx.Slider(temp, i, 512, 0, self.parent.project.resolution[i] - 1, wx.DefaultPosition, (200, -1), wx.SL_HORIZONTAL | wx.SL_LABELS) hbox.Add(temp.enable) hbox.Add(temp.position) temp.SetSizer(hbox) # multiple columns now: if i < self.parent.columns: poseEditSizer.Add(temp, (0, i), wx.GBSpan(1, 1), wx.TOP, 10) else: poseEditSizer.Add( temp, (i / self.parent.columns, i % self.parent.columns)) temp.Disable( ) # servo editors start out disabled, enabled only when a pose is selected self.servos.append(temp) # grid it editBox.Add(poseEditSizer) sizer.Add(editBox, (0, 0), wx.GBSpan(1, 1), wx.EXPAND) # list of poses self.posebox = wx.ListBox(self, self.ID_POSE_BOX, choices=self.parent.project.poses.keys()) sizer.Add(self.posebox, (0, 1), wx.GBSpan(1, 1), wx.EXPAND) # and add/remove hbox = wx.BoxSizer(wx.HORIZONTAL) hbox.Add(wx.Button(self, self.BT_POSE_ADD, 'add')) hbox.Add(wx.Button(self, self.BT_POSE_REM, 'remove')) hbox.Add(wx.Button(self, self.BT_POSE_RENAME, 'rename')) sizer.Add(hbox, (1, 1), wx.GBSpan(1, 1), wx.ALIGN_CENTER) # toolbar toolbar = wx.Panel(self, -1) toolbarsizer = wx.BoxSizer(wx.HORIZONTAL) # delta-T for interpolation self.deltaTButton = wx.Button(toolbar, self.BT_DELTA_T, 'delta-T') self.deltaTButton.Disable() toolbarsizer.Add(self.deltaTButton, 1) self.deltaT = 500 if port != None: self.deltaTButton.Enable() toolbarsizer.Add(wx.Button(toolbar, self.BT_RELAX, 'relax'), 1) toolbarsizer.Add(wx.Button(toolbar, self.BT_CAPTURE, 'capture'), 1) toolbarsizer.Add(wx.Button(toolbar, self.BT_SET, 'set'), 1) toolbar.SetSizer(toolbarsizer) sizer.Add(toolbar, (1, 0), wx.GBSpan(1, 1), wx.ALIGN_CENTER) self.Bind(wx.EVT_SLIDER, self.updatePose) self.Bind(wx.EVT_CHECKBOX, self.relaxServo) wx.EVT_BUTTON(self, self.BT_RELAX, self.parent.doRelax) wx.EVT_BUTTON(self, self.BT_CAPTURE, self.capturePose) wx.EVT_BUTTON(self, self.BT_SET, self.setPose) wx.EVT_BUTTON(self, self.BT_POSE_ADD, self.addPose) wx.EVT_BUTTON(self, self.BT_POSE_REM, self.remPose) wx.EVT_BUTTON(self, self.BT_POSE_RENAME, self.renamePose) wx.EVT_BUTTON(self, self.BT_DELTA_T, self.doDeltaT) wx.EVT_LISTBOX(self, self.ID_POSE_BOX, self.doPose) # key accelerators aTable = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('S'), self.BT_CAPTURE), # capture Servos (wx.ACCEL_CTRL, ord('R'), self.BT_RELAX), # Relax (wx.ACCEL_CTRL, ord('A'), self.BT_POSE_ADV), # Advance ]) self.SetAcceleratorTable(aTable) self.Bind(wx.EVT_MENU, self.capturePose, id=self.BT_CAPTURE) self.Bind(wx.EVT_MENU, self.parent.doRelax, id=self.BT_RELAX) self.Bind(wx.EVT_MENU, self.advancePose, id=self.BT_POSE_ADV) self.SetSizerAndFit(sizer)
def __init__(self,parent,id,name,image_dir,n_points=None,randomize=False,scale=1.0): wx.Frame.__init__(self,parent,id,name) # ---------------- Basic Data ------------------- self.image_dir = image_dir self.n_points = n_points self.image_names = [] self.current_image = None self.image_name = None self.scale = scale for name in os.listdir(image_dir): for format in IMAGE_FORMATS: if name.upper().endswith(format): self.image_names.append(name) if randomize: random.shuffle(self.image_names) self.filename = None self.coords = {} # ------------- Other Components ---------------- self.CreateStatusBar() # ------------------- Menu ---------------------- filemenu= wx.Menu() id_about = wx.NewId() id_open = wx.NewId() id_save = wx.NewId() id_save_as = wx.NewId() id_exit = wx.NewId() # File Menu filemenu.Append(wx.ID_ABOUT, wx.EmptyString) filemenu.AppendSeparator() filemenu.Append(wx.ID_OPEN, wx.EmptyString) filemenu.Append(wx.ID_SAVE, wx.EmptyString) filemenu.Append(wx.ID_SAVEAS, wx.EmptyString) filemenu.AppendSeparator() filemenu.Append(wx.ID_EXIT,wx.EmptyString) # Creating the menubar. menuBar = wx.MenuBar() menuBar.Append(filemenu,"&File") # Adding the "filemenu" to the MenuBar self.SetMenuBar(menuBar) # Adding the MenuBar to the Frame content. # ----------------- Image List ------------------ self.list=wx.ListBox(self,wx.NewId(),style=wx.LC_REPORT|wx.SUNKEN_BORDER,choices=self.image_names) self.list.Show(True) # --------------- Image Display ----------------- self.static_bitmap = wx.StaticBitmap(self,wx.NewId(), bitmap=wx.EmptyBitmap(300, 300)) self.static_bitmap.SetCursor(wx.CROSS_CURSOR) # --------------- Window Layout ----------------- box = wx.BoxSizer(wx.HORIZONTAL) box.Add(self.list, 1, wx.EXPAND) box.Add(self.static_bitmap, 3, wx.EXPAND) self.SetAutoLayout(True) self.SetSizer(box) self.Layout() # -------------- Event Handleing ---------------- wx.EVT_LISTBOX(self, self.list.GetId(), self.onSelect) wx.EVT_SIZE(self.static_bitmap, self.onBitmapResize) wx.EVT_LEFT_DOWN(self.static_bitmap, self.onClick) wx.EVT_LEFT_UP(self.static_bitmap, self.onRelease) wx.EVT_MOTION(self.static_bitmap, self.onMotion) self.moving = None wx.EVT_MENU(self,wx.ID_OPEN,self.onOpen) wx.EVT_MENU(self,wx.ID_SAVE,self.onSave) wx.EVT_MENU(self,wx.ID_SAVEAS,self.onSaveAs) wx.EVT_MENU(self,wx.ID_ABOUT,self.onAbout) #wx.EVT_MENU(self,wx.ID_EXIT,self.onExit) wx.EVT_CLOSE(self,self.onClose)