def __init__(self, parent, numRecords = 0): """ Create a Dialog Box to process the Database Conversion. Parameters: parent Parent Window numRecords The number of records that will be updated """ # Remember the total number of records passed in, or obtain that number if needed if numRecords == 0: self.numRecords = DBInterface.CountItemsWithoutPlainText() else: self.numRecords = numRecords # Create a Dialog Box wx.Dialog.__init__(self, parent, -1, _("Plain Text Conversion"), size=(600, 350)) # Add the Main Sizer mainSizer = wx.BoxSizer(wx.VERTICAL) # Add a gauge based on the number of records to be handled self.gauge = wx.Gauge(self, -1, numRecords) mainSizer.Add(self.gauge, 0, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 5) # Add a TextCtrl to provide user information self.txtCtrl = wx.TextCtrl(self, -1, "", style=wx.TE_LEFT | wx.TE_MULTILINE) mainSizer.Add(self.txtCtrl, 1, wx.EXPAND | wx.ALL, 5) # Add a hidden RichTextCrtl used for the conversion process self.richTextCtrl = TranscriptEditor_RTC.TranscriptEditor(self) self.richTextCtrl.SetReadOnly(True) self.richTextCtrl.Enable(False) # The user doesn't need to see this. self.richTextCtrl.Show(False) # Even though we add it to the sizer, it won't show up because of the Show(False). mainSizer.Add(self.richTextCtrl, 1, wx.EXPAND | wx.ALL, 5) # Finalize the Dialog layout self.SetSizer(mainSizer) self.SetAutoLayout(True) self.Layout() # Center the Dialog on the Screen TransanaGlobal.CenterOnPrimary(self)
def __init__(self, parent, id, title, quote_object, mergeList=None): # If no Merge List is passed in ... if mergeList == None: # ... use the default Quote Properties Dialog size passed in from the config object. (This does NOT get saved.) size = TransanaGlobal.configData.quotePropertiesSize # ... we can enable Quote Change Propagation propagateEnabled = True HelpContext = 'Quote Properties' # If we DO have a merge list ... else: # ... increase the size of the dialog to allow for the list of mergeable quotes. size = (TransanaGlobal.configData.quotePropertiesSize[0], TransanaGlobal.configData.quotePropertiesSize[1] + 130) # ... and Quote Change Propagation should be disabled propagateEnabled = False HelpContext = 'Quote 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 Quote Object passed in self.obj = quote_object # Add a placeholder to the quote object for the merge quote 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 Quote 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 Quotes ... if self.mergeList != None: # ... display a label for the Merge Quotes ... lblMergeQuote = wx.StaticText(self.panel, -1, _("Quote to Merge")) mainSizer.Add(lblMergeQuote, 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 Quotes ... self.mergeQuotes = 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.mergeQuotes, 1, wx.EXPAND) # ... bind the Item Selected event for the List Control ... self.mergeQuotes.Bind(wx.EVT_LIST_ITEM_SELECTED, self.OnItemSelected) # ... define the columns for the Merge Quotes ... self.mergeQuotes.InsertColumn(0, _('Quote Name')) self.mergeQuotes.InsertColumn(1, _('Collection')) self.mergeQuotes.InsertColumn(2, _('Start Character')) self.mergeQuotes.InsertColumn(3, _('End Character')) self.mergeQuotes.SetColumnWidth(0, 244) self.mergeQuotes.SetColumnWidth(1, 244) # ... and populate the Merge Quotes list from the mergeList data for (QuoteNum, QuoteID, DocumentNum, CollectNum, CollectID, StartChar, EndChar) in self.mergeList: index = self.mergeQuotes.InsertStringItem(sys.maxint, QuoteID) self.mergeQuotes.SetStringItem(index, 1, CollectID) self.mergeQuotes.SetStringItem(index, 2, u"%s" % StartChar) self.mergeQuotes.SetStringItem(index, 3, u"%s" % EndChar) # 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) # Quote ID self.id_edit = self.new_edit_box(_("Quote 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) # If the source document is known ... if self.obj.source_document_num > 0: try: tmpSrcDoc = Document.Document(num=self.obj.source_document_num) srcDocID = tmpSrcDoc.id tmpLibrary = Library.Library(tmpSrcDoc.library_num) libraryID = tmpLibrary.id except TransanaExceptions.RecordNotFoundError: srcDocID = '' libraryID = '' self.obj.source_document_id = 0 except: print print sys.exc_info()[0] print sys.exc_info()[1] self.obj.source_document_id = 0 srcDocID = '' libraryID = '' else: srcDocID = '' libraryID = '' # Create a VERTICAL sizer for the next element v3 = wx.BoxSizer(wx.VERTICAL) # Library ID library_edit = self.new_edit_box(_("Library ID"), v3, libraryID) # Add the element to the sizer r2Sizer.Add(v3, 1, wx.EXPAND) library_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) # Document ID document_edit = self.new_edit_box(_("Document ID"), v4, srcDocID) # Add the element to the sizer r2Sizer.Add(v4, 1, wx.EXPAND) document_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)) # 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) # Quote Start Character self.quote_start_edit = self.new_edit_box(_("Quote Start Character"), v5, unicode(self.obj.start_char)) # Add the element to the sizer r4Sizer.Add(v5, 1, wx.EXPAND) # For merging, we need to remember the merged value of Quote Start Char self.start_char = self.obj.start_char self.quote_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) # Quote End Character self.quote_end_edit = self.new_edit_box(_("Quote End Character"), v6, unicode(self.obj.end_char)) # Add the element to the sizer r4Sizer.Add(v6, 1, wx.EXPAND) # For merging, we need to remember the merged value of Quote End Char self.end_char = self.obj.end_char self.quote_end_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) # Quote Length self.quote_length_edit = self.new_edit_box( _("Quote Length"), v7, unicode(self.obj.end_char - self.obj.start_char)) # Add the element to the sizer r4Sizer.Add(v7, 1, wx.EXPAND) self.quote_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)) txt = wx.StaticText(self.panel, -1, _("Quote Text")) mainSizer.Add(txt, 0, wx.BOTTOM, 3) self.text_edit = TranscriptEditor_RTC.TranscriptEditor(self.panel) self.text_edit.load_transcript(self.obj) self.text_edit.SetReadOnly(False) self.text_edit.Enable(True) mainSizer.Add(self.text_edit, 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) 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) # Quote Keywords [label] txt = wx.StaticText(self.panel, -1, _("Quote Keywords")) v12.Add(txt, 0, wx.BOTTOM, 3) # Quote 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 Quotes 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)) # 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 Quote Keywords ListBox # If the quote object has keywords ... for quoteKeyword in self.obj.keyword_list: # ... add them to the keyword list self.ekw_lb.Append(quoteKeyword.keywordPair) # Set initial focus to the Quote ID self.id_edit.SetFocus()
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) # Series ID series_edit = self.new_edit_box(_("Series 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 self.CenterOnScreen() # 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=-1, includeClose=False, showLineNumbers=False): # Remember the parent self.parent = parent # If we're including an optional Close button ... if includeClose: # ... define a style that includes the Close Box. (System_Menu is required for Close to show on Windows in wxPython.) style = wx.CAPTION | wx.RESIZE_BORDER | wx.WANTS_CHARS | wx.SYSTEM_MENU | wx.CLOSE_BOX # If we don't need the close box ... else: # ... then we don't need that defined in the style style = wx.CAPTION | wx.RESIZE_BORDER | wx.WANTS_CHARS # Remember whether we're including line numbers self.showLineNumbers = showLineNumbers # Create the Frame with the appropriate style wx.Frame.__init__(self, parent, id, _("Transcript"), self.__pos(), self.__size(), style=style) # wx.MDIChildFrame.__init__(self, parent, id, _("Transcript"), self.__pos(), self.__size(), style=style) # if we're not on Linux ... if not 'wxGTK' in wx.PlatformInfo: # Set the Background Colour to the standard system background (not sure why this is necessary here.) self.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_FRAMEBK)) else: self.SetBackgroundColour(wx.WHITE) # Set "Window Variant" to small only for Mac to use small icons if "__WXMAC__" in wx.PlatformInfo: self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL) # The ControlObject handles all inter-object communication, initialized to None self.ControlObject = None # Initialize the Transcript Window Number to -1 self.transcriptWindowNumber = -1 # add the widgets to the panel sizer = wx.BoxSizer(wx.VERTICAL) # Define the Transcript Toolbar object self.toolbar = TranscriptToolbar(self) # Set this as the Frame's Toolbar. (Skipping this means toggle images disappear on OS X!) self.SetToolBar(self.toolbar) # Call toolbar.Realize() to initialize the toolbar self.toolbar.Realize() # Adding the Toolbar changes the Window Size on Mac! if 'wxMac' in wx.PlatformInfo: # Better reset the size! self.SetSize(self.__size()) # If the Format Panel is enabled ... if SHOWFORMATTINGPANEL: # ... add the Format Panel self.formatPanel = FormatPanel(self, -1, size=(500, 28)) sizer.Add(self.formatPanel, 0, wx.EXPAND) # Add a blank Bitmap for creating Line Numbers self.lineNumBmp = wx.EmptyBitmap(100, 100) # Create a horizontal Sizer to hold the Line Numbers and the Edit Control hsizer2 = wx.BoxSizer(wx.HORIZONTAL) # Create a Panel to hold Line Numbers self.lineNum = wx.Panel(self, -1, style=wx.BORDER_DOUBLE) # Set the background color for the Line Numbers panel to a pale gray self.lineNum.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE)) # Set the minimum and maximum width of the Line Number Panel to fix its size self.lineNum.SetSizeHints(minW=50, minH=0, maxW=50) # Add the Line Number Panel to the Horizontal Sizer hsizer2.Add(self.lineNum, 0, wx.EXPAND | wx.TOP | wx.LEFT | wx.BOTTOM, 3) # Bind the PAINT event used to display line numbers self.lineNum.Bind(wx.EVT_PAINT, self.LineNumPaint) self.lineNum.Show(self.showLineNumbers) # Create the Rich Text Edit Control itself, using Transana's TranscriptEditor object self.editor = TranscriptEditor_RTC.TranscriptEditor( self, id, self.toolbar.OnStyleChange, updateSelectionText=True) # Place the editor on the horizontal sizer hsizer2.Add(self.editor, 1, wx.EXPAND | wx.ALL, 3) self.redraw = False # Create a timer to update the Line Numbers self.LineNumTimer = wx.Timer() # Bind the method to the Timer event self.LineNumTimer.Bind(wx.EVT_TIMER, self.OnTimer) # EditorPaint) # Disable the Search components initially self.EnableSearch(False) # Put the horizontal sizer in the main vertical sizer sizer.Add(hsizer2, 1, wx.EXPAND) if "__WXMAC__" in wx.PlatformInfo: # This adds a space at the bottom of the frame on Mac, so that the scroll bar will get the down-scroll arrow. sizer.Add((0, 15)) # Finish the Size implementation self.SetSizer(sizer) self.SetAutoLayout(True) self.Layout() # Set the focus in the Editor self.editor.SetFocus() # Call Line Number Paint just once so the screen looks right self.EditorPaint(None) # Capture Size Changes wx.EVT_SIZE(self, self.OnSize) wx.EVT_IDLE(self, self.OnIdle) ## # If we're on Windows ... ## if 'wxMSW' in wx.PlatformInfo: ## ## # Create a timer to update the GDI Resource label ## self.GDITimer = wx.Timer() ## # Bind the method to the Timer event ## self.GDITimer.Bind(wx.EVT_TIMER, self.OnGDITimer) ## # update the GDI Resources label every few seconds ## self.GDITimer.Start(5000) try: # Define the Activate event (for setting the active window) self.Bind(wx.EVT_ACTIVATE, self.OnActivate) # Define the Close event (for THIS Transcript Window) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow) except: import sys print "TranscriptionUI._TranscriptDialog.__init__():" print sys.exc_info()[0] print sys.exc_info()[1] print if DEBUG: print "TranscriptionUI_RTC._TranscriptDialog.__init__(): Initial size:", self.GetSize( )
def __init__(self, parent, id=-1, title="", displayMethod=None, filterMethod=None, helpContext=None): """ Initialize the report framework. Parameters are: parent The report frame's parent id=-1 The report frame's ID title="" The report title displayMethod=None The method in the parent object that implements populating the report. (If left off, the report cannot function!) filterMethod=None The method in the parent object that implements the Filter Dialog call. (If left off, no Filter option will be displayed.) helpContext=None The Transana Help Context text for context-sensitive Help. (If left off, no Help option will be displayed.) """ # It's always important to remember your ancestors. (And the passed parameters!) self.parent = parent self.title = title # This instance of the TranscriptEditor object does NOT appear in a TranscriptionUI_RTC window # with Notebook Pages and Splitter Panes. We give it an ActivePanel here so avoid problems # when the report is clicked on. # self.ActivePanel = 0 self.reportNumber = 0 self.helpContext = helpContext self.displayMethod = displayMethod self.filterMethod = filterMethod # Default the Control Object to None self.ControlObject = None # Determine the screen size for setting the initial dialog size rect = wx.Display(TransanaGlobal.configData.primaryScreen ).GetClientArea() # wx.ClientDisplayRect() width = rect[2] * .80 height = rect[3] * .80 # Create the basic Frame structure with a white background wx.Frame.__init__(self, parent, id, title, size=wx.Size(width, height), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL | wx.NO_FULL_REPAINT_ON_RESIZE) self.SetBackgroundColour(wx.WHITE) # Set the report's icon transanaIcon = wx.Icon( os.path.join(TransanaGlobal.programDir, "images", "Transana.ico"), wx.BITMAP_TYPE_ICO) self.SetIcon(transanaIcon) # You can't have a separate menu on the Mac, so we'll use a Toolbar self.toolBar = self.CreateToolBar(wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_TEXT) # If a Filter Method is defined ... if self.filterMethod != None: # ... and create a Filter button on the tool bar. self.toolBar.AddTool(T_FILE_FILTER, TransanaImages.ArtProv_LISTVIEW.GetBitmap(), shortHelpString=_("Filter")) # Add an Edit button to the Toolbar self.toolBar.AddTool(T_FILE_EDIT, TransanaImages.ReadOnly16.GetBitmap(), isToggle=True, shortHelpString=_('Edit/Read-only select')) # ... and create a Format button on the tool bar. self.toolBar.AddTool(T_FILE_FONT, TransanaImages.ArtProv_HELPSETTINGS.GetBitmap(), shortHelpString=_("Format")) # Disable the Font button self.toolBar.EnableTool(T_FILE_FONT, False) # Add a Save button to the Toolbar self.toolBar.AddTool(T_FILE_SAVEAS, TransanaImages.Save16.GetBitmap(), shortHelpString=_('Save As')) # Disable Save for Right-To-Left languages if (TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft ): self.toolBar.EnableTool(T_FILE_SAVEAS, False) # Add a Print (page) Setup button to the toolbar self.toolBar.AddTool(T_FILE_PRINTSETUP, TransanaImages.PrintSetup.GetBitmap(), shortHelpString=_('Set up Page')) # Disable Print Setup for Right-To-Left languages if (TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft ): self.toolBar.EnableTool(T_FILE_PRINTSETUP, False) # Add a Print Preview button to the Toolbar self.toolBar.AddTool(T_FILE_PRINTPREVIEW, TransanaImages.PrintPreview.GetBitmap(), shortHelpString=_('Print Preview')) # Disable Print Preview on the PPC Mac and for Right-To-Left languages if (platform.processor() == 'powerpc') or (TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft): self.toolBar.EnableTool(T_FILE_PRINTPREVIEW, False) # Add a Print button to the Toolbar self.toolBar.AddTool(T_FILE_PRINT, TransanaImages.Print.GetBitmap(), shortHelpString=_('Print')) # Disable Print Setup for Right-To-Left languages if (TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft ): self.toolBar.EnableTool(T_FILE_PRINT, False) # If a help context is defined ... if self.helpContext != None: # ... and create a bitmap button for the Help button self.toolBar.AddTool(T_HELP_HELP, TransanaImages.ArtProv_HELP.GetBitmap(), shortHelpString=_("Help")) # Add an Exit button to the Toolbar self.toolBar.AddTool(T_FILE_EXIT, TransanaImages.Exit.GetBitmap(), shortHelpString=_('Exit')) # Add a toolbar separator self.toolBar.AddSeparator() # Add the Search Backwards button self.toolBar.AddTool(T_SEARCH_BACK, TransanaImages.ArtProv_BACK.GetBitmap(), shortHelpString=_('Search backwards')) # Create a text box for search terms, with the toolbar as its parent. self.searchText = wx.TextCtrl(self.toolBar, -1, size=(100, 20), style=wx.TE_PROCESS_ENTER) # Add the text box to the toolbar. self.toolBar.AddControl(self.searchText) # Add the Search Forwards button self.toolBar.AddTool(T_SEARCH_FORWARD, TransanaImages.ArtProv_FORWARD.GetBitmap(), shortHelpString=_('Search forwards')) # Actually create the Toolbar self.toolBar.Realize() # Let's go ahead and keep the menu for non-Mac platforms if not '__WXMAC__' in wx.PlatformInfo: # Add a Menu Bar menuBar = wx.MenuBar() # Create the File Menu self.menuFile = wx.Menu() # If a Filter Method is defined ... if self.filterMethod != None: # ... add a Filter item to the File menu self.menuFile.Append(M_FILE_FILTER, _("&Filter"), _("Filter report contents")) # Add "Edit" to the File Menu self.menuFile.Append(M_FILE_EDIT, _("&Edit"), _("Edit the report manually")) # Add "Font" to the File Menu self.menuFile.Append(M_FILE_FONT, _("Format"), _("Change the current formatting")) # Disable the Font Menu Option self.menuFile.Enable(M_FILE_FONT, False) # Add "Save As" to File Menu self.menuFile.Append(M_FILE_SAVEAS, _("Save &As"), _("Save As")) # If we have Right to Left text, we cannot enable PRINT because it doesn't work right due to wxWidgets bugs. if TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft: self.menuFile.Enable(M_FILE_SAVEAS, False) # Add "Page Setup" to the File Menu self.menuFile.Append(M_FILE_PRINTSETUP, _("Page Setup"), _("Set up Page")) # If we have Right to Left text, we cannot enable PRINT because it doesn't work right due to wxWidgets bugs. if TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft: self.menuFile.Enable(M_FILE_PRINTSETUP, False) # Add "Print Preview" to the File Menu self.menuFile.Append(M_FILE_PRINTPREVIEW, _("Print Preview"), _("Preview your printed output")) # If we have Right to Left text, we cannot enable PRINT because it doesn't work right due to wxWidgets bugs. if TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft: self.menuFile.Enable(M_FILE_PRINTPREVIEW, False) # Add "Print" to the File Menu self.menuFile.Append(M_FILE_PRINT, _("&Print"), _("Send your output to the Printer")) # If we have Right to Left text, we cannot enable PRINT because it doesn't work right due to wxWidgets bugs. if TransanaGlobal.configData.LayoutDirection == wx.Layout_RightToLeft: self.menuFile.Enable(M_FILE_PRINT, False) # Add "Exit" to the File Menu self.menuFile.Append(M_FILE_EXIT, _("E&xit"), _("Exit the Keyword Map program")) # Add the File Menu to the Menu Bar menuBar.Append(self.menuFile, _('&File')) # If a Help Context is defined ... if self.helpContext != None: # ... create a Help menu ... self.menuHelp = wx.Menu() # ... add a Help item to the Help menu ... self.menuHelp.Append(M_HELP_HELP, _("&Help"), _("Help")) # ... and add the Help menu to the menu bar menuBar.Append(self.menuHelp, _("&Help")) # Connect the Menu Bar to the Frame self.SetMenuBar(menuBar) # Link menu items and toolbar buttons to the appropriate methods if self.filterMethod != None: wx.EVT_MENU(self, M_FILE_FILTER, self.OnFilter) # Attach File > Filter to a method wx.EVT_MENU(self, T_FILE_FILTER, self.OnFilter) # Attach Toolbar Filter to a method wx.EVT_MENU(self, M_FILE_EDIT, self.OnEdit) # Attach OnEdit to File > Edit wx.EVT_MENU(self, T_FILE_EDIT, self.OnEdit) # Attach OnEdit to Toolbar Edit wx.EVT_MENU(self, M_FILE_FONT, self.OnFont) # Attach OnFont to File > Font wx.EVT_MENU(self, T_FILE_FONT, self.OnFont) # Attach OnFont to Toolbar Font button wx.EVT_MENU(self, M_FILE_SAVEAS, self.OnSaveAs) # Attach File > Save As to a method wx.EVT_MENU(self, T_FILE_SAVEAS, self.OnSaveAs) # Attach Toolbar Save As to a method wx.EVT_MENU(self, M_FILE_PRINTSETUP, self.OnPrintSetup) # Attach File > Print Setup to a method wx.EVT_MENU( self, T_FILE_PRINTSETUP, self.OnPrintSetup) # Attach Toolbar Print Setup to a method wx.EVT_MENU( self, M_FILE_PRINTPREVIEW, self.OnPrintPreview) # Attach File > Print Preview to a method wx.EVT_MENU( self, T_FILE_PRINTPREVIEW, self.OnPrintPreview) # Attach Toolbar Print Preview to a method wx.EVT_MENU(self, M_FILE_PRINT, self.OnPrint) # Attach File > Print to a method wx.EVT_MENU(self, T_FILE_PRINT, self.OnPrint) # Attach Toolbar Print to a method wx.EVT_MENU(self, M_FILE_EXIT, self.CloseWindow) # Attach CloseWindow to File > Exit wx.EVT_MENU(self, T_FILE_EXIT, self.CloseWindow) # Attach CloseWindow to Toolbar Exit wx.EVT_MENU( self, T_SEARCH_BACK, self.OnSearch) # Attach Toolbar Search Backwards to Search method wx.EVT_MENU( self, T_SEARCH_FORWARD, self.OnSearch) # Attach Toolbar Search Forwards to Search method self.searchText.Bind( wx.EVT_TEXT_ENTER, self.OnSearch) # Attach Search Box Enter event to Search method if self.helpContext != None: wx.EVT_MENU(self, M_HELP_HELP, self.OnHelp) # Attach OnHelp to Help > Help wx.EVT_MENU(self, T_HELP_HELP, self.OnHelp) # Attach OnHelp to Toolbar Help # Define the Window's Close event, so we can remove the window from the Transana Interface self.Bind(wx.EVT_CLOSE, self.OnClose) # Add a Status Bar self.CreateStatusBar() # If we're using the RTC if TransanaConstants.USESRTC: # Add a Rich Text Edit control to the Report Frame. This is where the actual report text goes. self.reportText = TranscriptEditor_RTC.TranscriptEditor(self) # Clear / initialize the document self.reportText.ClearDoc() ## # If we're using STC ## else: ## # Add a Styled Text Edit control to the Report Frame. This is where the actual report text goes. ## self.reportText = TranscriptEditor_STC.TranscriptEditor(self) ## # Set report margins, the left margin to 1 inch, the right margin to 0 to prevent premature word wrap. ## self.reportText.SetMargins(TranscriptPrintoutClass.DPI, 0) # We need to over-ride the reportText's EVT_RIGHT_UP method wx.EVT_RIGHT_UP(self.reportText, self.OnRightUp) # Initialize a variable to indicate whether a custom edit has occurred self.reportEdited = False # Get the global print data self.printData = TransanaGlobal.printData if parent == None: TransanaGlobal.CenterOnPrimary(self) # Show the Frame self.Show(True)