Esempio n. 1
0
    def __init__(self, parent, kw_groups):

        # ALSO SEE Keyword._set_keywordGroup().  The same errors are caught there.

        # Let's get a copy of kw_groups that's all upper case
        self.kw_groups_upper = []
        for kwg in kw_groups:
            self.kw_groups_upper.append(kwg.upper())

        # Define the default Window style
        dlgStyle = wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP | wx.DIALOG_NO_PARENT
        # Create a small dialog box
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           _("Add Keyword Group"),
                           size=(350, 145),
                           style=dlgStyle)
        # Create a main vertical sizer
        box = wx.BoxSizer(wx.VERTICAL)
        # Create a horizontal sizer for the buttons
        boxButtons = wx.BoxSizer(wx.HORIZONTAL)

        # Create a text screen object for the dialog text
        message = wx.StaticText(self, -1, _("New Keyword Group:"))
        # Add the first row to the main sizer
        box.Add(message, 0, wx.EXPAND | wx.ALL, 10)

        # Create a TextCtrl for the Keyword Group name
        self.kwGroup = wx.TextCtrl(self, -1, "")
        box.Add(self.kwGroup, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
                10)
        # Do error-checking in the EVT_TEXT event
        self.kwGroup.Bind(wx.EVT_TEXT, self.OnText)

        # Create the first button, which is OK
        btnOK = wx.Button(self, wx.ID_OK, _("OK"))
        # Set as the Default to handle ENTER keypress
        btnOK.SetDefault()
        # Bind the button event to its method
        btnOK.Bind(wx.EVT_BUTTON, self.OnButton)

        # Create the second button, which is Cancel
        btnCancel = wx.Button(self, wx.ID_CANCEL, _("Cancel"))
        # Add an expandable spacer to the button sizer
        boxButtons.Add((20, 1), 1)
        # If we're on the Mac, we want Cancel then OK
        if "__WXMAC__" in wx.PlatformInfo:
            # Add No first
            boxButtons.Add(btnCancel, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10)
            # Add a spacer
            boxButtons.Add((20, 1))
            # Then add Yes
            boxButtons.Add(btnOK, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10)
        # If we're not on the Mac, we want OK then Cancel
        else:
            # Add Yes first
            boxButtons.Add(btnOK, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10)
            # Add a spacer
            boxButtons.Add((20, 1))
            # Then add No
            boxButtons.Add(btnCancel, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10)
        # Add a final expandable spacer
        boxButtons.Add((20, 1), 1)
        # Add the button bar to the main sizer
        box.Add(boxButtons, 0, wx.ALIGN_RIGHT | wx.EXPAND)

        # Turn AutoLayout On
        self.SetAutoLayout(True)
        # Set the form's main sizer
        self.SetSizer(box)
        # Fit the form
        self.Fit()
        # Lay the form out
        self.Layout()
        # Center the form on screen
        #        self.CentreOnScreen()
        # That's not working.  Let's try this ...
        TransanaGlobal.CenterOnPrimary(self)
Esempio n. 2
0
    def __init__(self):
        """ Create and display the About Dialog Box """
        # Define the initial size
        if '__WXMAC__' in wx.PlatformInfo:
            width = 400
        else:
            width = 370
        height = 425

        # Create the form's main VERTICAL sizer
        mainSizer = wx.BoxSizer(wx.VERTICAL)

        # Create a Dialog Box
        wx.Dialog.__init__(self,
                           None,
                           -1,
                           _("About Transana"),
                           size=(width, height),
                           style=wx.CAPTION | wx.WANTS_CHARS)
        # OS X requires the Small Window Variant to look right
        if "__WXMAC__" in wx.PlatformInfo:
            self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
        # Create a label for the Program Title
        title = wx.StaticText(self, -1, _("Transana"), style=wx.ALIGN_CENTRE)
        # Specify 16pt Bold font
        font = wx.Font(16, wx.SWISS, wx.NORMAL, wx.BOLD)
        # Apply this font to the Title
        title.SetFont(font)
        # Add the title to the main sizer
        mainSizer.Add(
            title, 0,
            wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM | wx.LEFT | wx.RIGHT, 12)

        # Create a label for the Program Version
        # Build the Version label
        if TransanaConstants.singleUserVersion:
            if TransanaConstants.labVersion:
                versionLbl = _("Computer Lab Version")
            elif TransanaConstants.demoVersion:
                versionLbl = _("Demonstration Version")
            elif TransanaConstants.workshopVersion:
                versionLbl = _("Workshop Version")
            else:
                if TransanaConstants.proVersion:
                    versionLbl = _("Professional Version")
                else:
                    versionLbl = _("Standard Version")
        else:
            versionLbl = _("Multi-user Version")
        versionLbl += " %s"
        version = wx.StaticText(self,
                                -1,
                                versionLbl % TransanaConstants.versionNumber,
                                style=wx.ALIGN_CENTRE)
        # Specify 10pt Bold font
        font = wx.Font(10, wx.SWISS, wx.NORMAL, wx.BOLD)
        # Apply the font to the Version Label
        version.SetFont(font)
        # Add the version to the main sizer
        mainSizer.Add(version, 0,
                      wx.ALIGN_CENTER | wx.BOTTOM | wx.LEFT | wx.RIGHT, 12)

        # Create a label for the Program Copyright
        str = _(
            "Copyright 2002-2014\nThe Board of Regents of the University of Wisconsin System"
        )
        copyright = wx.StaticText(self, -1, str, style=wx.ALIGN_CENTRE)
        # Apply the last specified font (from Program Version) to the copyright label
        font = self.GetFont()
        copyright.SetFont(font)
        # Add the copyright to the main sizer
        mainSizer.Add(copyright, 0,
                      wx.ALIGN_CENTER | wx.BOTTOM | wx.LEFT | wx.RIGHT, 12)

        # Create a label for the Program Description, including GNU License information
        self.description_str = _(
            "Transana is written at the \nWisconsin Center for Education Research, \nUniversity of Wisconsin, Madison, and is released with \nno warranty under the GNU General Public License (GPL).  \nFor more information, see http://www.gnu.org."
        )
        self.description = wx.StaticText(self,
                                         -1,
                                         self.description_str,
                                         style=wx.ALIGN_CENTRE)
        # Add the description to the main sizer
        mainSizer.Add(self.description, 0,
                      wx.ALIGN_CENTER | wx.BOTTOM | wx.LEFT | wx.RIGHT, 12)

        # Create a label for the Program Authoring Credits
        self.credits_str = _(
            "Transana was originally conceived and written by Chris Fassnacht.\nCurrent development is being directed by David K. Woods, Ph.D.\nOther contributors include:  Jonathan Beavers, Nate Case, Mark Kim, \nRajas Sambhare and David Mandelin"
        )
        self.credits_str += ".\n" + _(
            "Methodology consultants: Paul Dempster, Chris Thorn,\nand Nicolas Sheon."
        )
        self.credits = wx.StaticText(self,
                                     -1,
                                     self.credits_str,
                                     style=wx.ALIGN_CENTRE)
        # Add the credits to the main sizer
        mainSizer.Add(self.credits, 0,
                      wx.ALIGN_CENTER | wx.BOTTOM | wx.LEFT | wx.RIGHT, 12)

        # Create a label for the Translation Credits
        if TransanaGlobal.configData.language == 'en':
            str = 'Documentation written by David K. Woods\nwith assistance and editing by Becky Holmes.'
        elif TransanaGlobal.configData.language == 'ar':
            str = _("Arabic translation provided by\n.")
        elif TransanaGlobal.configData.language == 'da':
            str = _(
                "Danish translation provided by\nChris Kjeldsen, Aalborg University."
            )
        elif TransanaGlobal.configData.language == 'de':
            str = _(
                "German translation provided by Tobias Reu, New York University.\n."
            )
        elif TransanaGlobal.configData.language == 'el':
            str = _("Greek translation provided by\n.")
        elif TransanaGlobal.configData.language == 'es':
            str = _(
                "Spanish translation provided by\nNate Case, UW Madison, and Paco Molinero, Barcelone, Spain"
            )
        elif TransanaGlobal.configData.language == 'fi':
            str = _(
                "Finnish translation provided by\nMiia Collanus, University of Helsinki, Finland"
            )
        elif TransanaGlobal.configData.language == 'fr':
            str = _(
                "French translation provided by\nDr. Margot Kaszap, Ph. D., Universite Laval, Quebec, Canada."
            )
        elif TransanaGlobal.configData.language == 'he':
            str = _("Hebrew translation provided by\n.")
        elif TransanaGlobal.configData.language == 'it':
            str = _(
                "Italian translation provided by\nFabio Malfatti, Centro Ricerche EtnoAntropologiche www.creasiena.it\nPeri Weingrad, University of Michigan & Terenziano Speranza, Rome, Italy\nDorian Soru, Ph. D. e ICLab, www.iclab.eu, Padova, Italia"
            )
        elif TransanaGlobal.configData.language == 'nl':
            str = _("Dutch translation provided by\nFleur van der Houwen.")
        elif TransanaGlobal.configData.language in ['nb', 'nn']:
            str = _(
                "Norwegian translations provided by\nDr. Dan Yngve Jacobsen, Department of Psychology,\nNorwegian University of Science and Technology, Trondheim"
            )
        elif TransanaGlobal.configData.language == 'pl':
            str = _("Polish translation provided by\n.")
        elif TransanaGlobal.configData.language == 'pt':
            str = _("Portuguese translation provided by\n.")
        elif TransanaGlobal.configData.language == 'ru':
            str = _("Russian translation provided by\nViktor Ignatjev.")
        elif TransanaGlobal.configData.language == 'sv':
            str = _(
                "Swedish translation provided by\nJohan Gille, Stockholm University, Sweden"
            )
        elif TransanaGlobal.configData.language == 'zh':
            str = _(
                "Chinese translation provided by\nZhong Hongquan, Beijin Poweron Technology Co.Ltd.,\nmaintained by Bei Zhang, University of Wisconsin."
            )
        self.translations_str = str
        self.translations = wx.StaticText(self,
                                          -1,
                                          self.translations_str,
                                          style=wx.ALIGN_CENTRE)
        # Add the transcription credit to the main sizer
        mainSizer.Add(self.translations, 0,
                      wx.ALIGN_CENTER | wx.BOTTOM | wx.LEFT | wx.RIGHT, 12)

        # Create a label for the FFmpeg Credits
        self.ffmpeg_str = _(
            "This software uses libraries from the FFmpeg project\nunder the LGPLv2.1 or GNU-GPL.  Transana's copyright\ndoes not extend to the FFmpeg libraries or code.\nPlease see http://www.ffmpeg.com."
        )
        self.ffmpeg = wx.StaticText(self,
                                    -1,
                                    self.ffmpeg_str,
                                    style=wx.ALIGN_CENTRE)
        # Add the FFmpeg Credits to the main sizer
        mainSizer.Add(self.ffmpeg, 0,
                      wx.ALIGN_CENTER | wx.BOTTOM | wx.LEFT | wx.RIGHT, 12)

        # Create an OK button
        btnOK = wx.Button(self, wx.ID_OK, _("OK"))
        # Add the OK button to the main sizer
        mainSizer.Add(btnOK, 0,
                      wx.ALIGN_CENTER | wx.BOTTOM | wx.LEFT | wx.RIGHT, 12)

        # Add the Keyboard Event for the Easter Egg screen
        self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
        btnOK.Bind(wx.EVT_KEY_UP, self.OnKeyUp)

        # Define the form's Sizer
        self.SetSizer(mainSizer)
        # Lay out the form
        self.SetAutoLayout(True)
        self.Layout()
        # Fit the form to the contained controls
        self.Fit()
        # Center on screen
        #	self.CentreOnScreen()
        TransanaGlobal.CenterOnPrimary(self)

        # Show the About Dialog Box modally
        val = self.ShowModal()

        # Destroy the Dialog Box when done with it
        self.Destroy()

        # Dialog Box Initialization returns "None" as the result (see wxPython documentation)
        return None
Esempio n. 3
0
    def __init__(self, parent, id, title, transcript_object):
        """ Create the Transcript Properties form """
        self.width = 500
        self.height = 260
        # Make the Keyword Edit List resizable by passing wx.RESIZE_BORDER style
        Dialogs.GenForm.__init__(self,
                                 parent,
                                 id,
                                 title,
                                 size=(self.width, self.height),
                                 style=wx.DEFAULT_DIALOG_STYLE
                                 | wx.RESIZE_BORDER,
                                 useSizers=True,
                                 HelpContext='Transcript Properties')

        # Define the form's main object
        self.obj = transcript_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)
        # Add the Transcript ID element
        self.id_edit = self.new_edit_box(_("Transcript 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)
        # Add the Library ID element
        series_id_edit = self.new_edit_box(_("Library ID"), v2,
                                           self.obj.series_id)
        # Add the element to the row sizer
        r2Sizer.Add(v2, 1, wx.EXPAND)
        # Disable Library ID
        series_id_edit.Enable(False)

        # Add a horizontal spacer to the row sizer
        r2Sizer.Add((10, 0))

        # Create a VERTICAL sizer for the next element
        v3 = wx.BoxSizer(wx.VERTICAL)
        # Add the Episode ID element
        episode_id_edit = self.new_edit_box(_("Episode ID"), v3,
                                            self.obj.episode_id)
        # Add the element to the row sizer
        r2Sizer.Add(v3, 1, wx.EXPAND)
        # Disable Episode ID
        episode_id_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
        r3Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Create a VERTICAL sizer for the next element
        v4 = wx.BoxSizer(wx.VERTICAL)
        # Add the Transcriber element
        transcriber_edit = self.new_edit_box(_("Transcriber"),
                                             v4,
                                             self.obj.transcriber,
                                             maxLen=100)
        # Add the element to the row sizer
        r3Sizer.Add(v4, 3, wx.EXPAND | wx.RIGHT, 10)

        # Create a VERTICAL sizer for the next element
        v7 = wx.BoxSizer(wx.VERTICAL)
        # Add the Min Transcript Width element
        mintranscriptwidth = self.new_edit_box(
            _("Min. Width"), v7, str(self.obj.minTranscriptWidth))
        # Add the element to the row sizer
        r3Sizer.Add(v7, 1, wx.EXPAND)

        # 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)
        # Add the Comment element
        comment_edit = self.new_edit_box(_("Comment"),
                                         v5,
                                         self.obj.comment,
                                         maxLen=255)
        # Add the element to the row 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)
        # Add the Import File element
        self.rtfname_edit = self.new_edit_box(
            _("RTF/XML/TXT File to import  (optional)"), v6, '')
        # Make this text box a File Drop Target
        self.rtfname_edit.SetDropTarget(
            EditBoxFileDropTarget(self.rtfname_edit))
        # Add the element to the row sizer
        r5Sizer.Add(v6, 1, wx.EXPAND)

        # Add a horizontal spacer to the row sizer
        r5Sizer.Add((10, 0))

        # Add the Browse Button
        browse = wx.Button(self.panel, -1, _("Browse"))
        # Add the Browse Method to the Browse Button
        wx.EVT_BUTTON(self, browse.GetId(), self.OnBrowseClick)
        # Add the element to the sizer
        r5Sizer.Add(browse, 0, wx.ALIGN_BOTTOM)
        # If Mac ...
        if 'wxMac' in wx.PlatformInfo:
            # ... add a spacer to avoid control clipping
            r5Sizer.Add((2, 0))

        # 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 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(self.width, width), height))
        # Define the minimum size for this dialog as the current size, and define height as unchangeable
        self.SetSizeHints(max(self.width, width), height, -1, height)
        # Center the form on screen
        TransanaGlobal.CenterOnPrimary(self)
        # Set focus to the Transcript ID
        self.id_edit.SetFocus()
Esempio n. 4
0
    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()
Esempio n. 5
0
    def __init__(self, parent, id, title, coredata_object):
        """ Initialize the Core Data Properties form """
        # Set the Size of the Form
        self.width = 550
        self.height = 510
        # Create the Base Form, based on GenForm in the Transana Dialogs module
        Dialogs.GenForm.__init__(self,
                                 parent,
                                 id,
                                 title,
                                 size=(self.width, self.height),
                                 style=wx.DEFAULT_DIALOG_STYLE
                                 | wx.RESIZE_BORDER,
                                 useSizers=True,
                                 HelpContext='Core Data Properties')

        # Preserve the initial Core Data Object sent in from the calling routine
        self.obj = coredata_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)
        # Media File Name
        # NOTE:  The otherwise unused Comment Field is used to contain the full Media File Name.
        media_filename_edit = self.new_edit_box(_("Media File Name"), v1,
                                                self.obj.comment)
        # Add the element to the row sizer
        r1Sizer.Add(v1, 1, wx.EXPAND)
        # Media File Name Field is not editable
        media_filename_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 first row
        r2Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Create a VERTICAL sizer for the next element
        v2 = wx.BoxSizer(wx.VERTICAL)
        # Title
        title_edit = self.new_edit_box(_("Title"),
                                       v2,
                                       self.obj.title,
                                       maxLen=255)
        # Add the element to the row sizer
        r2Sizer.Add(v2, 1, wx.EXPAND)

        # 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 first row
        r3Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Create a VERTICAL sizer for the next element
        v3 = wx.BoxSizer(wx.VERTICAL)
        # Creator
        creator_edit = self.new_edit_box(_("Creator"),
                                         v3,
                                         self.obj.creator,
                                         maxLen=255)
        # Add the element to the row sizer
        r3Sizer.Add(v3, 1, wx.EXPAND)

        # 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)
        # Subject
        subject_edit = self.new_edit_box(_("Subject"),
                                         v4,
                                         self.obj.subject,
                                         maxLen=255)
        # Add the element to the row sizer
        r3Sizer.Add(v4, 1, wx.EXPAND)

        # 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 first row
        r4Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Create a VERTICAL sizer for the next element
        v5 = wx.BoxSizer(wx.VERTICAL)
        # Description
        self.description_edit = self.new_edit_box(_("Description"),
                                                  v5,
                                                  self.obj.description,
                                                  style=wx.TE_MULTILINE,
                                                  maxLen=255)
        # Add the element to the row sizer
        r4Sizer.Add(v5, 1, wx.EXPAND)

        # Add a spacer to enforce the height of the Description item
        r4Sizer.Add((0, 80))

        # Add the row sizer to the main vertical sizer
        mainSizer.Add(r4Sizer, 5, wx.EXPAND)

        # Add a vertical spacer to the main sizer
        mainSizer.Add((0, 10))

        # Create a HORIZONTAL sizer for the first row
        r5Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Create a VERTICAL sizer for the next element
        v6 = wx.BoxSizer(wx.VERTICAL)
        # Publisher
        publisher_edit = self.new_edit_box(_("Publisher"),
                                           v6,
                                           self.obj.publisher,
                                           maxLen=255)
        # Add the element to the row sizer
        r5Sizer.Add(v6, 1, wx.EXPAND)

        # Add a horizontal spacer to the row sizer
        r5Sizer.Add((10, 0))

        # Create a VERTICAL sizer for the next element
        v7 = wx.BoxSizer(wx.VERTICAL)
        # Contributor
        contributor_edit = self.new_edit_box(_("Contributor"),
                                             v7,
                                             self.obj.contributor,
                                             maxLen=255)
        # Add the element to the row sizer
        r5Sizer.Add(v7, 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 first row
        r6Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Create a VERTICAL sizer for the next element
        v8 = wx.BoxSizer(wx.VERTICAL)
        # Dialogs.GenForm does not provide a Masked text control, so the Date
        # Field is handled differently than other fields.

        # Date [label]
        date_lbl = wx.StaticText(self.panel, -1, _("Date (MM/DD/YYYY)"))
        # Add the element to the vertical sizer
        v8.Add(date_lbl, 0, wx.BOTTOM, 3)

        # Date layout
        # Use the Masked Text Control (Requires wxPython 2.4.2.4 or later)
        # TODO:  Make Date autoformat localizable
        self.date_edit = wx.lib.masked.TextCtrl(self.panel,
                                                -1,
                                                '',
                                                autoformat='USDATEMMDDYYYY/')
        # Add the element to the vertical sizer
        v8.Add(self.date_edit, 1, wx.EXPAND)
        # If a Date is know, load it into the control
        if (self.obj.dc_date != '') and (self.obj.dc_date != '01/01/0'):
            self.date_edit.SetValue(self.obj.dc_date)

        # Add the element to the row sizer
        r6Sizer.Add(v8, 1, wx.EXPAND)

        # Add a horizontal spacer to the row sizer
        r6Sizer.Add((10, 0))

        # Create a VERTICAL sizer for the next element
        v9 = wx.BoxSizer(wx.VERTICAL)
        # Type
        # Define legal options for the Combo Box
        options = ['', _('Image'), _('Sound')]
        self.type_combo = self.new_combo_box(_("Media Type"), v9, options,
                                             self.obj.dc_type)
        # Add the element to the row sizer
        r6Sizer.Add(v9, 1, wx.EXPAND)
        # Define a Combo Box Event.  When different Types are selected, different Format options should be displayed.
        wx.EVT_COMBOBOX(self, self.type_combo.GetId(), self.OnTypeChoice)

        # Add a horizontal spacer to the row sizer
        r6Sizer.Add((10, 0))

        # Create a VERTICAL sizer for the next element
        v10 = wx.BoxSizer(wx.VERTICAL)
        # Format
        # The Format Combo Box has different options depending on the value of Type
        if self.obj.dc_type == unicode(_('Image'), 'utf8'):
            options = imageOptions
        elif self.obj.dc_type == unicode(_('Sound'), 'utf8'):
            options = soundOptions
        else:
            options = allOptions
        self.format_combo = self.new_combo_box(_("Format"), v10, options,
                                               self.obj.format)
        # Add the element to the row sizer
        r6Sizer.Add(v10, 1, wx.EXPAND)

        # Add the row sizer to the main vertical sizer
        mainSizer.Add(r6Sizer, 0, wx.EXPAND)

        # Add a vertical spacer to the main sizer
        mainSizer.Add((0, 10))

        # Create a HORIZONTAL sizer for the first row
        r7Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Create a VERTICAL sizer for the next element
        v11 = wx.BoxSizer(wx.VERTICAL)
        # Identifier
        identifier_edit = self.new_edit_box(_("Identifier"), v11, self.obj.id)
        # Add the element to the row sizer
        r7Sizer.Add(v11, 1, wx.EXPAND)
        # Identifier is not editable
        identifier_edit.Enable(False)

        # Add a horizontal spacer to the row sizer
        r7Sizer.Add((10, 0))

        # Create a VERTICAL sizer for the next element
        v12 = wx.BoxSizer(wx.VERTICAL)
        # Source
        source_edit = self.new_edit_box(_("Source"),
                                        v12,
                                        self.obj.source,
                                        maxLen=255)
        # Add the element to the row sizer
        r7Sizer.Add(v12, 1, wx.EXPAND)

        # Add the row sizer to the main vertical sizer
        mainSizer.Add(r7Sizer, 0, wx.EXPAND)

        # Add a vertical spacer to the main sizer
        mainSizer.Add((0, 10))

        # Create a HORIZONTAL sizer for the first row
        r8Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Create a VERTICAL sizer for the next element
        v13 = wx.BoxSizer(wx.VERTICAL)
        # Language
        language_edit = self.new_edit_box(_("Language"),
                                          v13,
                                          self.obj.language,
                                          maxLen=25)
        # Add the element to the row sizer
        r8Sizer.Add(v13, 1, wx.EXPAND)

        # Add a horizontal spacer to the row sizer
        r8Sizer.Add((10, 0))

        # Create a VERTICAL sizer for the next element
        v14 = wx.BoxSizer(wx.VERTICAL)
        # Relation
        relation_edit = self.new_edit_box(_("Relation"),
                                          v14,
                                          self.obj.relation,
                                          maxLen=255)
        # Add the element to the row sizer
        r8Sizer.Add(v14, 1, wx.EXPAND)

        # Add the row sizer to the main vertical sizer
        mainSizer.Add(r8Sizer, 0, wx.EXPAND)

        # Add a vertical spacer to the main sizer
        mainSizer.Add((0, 10))

        # Create a HORIZONTAL sizer for the first row
        r9Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Create a VERTICAL sizer for the next element
        v15 = wx.BoxSizer(wx.VERTICAL)
        # Coverage
        coverage_edit = self.new_edit_box(_("Coverage"),
                                          v15,
                                          self.obj.coverage,
                                          maxLen=255)
        # Add the element to the row sizer
        r9Sizer.Add(v15, 1, wx.EXPAND)

        # Add a horizontal spacer to the row sizer
        r9Sizer.Add((10, 0))

        # Create a VERTICAL sizer for the next element
        v16 = wx.BoxSizer(wx.VERTICAL)
        # Rights
        rights_edit = self.new_edit_box(_("Rights"),
                                        v16,
                                        self.obj.rights,
                                        maxLen=255)
        # Add the element to the row sizer
        r9Sizer.Add(v16, 1, wx.EXPAND)

        # Add the row sizer to the main vertical sizer
        mainSizer.Add(r9Sizer, 0, 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(self.width, width), height))
        # Define the minimum size for this dialog as the current size
        self.SetSizeHints(max(self.width, width), height)
        # Center the form on screen
        TransanaGlobal.CenterOnPrimary(self)

        # Set focus to Title
        title_edit.SetFocus()
Esempio n. 6
0
    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)
Esempio n. 7
0
    def __init__(self, parent, id, title, keyword_object):
        self.width = 450
        self.height = 400
        # Make the Keyword Edit List resizable by passing wx.RESIZE_BORDER style
        Dialogs.GenForm.__init__(self,
                                 parent,
                                 id,
                                 title,
                                 size=(self.width, self.height),
                                 style=wx.DEFAULT_DIALOG_STYLE
                                 | wx.RESIZE_BORDER,
                                 useSizers=True,
                                 HelpContext='Keyword Properties')

        self.obj = keyword_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)
        # Keyword Group
        self.kwg_choice = self.new_combo_box(_("Keyword Group"), v1, [""])
        # Add the element to the sizer
        r1Sizer.Add(v1, 1, wx.EXPAND)

        # Add a horizontal spacer to the row sizer
        r1Sizer.Add((10, 0))

        # wxComboBox doesn't have a Max Length method.  Let's emulate one here using the Combo Box's EVT_TEXT method
        self.kwg_choice.Bind(wx.EVT_TEXT, self.OnKWGText)

        # Create a VERTICAL sizer for the next element
        v2 = wx.BoxSizer(wx.VERTICAL)
        # Keyword
        keyword_edit = self.new_edit_box(_("Keyword"),
                                         v2,
                                         self.obj.keyword,
                                         maxLen=85)
        # Add the element to the sizer
        r1Sizer.Add(v2, 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
        v3 = wx.BoxSizer(wx.VERTICAL)
        # Definition [label]
        definition_lbl = wx.StaticText(self.panel, -1, _("Definition"))
        v3.Add(definition_lbl, 0, wx.BOTTOM, 3)

        # Definition layout [control]
        self.definition_edit = wx.TextCtrl(self.panel,
                                           -1,
                                           self.obj.definition,
                                           style=wx.TE_MULTILINE)
        v3.Add(self.definition_edit, 1, wx.EXPAND)

        # Add the element to the sizer
        r2Sizer.Add(v3, 1, wx.EXPAND)

        # Add the row sizer to the main vertical sizer
        mainSizer.Add(r2Sizer, 1, wx.EXPAND)

        # Add a vertical spacer to the main sizer
        mainSizer.Add((0, 10))

        # Create a HORIZONTAL sizer for the next row
        r3Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Create a VERTICAL sizer for the next element
        v4 = wx.BoxSizer(wx.VERTICAL)
        # Definition [label]
        definition_lbl = wx.StaticText(self.panel, -1, _("Default Code Color"))
        v4.Add(definition_lbl, 0, wx.BOTTOM, 3)

        # Get the list of colors for populating the control
        choices = ['']
        # Make a dictionary for looking up the UNTRANSLATED color names and color definintions that match the TRANSLATED color names
        self.colorList = {}
        # Iterate through the global Graphics Colors (which can be user-defined!)
        for x in TransanaGlobal.transana_graphicsColorList:
            # We need to exclude WHITE
            if x[1] != (255, 255, 255):
                # Get the TRANSLATED color name
                tmpColorName = _(x[0])
                # If the color name is a string ...
                if isinstance(tmpColorName, str):
                    # ... convert it to unicode
                    tmpColorName = unicode(tmpColorName, 'utf8')
                # Add the translated color name to the choice box
                choices.append(tmpColorName)
                # Add the color definition to the dictionary, using the translated name as the key
                self.colorList[tmpColorName] = x

        # Add the Choice Control
        self.line_color_cb = wx.Choice(self.panel, wx.ID_ANY, choices=choices)
        # If the current Keyword Object's color is in the Color List ...
        if self.obj.lineColorName in TransanaGlobal.keywordMapColourSet:
            # ... select the correct color in the choice box
            self.line_color_cb.SetStringSelection(_(self.obj.lineColorName))
        # If the current Keyword Object's color is not blank and is not in the list ...
        else:
            if self.obj.lineColorName != '':
                # ... add the color to the choice box
                self.line_color_cb.SetStringSelection(_(
                    self.obj.lineColorName))
                # ... and add the color definition to the color list
                self.colorList[self.obj.lineColorName] = (
                    self.obj.lineColorName,
                    (int(self.obj.lineColorDef[1:3],
                         16), int(self.obj.lineColorDef[3:5],
                                  16), int(self.obj.lineColorDef[5:7], 16)))
            else:
                self.obj.lineColorDef = ''

        v4.Add(self.line_color_cb, 0, wx.EXPAND | wx.BOTTOM, 3)

        # Add the element to the sizer
        r3Sizer.Add(v4, 1, wx.EXPAND)

        # Add a horizontal spacer to the row sizer
        r3Sizer.Add((10, 0))

        # Create a VERTICAL sizer for the next element
        v5 = wx.BoxSizer(wx.VERTICAL)
        # Definition [label]
        definition_lbl = wx.StaticText(self.panel, -1,
                                       _("Default Snapshot Code Tool"))
        v5.Add(definition_lbl, 0, wx.BOTTOM, 3)
        self.codeShape = wx.Choice(
            self.panel,
            wx.ID_ANY,
            choices=['',
                     _('Rectangle'),
                     _('Ellipse'),
                     _('Line'),
                     _('Arrow')])
        # If the Draw Mode is Rectangle ...
        if self.obj.drawMode == 'Rectangle':
            # ... set the Shape to Rectangle
            self.codeShape.SetStringSelection(_('Rectangle'))
        # If the Draw Mode is Ellipse ...
        elif self.obj.drawMode == 'Ellipse':
            # ... set the Shape to Ellipse
            self.codeShape.SetStringSelection(_('Ellipse'))
        # If the Draw Mode is Line ...
        elif self.obj.drawMode == 'Line':
            # ... set the Shape to Line
            self.codeShape.SetStringSelection(_('Line'))
        # If the Draw Mode is Arrow ...
        elif self.obj.drawMode == 'Arrow':
            # ... set the Shape to Arrow
            self.codeShape.SetStringSelection(_('Arrow'))
        # If it's none of these ...
        else:
            # ... set it to blank!
            self.codeShape.SetStringSelection('')
        v5.Add(self.codeShape, 0, wx.EXPAND | wx.BOTTOM, 3)

        # Add the element to the sizer
        r3Sizer.Add(v5, 1, wx.EXPAND)

        # 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
        v6 = wx.BoxSizer(wx.VERTICAL)
        # Definition [label]
        definition_lbl = wx.StaticText(self.panel, -1,
                                       _("Default Snapshot Line Width"))
        v6.Add(definition_lbl, 0, wx.BOTTOM, 3)

        self.lineSize = wx.Choice(self.panel,
                                  wx.ID_ANY,
                                  choices=['', '1', '2', '3', '4', '5', '6'])
        # Set Line Width
        if self.obj.lineWidth > 0:
            self.lineSize.SetStringSelection("%d" % self.obj.lineWidth)
        else:
            self.lineSize.SetStringSelection('')
        v6.Add(self.lineSize, 0, wx.EXPAND | wx.BOTTOM, 3)

        # Add the element to the sizer
        r4Sizer.Add(v6, 1, wx.EXPAND)

        # 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)
        # Definition [label]
        definition_lbl = wx.StaticText(self.panel, -1,
                                       _("Default Snapshot Line Style"))
        v7.Add(definition_lbl, 0, wx.BOTTOM, 3)
        # ShortDash is indistinguishable from LongDash, at least on Windows, so I've left it out of the options here.
        self.line_style_cb = wx.Choice(
            self.panel,
            wx.ID_ANY,
            choices=['', _('Solid'),
                     _('Dot'),
                     _('Dash'),
                     _('Dot Dash')])
        # Set the Line Style
        if self.obj.lineStyle == 'Solid':
            self.line_style_cb.SetStringSelection(_('Solid'))
        elif self.obj.lineStyle == 'Dot':
            self.line_style_cb.SetStringSelection(_('Dot'))
        elif self.obj.lineStyle == 'LongDash':
            self.line_style_cb.SetStringSelection(_('Dash'))
        elif self.obj.lineStyle == 'DotDash':
            self.line_style_cb.SetStringSelection(_('Dot Dash'))
        else:
            self.line_style_cb.SetStringSelection('')
        v7.Add(self.line_style_cb, 0, wx.EXPAND | wx.BOTTOM, 3)

        # Add the element to the sizer
        r4Sizer.Add(v7, 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 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(self.width, width), max(self.height, height)))
        # Define the minimum size for this dialog as the current size
        self.SetSizeHints(max(self.width, width), max(self.height, height))
        # Center the form on screen
        TransanaGlobal.CenterOnPrimary(self)

        # We need to set some minimum sizes so the sizers will work right
        self.kwg_choice.SetSizeHints(minW=50, minH=20)
        keyword_edit.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.kwg_choice.Append(keywordGroup)

        if self.obj.keywordGroup:
            # If the Keyword Group of the passed-in Keyword object does not exist, add it to the list.
            # Otherwise, there's no way to ever add a first keyword to a group!
            if self.kwg_choice.FindString(self.obj.keywordGroup) == -1:
                self.kwg_choice.Append(self.obj.keywordGroup)


#            self.kwg_choice.SetStringSelection(self.obj.keywordGroup)
# If we're on the Mac ...
            if 'wxMac' in wx.PlatformInfo:
                # ... SetStringSelection is broken, so we locate the string's item number and use SetSelection!
                self.kwg_choice.SetSelection(self.kwg_choice.GetItems().index(
                    self.obj.keywordGroup))
            else:
                self.kwg_choice.SetStringSelection(self.obj.keywordGroup)

        else:
            self.kwg_choice.SetSelection(0)

        if self.obj.keywordGroup == '':
            self.kwg_choice.SetFocus()
        else:
            keyword_edit.SetFocus()
Esempio n. 8
0
    def __init__(self, parent, id, title, document_object):
        """ Create the Transcript Properties form """
        self.parent = parent
        self.width = 500
        self.height = 260
        # Make the Keyword Edit List resizable by passing wx.RESIZE_BORDER style
        Dialogs.GenForm.__init__(self,
                                 parent,
                                 id,
                                 title,
                                 size=(self.width, self.height),
                                 style=wx.DEFAULT_DIALOG_STYLE
                                 | wx.RESIZE_BORDER,
                                 useSizers=True,
                                 HelpContext='Document Properties')

        # Define the form's main object
        self.obj = document_object
        # if a Library has been passed in ...
        if self.obj.library_num > 0:
            # ... get the Library's data
            library = Library.Library(self.obj.library_num)
        # If no Library has been passed in (ILLEGAL??) ...
        else:
            # ... create an empty Library
            library = Library.Library()

        # Create the form's main VERTICAL sizer
        mainSizer = wx.BoxSizer(wx.VERTICAL)

        # Create a VERTICAL sizer for the next element
        v1 = wx.BoxSizer(wx.VERTICAL)
        # Add the Transcript ID element
        self.id_edit = self.new_edit_box(_("Document ID"),
                                         v1,
                                         self.obj.id,
                                         maxLen=100)
        # Add the element to the sizer
        mainSizer.Add(v1, 1, wx.EXPAND)

        # Add a vertical spacer to the main sizer
        mainSizer.Add((0, 10))

        # Create a VERTICAL sizer for the next element
        v2 = wx.BoxSizer(wx.VERTICAL)
        # Add the Library ID element
        library_id_edit = self.new_edit_box(_("Library ID"), v2, library.id)
        # Add the element to the main sizer
        mainSizer.Add(v2, 1, wx.EXPAND)
        # Disable Library ID
        library_id_edit.Enable(False)

        # Add a vertical spacer to the main sizer
        mainSizer.Add((0, 10))

        # If the Document has already been defined, we can skip this!
        if self.obj.number == 0:
            # Create a HORIZONTAL sizer for the next row
            r1Sizer = wx.BoxSizer(wx.HORIZONTAL)

            # Create a VERTICAL sizer for the next element
            v3 = wx.BoxSizer(wx.VERTICAL)
            # Add the Import File element
            self.rtfname_edit = self.new_edit_box(
                _("RTF/XML/TXT File to import  (optional)"), v3, '')
            # Make this text box a File Drop Target
            self.rtfname_edit.SetDropTarget(
                EditBoxFileDropTarget(self.rtfname_edit))
            # Add the element to the row sizer
            r1Sizer.Add(v3, 1, wx.EXPAND)

            # Add a horizontal spacer to the row sizer
            r1Sizer.Add((10, 0))

            # Add the Browse Button
            browse = wx.Button(self.panel, -1, _("Browse"))
            # Add the Browse Method to the Browse Button
            wx.EVT_BUTTON(self, browse.GetId(), self.OnBrowseClick)
            # Add the element to the sizer
            r1Sizer.Add(browse, 0, wx.ALIGN_BOTTOM)
            # If Mac ...
            if 'wxMac' in wx.PlatformInfo:
                # ... add a spacer to avoid control clipping
                r1Sizer.Add((2, 0))

            # 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))

        else:
            # Create a HORIZONTAL sizer for the next row
            r1Sizer = wx.BoxSizer(wx.HORIZONTAL)
            # Create a VERTICAL sizer for the next element
            v3 = wx.BoxSizer(wx.VERTICAL)
            # Add the Import File element
            self.rtfname_edit = self.new_edit_box(_("Imported File"), v3,
                                                  self.obj.imported_file)
            # Disable this field
            self.rtfname_edit.Enable(False)
            # Add the element to the row sizer
            r1Sizer.Add(v3, 4, wx.EXPAND)

            # Add a horizontal spacer to the row sizer
            r1Sizer.Add((10, 0))

            # Create a VERTICAL sizer for the next element
            v35 = wx.BoxSizer(wx.VERTICAL)
            # If the import date is a datetime object ...
            if isinstance(self.obj.import_date, datetime.datetime):
                # ... get its YYYY-MM-DD representation
                dtStr = self.obj.import_date.strftime('%Y-%m-%d')
            # if the import date is None ...
            elif self.obj.import_date is None:
                # ... leave this field blank
                dtStr = ''
            # Otherwise ...
            else:
                # Use whatever the import date value is
                dtStr = self.obj.import_date
            # If no file was imported ...
            if self.obj.imported_file == '':
                # ... the date is the Document Creation Date
                prompt = _("Creation Date")
            # If a file was imported ...
            else:
                # ... the date is the Document Import Date
                prompt = _("Import Date")
            # Add the Import Date element
            self.import_date = self.new_edit_box(prompt, v35, dtStr)
            # Disable this field
            self.import_date.Enable(False)
            # Add the element to the row sizer
            r1Sizer.Add(v35, 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 VERTICAL sizer for the next element
        v4 = wx.BoxSizer(wx.VERTICAL)
        # Add the Author element
        author_edit = self.new_edit_box(_("Author"),
                                        v4,
                                        self.obj.author,
                                        maxLen=100)
        # Add the element to the main sizer
        mainSizer.Add(v4, 1, wx.EXPAND)

        # Add a vertical spacer to the main sizer
        mainSizer.Add((0, 10))

        # Create a VERTICAL sizer for the next element
        v5 = wx.BoxSizer(wx.VERTICAL)
        # Add the Comment element
        comment_edit = self.new_edit_box(_("Comment"),
                                         v5,
                                         self.obj.comment,
                                         maxLen=255)
        # Add the element to the main sizer
        mainSizer.Add(v5, 1, 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
        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
        r2Sizer.Add(v6, 1, wx.EXPAND)

        self.kw_list = []
        wx.EVT_LISTBOX(self, kw_groups_id, self.OnGroupSelect)

        # Add a horizontal spacer
        r2Sizer.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
        r2Sizer.Add(v7, 1, wx.EXPAND)

        # Add a horizontal spacer
        r2Sizer.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, 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
        r2Sizer.Add(v8, 0)

        # Add a horizontal spacer
        r2Sizer.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, _("Document 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
        r2Sizer.Add(v9, 2, wx.EXPAND)

        # Add the row sizer to the main vertical sizer
        mainSizer.Add(r2Sizer, 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)
        # 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 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(self.width, width), height))
        # Define the minimum size for this dialog as the current size, and define height as unchangeable
        self.SetSizeHints(max(self.width, width), height, -1, 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)

        # Select the Library Default Keyword Group in the Keyword Group list
        if (library.keyword_group != '') and (self.kw_group_lb.FindString(
                library.keyword_group) != wx.NOT_FOUND):
            self.kw_group_lb.SetStringSelection(library.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 documentKeyword in self.obj.keyword_list:
            self.ekw_lb.Append(documentKeyword.keywordPair)

        # Set focus to the Transcript ID
        self.id_edit.SetFocus()
Esempio n. 9
0
    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()
Esempio n. 10
0
    def __init__(self, parent, title, controlObject):
        # Note the Control Object passed in, used in the Help call
        self.ControlObject = controlObject
        # Get the Media Library Directory
        mediaDir = TransanaGlobal.configData.videoPath.replace('\\', '/')
        # We need a specifically-named dictionary in a particular format for the ColumnSorterMixin.
        # Initialize that here.  (This also tells us if we've gotten the data yet!)
        self.itemDataMap = {}

        # Create the Form
        wx.Dialog.__init__(self,
                           parent,
                           title=title,
                           size=(1000, 650),
                           style=wx.CAPTION | wx.RESIZE_BORDER | wx.CLOSE_BOX)

        # Create a Sizer
        s1 = wx.BoxSizer(wx.VERTICAL)
        # Create instructions
        prompt = _(
            "The following files are not where Transana expects them to be.  First, please select one or more files and search for them using the Search button below.\n"
        )
        prompt += _(
            "If a copy of the file is found, You can instruct Transana to use it where it is, to copy it to where Transana expects it, or to move it.  If no copy of the file \n"
        )
        prompt += _(
            "is found, you can change the Search Directory and search again.")
        # Place the instructions on the form
        txt = wx.StaticText(self, -1, prompt)
        # Add the instructions to the Sizer
        s1.Add(txt, 0, wx.EXPAND | wx.ALL, 10)

        # Create the list of missing files
        self.fileList = AutoWidthListCtrl(self,
                                          -1,
                                          style=wx.LC_REPORT | wx.BORDER_SUNKEN
                                          | wx.LC_SORT_ASCENDING)
        # Add in the Column Sorter mixin to make the results panel sortable
        wx.lib.mixins.listctrl.ColumnSorterMixin.__init__(self, 3)
        # Add the missing file list to the Sizer
        s1.Add(self.fileList, 1, wx.EXPAND)

        # Create a horizontal sizer
        h1 = wx.BoxSizer(wx.HORIZONTAL)
        # Create a Search button and give it a handler
        self.btnSearch = wx.Button(self, -1, _("Search for File(s)"))
        self.btnSearch.Bind(wx.EVT_BUTTON, self.OnSearch)
        # Add it to the Button Sizer
        h1.Add(self.btnSearch, 0, wx.TOP | wx.LEFT | wx.RIGHT, 10)
        # Add a Label for the Search Directory
        searchTxt = wx.StaticText(self, -1, _("Starting Search Directory"))
        # Add the label to the Sizer
        h1.Add(searchTxt, 0,
               wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.LEFT | wx.RIGHT, 10)
        # Add a TextCtrl for the Search Path
        self.path = wx.TextCtrl(self, -1, mediaDir)
        # Add the Search Path to the Sizer
        h1.Add(self.path, 1, wx.EXPAND | wx.TOP | wx.LEFT | wx.RIGHT, 10)
        # Create a Browse Button
        browse = wx.Button(self, -1, _("Browse"))
        # Add the Browse button to the Sizer
        h1.Add(browse, 0, wx.TOP | wx.LEFT | wx.RIGHT, 10)
        # Add the Button Press Handler
        browse.Bind(wx.EVT_BUTTON, self.OnBrowse)
        # Add the horizontal Sizer to the Main Sizer
        s1.Add(h1, 0, wx.EXPAND)

        # Create a Sizer for the Button Bar
        h2 = wx.BoxSizer(wx.HORIZONTAL)
        # Create a Use Existing Location button and give it a handler
        self.btnUse = wx.Button(self, -1, _("Use Actual Location"))
        self.btnUse.Bind(wx.EVT_BUTTON, self.OnUseCopyMove)
        # Add it to the Button Sizer
        h2.Add(self.btnUse, 0, wx.ALL, 10)
        # Create a Copy File button and give it a handler
        self.btnCopy = wx.Button(self, -1, _("Copy File"))
        self.btnCopy.Bind(wx.EVT_BUTTON, self.OnUseCopyMove)
        # Add it to the Button Sizer
        h2.Add(self.btnCopy, 0, wx.ALL, 10)
        # Create a Move File button and give it a handler
        self.btnMove = wx.Button(self, -1, _("Move File"))
        self.btnMove.Bind(wx.EVT_BUTTON, self.OnUseCopyMove)
        # Add it to the Button Sizer
        h2.Add(self.btnMove, 0, wx.ALL, 10)
        # Create a Rename button and give it a handler
        self.btnRename = wx.Button(self, -1, _("Change File Name"))
        self.btnRename.Bind(wx.EVT_BUTTON, self.OnUseCopyMove)
        # Add it to the Button Sizer
        h2.Add(self.btnRename, 0, wx.ALL, 10)
        # Create a File Management button and give it a handler
        self.btnFileMgt = wx.Button(self, -1, _("File Management"))
        self.btnFileMgt.Bind(wx.EVT_BUTTON, self.OnFileManagement)
        # Add it to the Button Sizer
        h2.Add(self.btnFileMgt, 0, wx.ALL, 10)
        # Add an expandable spacer to the Button Sizer
        h2.Add((1, 1), 1, wx.EXPAND)
        # Create an OK button and give it a handler
        self.btnOK = wx.Button(self, -1, _("OK"))
        self.btnOK.Bind(wx.EVT_BUTTON, self.OnOk)
        # Add it to the Button Sizer
        h2.Add(self.btnOK, 0, wx.ALIGN_RIGHT | wx.ALL, 10)
        # Create a Help button and give it a handler
        self.btnHelp = wx.Button(self, -1, _("Help"))
        self.btnHelp.Bind(wx.EVT_BUTTON, self.OnHelp)
        # Add it to the Button Sizer
        h2.Add(self.btnHelp, 0, wx.ALIGN_RIGHT | wx.ALL, 10)
        # Add the Button Sizer to the Main Sizer
        s1.Add(h2, 0, wx.EXPAND)

        # Set the main sizer
        self.SetSizer(s1)
        # Lay out the Form
        self.Layout()
        self.SetAutoLayout(True)
        # Center the form on screen
        TransanaGlobal.CenterOnPrimary(self)
        # Populate the Missing Files List
        self.UpdateMissingFileList()
Esempio n. 11
0
    def __init__(self, parent):
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           _("sFTP Connection Parameters"),
                           size=(250, 520),
                           style=wx.CAPTION | wx.RESIZE_BORDER
                           | wx.NO_FULL_REPAINT_ON_RESIZE)

        self.LoadConfiguration()

        # Create a Sizer
        box = wx.BoxSizer(wx.VERTICAL)

        lblUserName = wx.StaticText(self, -1, _("User Name:"))
        box.Add(lblUserName, 0, wx.LEFT, 10)

        self.editUserName = wx.TextCtrl(self, -1)
        box.Add(self.editUserName, 2,
                wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 10)

        lblPassword = wx.StaticText(self, -1, _("Password:"******"sFTP Server:"))
        box.Add(lblsFTPServer, 0, wx.LEFT, 10)

        self.editsFTPServer = wx.TextCtrl(self, -1, self.sFTPServer)
        box.Add(self.editsFTPServer, 2,
                wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 10)

        lblsFTPPort = wx.StaticText(self, -1, _("sFTP Port:"))
        box.Add(lblsFTPPort, 0, wx.LEFT, 10)

        self.editsFTPPort = wx.TextCtrl(self, -1, self.sFTPPort)
        box.Add(self.editsFTPPort, 2,
                wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 10)

        lblsFTPPublicKeyType = wx.StaticText(self, -1,
                                             _("sFTP Server Public Key Type:"))
        box.Add(lblsFTPPublicKeyType, 0, wx.LEFT, 10)

        self.choicesFTPPublicKeyType = wx.Choice(
            self, -1, choices=[_('None'), 'ssh-rsa', 'ssh-dss'])
        self.choicesFTPPublicKeyType.SetStringSelection(self.sFTPPublicKeyType)
        self.choicesFTPPublicKeyType.Bind(wx.EVT_CHOICE,
                                          self.OnPublicKeyTypeSelect)
        box.Add(self.choicesFTPPublicKeyType, 2,
                wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 10)

        lblsFTPPublicKey = wx.StaticText(self, -1,
                                         _("sFTP Server Public Key:"))
        box.Add(lblsFTPPublicKey, 0, wx.LEFT, 10)

        self.editsFTPPublicKey = wx.TextCtrl(self, -1, self.sFTPPublicKey)

        if self.sFTPPublicKeyType.encode('utf8') == _("None"):
            self.editsFTPPublicKey.Enable(False)
        box.Add(self.editsFTPPublicKey, 2,
                wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.EXPAND, 10)

        btnBox = wx.BoxSizer(wx.HORIZONTAL)

        btnBox.Add((20, 0))

        btnConnect = wx.Button(self, wx.ID_OK, _("Connect"))
        btnBox.Add(btnConnect, 1, wx.ALIGN_CENTER_HORIZONTAL)

        # Make the Connect button the default
        self.SetDefaultItem(btnConnect)

        btnBox.Add((20, 0))

        btnCancel = wx.Button(self, wx.ID_CANCEL, _("Cancel"))
        btnBox.Add(btnCancel, 1, wx.ALIGN_CENTER_HORIZONTAL)

        btnBox.Add((20, 0))
        box.Add(btnBox, 0, wx.ALIGN_CENTER)
        box.Add((0, 10))

        self.SetSizer(box)
        self.Fit()

        self.Layout()
        self.SetAutoLayout(True)
        # Center on the Screen
        TransanaGlobal.CenterOnPrimary(self)

        # Set Focus
        self.editUserName.SetFocus()
Esempio n. 12
0
    def __init__(self, parent, title, copyFrom, copyTo):
        """ Set up the Dialog Box and all GUI Widgets. """
        if (os.path.exists(copyFrom)):
            # Set up local variables
            self.parent = parent
            # Initialize Threaded File Copy object and the timer that updates the progress dialog
            self.threadedFileCopy = None
            self.timer = None

            size = (350,200)
            # Create the Dialog Box itself, with no minimize/maximize/close buttons
            wx.Dialog.__init__(self, parent, -1, title, size = size, style=wx.CAPTION)

            # Create a main VERTICAL sizer for the form
            mainSizer = wx.BoxSizer(wx.VERTICAL)

            # File label
            if 'unicode' in wx.PlatformInfo:
                # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
                prompt = unicode(_("File: %s"), 'utf8')
            else:
                prompt = _("File: %s")
            # extract the file name...
            (dir, fileName) = os.path.split(copyFrom)
            self.destFileStr = os.path.join(copyTo, fileName)
            self.lblFile = wx.StaticText(self, -1, prompt % fileName, style=wx.ST_NO_AUTORESIZE)
            # Add the label to the Main Sizer
            mainSizer.Add(self.lblFile, 0, wx.ALL, 10)

            # Progress Bar
            self.progressBar = wx.Gauge(self, -1, 100, style=wx.GA_HORIZONTAL | wx.GA_SMOOTH)
            # Add the element to the Main Sizer
            mainSizer.Add(self.progressBar, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

            # Create a Row Sizer
            r1Sizer = wx.BoxSizer(wx.HORIZONTAL)
            
            # Bytes Transferred label
            if 'unicode' in wx.PlatformInfo:
                # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
                prompt = unicode(_("%d bytes of %d transferred"), 'utf8')
            else:
                prompt = _("%d bytes of %d transferred")
            self.lblBytes = wx.StaticText(self, -1, prompt % (100000000, 100000000), style=wx.ST_NO_AUTORESIZE)
            # Add the label to the Row Sizer
            r1Sizer.Add(self.lblBytes, 5, wx.EXPAND)

            # Percent Transferred label
            self.lblPercent = wx.StaticText(self, -1, "%5.1d %%" % 1000.1, style=wx.ST_NO_AUTORESIZE | wx.ALIGN_RIGHT)
            # Add the Element to the Row Sizer
            r1Sizer.Add(self.lblPercent, 1, wx.ALIGN_RIGHT)

            # Add the Row Sizer to the Main Sizer
            mainSizer.Add(r1Sizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

            # Create a Row Sizer
            r2Sizer = wx.BoxSizer(wx.HORIZONTAL)

            # Elapsed Time label
            if 'unicode' in wx.PlatformInfo:
                # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
                prompt = unicode(_("Elapsed Time: %d:%02d:%02d"), 'utf8')
            else:
                prompt = _("Elapsed Time: %d:%02d:%02d")
            self.lblElapsedTime = wx.StaticText(self, -1, prompt % (0, 0, 0), style=wx.ST_NO_AUTORESIZE)
            # Add the element to the Row Sizer
            r2Sizer.Add(self.lblElapsedTime, 0)

            # Add a spacer
            r2Sizer.Add((1, 0), 1, wx.EXPAND)

            # Remaining Time label
            if 'unicode' in wx.PlatformInfo:
                # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
                prompt = unicode(_("Time Remaining: %d:%02d:%02d"), 'utf8')
            else:
                prompt = _("Time Remaining: %d:%02d:%02d")
            self.lblTimeRemaining = wx.StaticText(self, -1, prompt % (0, 0, 0), style=wx.ST_NO_AUTORESIZE | wx.ALIGN_RIGHT)
            # Add the element to the Row Sizer
            r2Sizer.Add(self.lblTimeRemaining, 0)

            # Add the Row Sizer to the Main Sizer
            mainSizer.Add(r2Sizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

            # Transfer Speed label
            if 'unicode' in wx.PlatformInfo:
                # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
                prompt = unicode(_("Transfer Speed: %d k/sec"), 'utf8')
            else:
                prompt = _("Transfer Speed: %d k/sec")
            self.lblTransferSpeed = wx.StaticText(self, -1, prompt % 0, style=wx.ST_NO_AUTORESIZE)
            # Add the element to the Main Sizer
            mainSizer.Add(self.lblTransferSpeed, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

            # Cancel Button
            self.btnCancel = wx.Button(self, wx.ID_CANCEL, _("Cancel Remaining Files"))
            # Add the element to the Main Sizer
            mainSizer.Add(self.btnCancel, 0, wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

            wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)

            # Attach the main sizer to the form
            self.SetSizer(mainSizer)
            # Turn Auto Layout on
            self.SetAutoLayout(True)
            # Lay out the form
            self.Layout()
            # Center on the Screen
            TransanaGlobal.CenterOnPrimary(self)
            # Initialize variables used in file transfer
            BytesRead = 0
            # "cancelled" is intialized to false.  If the user cancels the file transfer,
            # this variable gets set to true to signal the need to interrupt the transfer.
            self.cancelled = False
            # Note the starting time of the transfer for progress reporting purposes
            self.StartTime = time.time()

            self.Bind(wx.EVT_TIMER, self.UpdateDisplay)
            EVT_THREAD_COMPLETE(self, self.OnFileCopyComplete)
            
            # Create a timer used to update the Progress Dialog
            self.timer = wx.Timer(self)
            # Start the timer, firing it every half second
            self.timer.Start(500)

            self.size1 = os.stat(copyFrom)[6]
            self.threadedFileCopy = ThreadedFileCopy(self, copyFrom, copyTo)

            # Show the form
            self.ShowModal()
Esempio n. 13
0
    def OnKeyUp(self, event):
        """ OnKeyUp event captures the release of keys so they can be processed """
        # If ALT and SHIFT are pressed ...
        if event.AltDown() and event.ShiftDown():
            # ... get the key that was pressed
            key = event.GetKeyCode()
            # If F11 is pressed, show COMPONENT VERSION information
            if (key == wx.WXK_F11) or (key in [ord('S'), ord('s')]):
                # Import Python's ctypes, Transana's DBInterface, Python's sys modules, and numpy
                import Crypto, ctypes, DBInterface, paramiko, sys, numpy

                if sys.platform == 'win32':
                    sysplat = 'Windows'
                    sysver = platform.win32_ver()[0]
                elif sys.platform == 'darwin':
                    sysplat = 'Mac OS X'
                    sysver = platform.mac_ver()[0]
                else:
                    sysplat = sys.platform
                    sysver = platform.version()
                str = 'Platform:  %s %s' % (sysplat, sysver)
                # Build a string that contains the version information for crucial programming components
                str += '\n\nTransana %s uses the following tools:\n\n'% (TransanaConstants.versionNumber)
                if (platform.architecture()[0] == '32bit') or (sys.maxint == 2 ** 31 - 1):
                    arc = '32-bit'
                elif platform.architecture()[0] == '64bit':
                    arc = '64-bit'
                else:
                    arc = 'Unknown architecture'
                str = '%sPython:  %s  (%s)\n' % (str, sys.version[:6].strip(), arc)
                if 'unicode' in wx.PlatformInfo:
                    str2 = 'unicode'
                else:
                    str2 = 'ansi'
                str = '%swxPython:  %s - %s\n' % (str, wx.VERSION_STRING, str2)
                if TransanaConstants.DBInstalled in ['MySQLdb-embedded', 'MySQLdb-server']:
                    import MySQLdb
                    str = '%sMySQL for Python:  %s\n' % (str, MySQLdb.__version__)
                elif TransanaConstants.DBInstalled in ['PyMySQL']:
                    import pymysql
                    str = '%sPyMySQL:  %s\n' % (str, pymysql.version_info)
                elif TransanaConstants.DBInstalled in ['sqlite3']:
                    import sqlite3
                    str = '%ssqlite:  %s\n' % (str, sqlite3.version)
                else:
                    str = '%sUnknown Database:  Unknown Version\n' % (str, )
                if DBInterface._dbref != None:
                    # Get a Database Cursor
                    dbCursor = DBInterface._dbref.cursor()
                    if TransanaConstants.DBInstalled in ['MySQLdb-embedded', 'MySQLdb-server', 'PyMySQL']:
                        # Query the Database about what Database Names have been defined
                        dbCursor.execute('SELECT VERSION()')
                        vs = dbCursor.fetchall()
                        for v in vs:
                            str = "%sMySQL:  %s\n" % (str, v[0])
                str = "%sctypes:  %s\n" % (str, ctypes.__version__)
                str = "%sCrypto:  %s\n" % (str, Crypto.__version__)
                str = "%sparamiko:  %s\n" % (str, paramiko.__version__)
                str = "%snumpy:     %s\n" % (str, numpy.__version__)
                str = "%sEncoding:  %s\n" % (str, TransanaGlobal.encoding)
                str = "%sLanguage:  %s\n" % (str, TransanaGlobal.configData.language)
                # Replace the Description text with the version information text
                self.description.SetLabel(str)

                query = "SELECT COUNT(SeriesNum) FROM Series2"
                dbCursor.execute(query)
                seriesCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(DocumentNum) FROM Documents2"
                dbCursor.execute(query)
                documentCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(EpisodeNum) FROM Episodes2"
                dbCursor.execute(query)
                episodeCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(CoreDataNum) FROM CoreData2"
                dbCursor.execute(query)
                coreDataCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(TranscriptNum) FROM Transcripts2 WHERE ClipNum = 0"
                dbCursor.execute(query)
                transcriptCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(CollectNum) FROM Collections2"
                dbCursor.execute(query)
                collectionCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(quoteNum) FROM Quotes2"
                dbCursor.execute(query)
                quoteCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(clipNum) FROM Clips2"
                dbCursor.execute(query)
                clipCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(TranscriptNum) FROM Transcripts2 WHERE ClipNum <> 0"
                dbCursor.execute(query)
                clipTranscriptCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(SnapshotNum) FROM Snapshots2"
                dbCursor.execute(query)
                snapshotCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(NoteNum) FROM Notes2"
                dbCursor.execute(query)
                noteCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(Keyword) FROM Keywords2"
                dbCursor.execute(query)
                keywordCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(Keyword) FROM ClipKeywords2"
                dbCursor.execute(query)
                clipKeywordCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(Keyword) FROM SnapshotKeywords2"
                dbCursor.execute(query)
                snapshotKeywordCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(Keyword) FROM SnapshotKeywordStyles2"
                dbCursor.execute(query)
                snapshotKeywordStylesCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(AddVidNum) FROM AdditionalVids2"
                dbCursor.execute(query)
                addVidCount = dbCursor.fetchall()[0][0]
                
                query = "SELECT COUNT(ConfigName) FROM Filters2"
                dbCursor.execute(query)
                filterCount = dbCursor.fetchall()[0][0]

                tmpStr = """Data Records:
  Libraries: %s
  Documents: %s
  Episodes: %s
  Episode Transcripts: %s
  Collections: %s
  Quotes: %s
  Clips: %s
  Clip Transcripts: %s
  Snapshots: %s
  Notes:  %s
  Keywords: %s
  Quote/Clip Keywords: %s
  Snapshot Keywords: %s
  Snapshot Keyword Styles: %s
  Additional Videos:  %s
  Filters:  %s
  Core Data: %s\n  """
                data = (seriesCount, documentCount, episodeCount, transcriptCount, collectionCount, quoteCount,
                        clipCount, clipTranscriptCount,
                        snapshotCount, noteCount, keywordCount, clipKeywordCount, snapshotKeywordCount,
                        snapshotKeywordStylesCount, addVidCount, filterCount, coreDataCount)
                
                # Eliminate the Credits text
                self.credits.SetLabel(tmpStr % data)
                self.translations.SetLabel('')
                self.ffmpeg.SetLabel('')
            # If F12 is pressed ...
            elif (key == wx.WXK_F12) or (key in [ord('H'), ord('h')]):
                # Replace the Version information text with the original description text
                self.description.SetLabel(self.description_str)
                # Replace the blank credits text with the original credits text
                self.credits.SetLabel(self.credits_str)
                self.translations.SetLabel(self.translations_str)
                self.ffmpeg.SetLabel(self.ffmpeg_str)
            # Fit the window to the altered controls
            self.Fit()
            TransanaGlobal.CenterOnPrimary(self)

        # If ALT and SHIFT aren't both pressed ...
        else:
            # ... then we don't do anything
            pass
Esempio n. 14
0
    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()
Esempio n. 15
0
    def __init__(self, parent, id, title, snapshot_object):
        # ... use the default Clip Properties Dialog size passed in from the config object.  (This does NOT get saved.)
        size = TransanaGlobal.configData.clipPropertiesSize
        # Define the Help Context
        HelpContext = 'Snapshot Properties'

        # 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,
                                 useSizers=True,
                                 HelpContext=HelpContext)
        # Define the minimum size for this dialog as the initial size
        minWidth = 750
        minHeight = 570
        # Remember the Parent Window
        self.parent = parent
        # Remember the original Snapshot Object passed in
        self.obj = snapshot_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)
        # Snapshot ID
        self.id_edit = self.new_edit_box(_("Snapshot 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))

        # Update the Snapshot's Collection ID based on the Snapshot's Collection Number
        self.obj._sync_snapshot()

        # 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)

        # Image Filename
        # If the image filename path is not empty, we should normalize the path specification
        if self.obj.image_filename == '':
            filePath = self.obj.image_filename
        else:
            filePath = os.path.normpath(self.obj.image_filename)

        self.fname_edit = self.new_edit_box(_("Image Filename"), v3, filePath)
        r2Sizer.Add(v3, 5, wx.EXPAND)

        r2Sizer.Add((10, 0))

        # Browse button layout
        btnBrowse = wx.Button(self.panel, wx.ID_FILE1, _("Browse"),
                              wx.DefaultPosition)
        r2Sizer.Add(btnBrowse, 0, wx.EXPAND | wx.TOP, 20)
        wx.EVT_BUTTON(self, wx.ID_FILE1, self.OnBrowse)

        # Figure out if the Snapshot Button should be displayed
        if ((isinstance(self.parent.ControlObject.currentObj, Episode.Episode)) or \
            (isinstance(self.parent.ControlObject.currentObj, Clip.Clip))) and \
           (len(self.parent.ControlObject.VideoWindow.mediaPlayers) == 1):

            # Add a horizontal spacer
            r2Sizer.Add((10, 0))

            # Snapshot button layout
            # Create the Snapshot button
            btnSnapshot = wx.BitmapButton(self.panel,
                                          -1,
                                          TransanaImages.Snapshot.GetBitmap(),
                                          size=(48, 24))
            # Set the Help String
            btnSnapshot.SetToolTipString(_("Capture Snapshot for Coding"))
            r2Sizer.Add(btnSnapshot, 0, wx.EXPAND | wx.TOP, 20)
            # Bind the Snapshot button to its event handler
            btnSnapshot.Bind(wx.EVT_BUTTON, self.OnSnapshot)

        # 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)

        self.seriesList = DBInterface.list_of_series()
        seriesRecs = ['']
        serDefault = 0
        for (seriesNum, seriesName) in self.seriesList:
            seriesRecs.append(seriesName)
            if self.obj.series_num == seriesNum:
                serDefault = len(seriesRecs) - 1

        # Create a VERTICAL sizer for the next element
        v4 = wx.BoxSizer(wx.VERTICAL)
        # Library ID
        self.series_cb = self.new_choice_box(_("Library ID"),
                                             v4,
                                             seriesRecs,
                                             default=serDefault)
        # Add the element to the sizer
        r4Sizer.Add(v4, 1, wx.EXPAND)
        self.series_cb.Bind(wx.EVT_CHOICE, self.OnSeriesChoice)

        # Add a horizontal spacer to the row sizer
        r4Sizer.Add((10, 0))

        # Create a VERTICAL sizer for the next element
        v5 = wx.BoxSizer(wx.VERTICAL)
        # Episode ID
        self.episode_cb = self.new_choice_box(_("Episode ID"), v5, [''])
        # Add the element to the sizer
        r4Sizer.Add(v5, 1, wx.EXPAND)
        self.episode_cb.Bind(wx.EVT_CHOICE, self.OnEpisodeChoice)

        self.episodeList = []
        if self.obj.series_id != '':
            self.PopulateEpisodeChoiceBasedOnSeries(self.obj.series_id)

        # 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)
        # Episode ID
        self.transcript_cb = self.new_choice_box(_("Transcript ID"), v6, [''])
        # Add the element to the sizer
        r5Sizer.Add(v6, 2, wx.EXPAND)
        self.transcript_cb.Bind(wx.EVT_CHOICE, self.OnTranscriptChoice)

        self.transcriptList = []
        if self.obj.episode_id != '':
            self.PopulateTranscriptChoiceBasedOnEpisode(
                self.obj.series_id, self.obj.episode_id)

        # Add a horizontal spacer to the row sizer
        r5Sizer.Add((10, 0))

        # Create a VERTICAL sizer for the next element
        v7 = wx.BoxSizer(wx.VERTICAL)
        # Episode Time Code.  Convert to HH:MM:SS.mm
        self.episode_start_edit = self.new_edit_box(
            _("Episode Position"), v7,
            Misc.time_in_ms_to_str(self.obj.episode_start))
        # Add the element to the sizer
        r5Sizer.Add(v7, 1, wx.EXPAND)
        if self.episode_cb.GetStringSelection() == '':
            self.episode_start_edit.Enable(False)

        # Add a horizontal spacer to the row sizer
        r5Sizer.Add((10, 0))

        # Create a VERTICAL sizer for the next element
        v8 = wx.BoxSizer(wx.VERTICAL)
        # Episode Duration.  Convert to HH:MM:SS.mm
        self.episode_duration_edit = self.new_edit_box(
            _("Duration"), v8,
            Misc.time_in_ms_to_str(self.obj.episode_duration))
        # Add the element to the sizer
        r5Sizer.Add(v8, 1, wx.EXPAND)
        if self.episode_cb.GetStringSelection() == '':
            self.episode_duration_edit.Enable(False)

        # 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)

        # Create a VERTICAL sizer for the next element
        v9 = wx.BoxSizer(wx.VERTICAL)
        # Comment
        comment_edit = self.new_edit_box(_("Comment"),
                                         v9,
                                         self.obj.comment,
                                         maxLen=255)
        # Add the element to the sizer
        r6Sizer.Add(v9, 1, wx.EXPAND)

        # Add the row sizer to the main vertical sizer
        mainSizer.Add(r6Sizer, 0, 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
        v10 = wx.BoxSizer(wx.VERTICAL)
        # Keyword Group [label]
        txt = wx.StaticText(self.panel, -1, _("Keyword Group"))
        v10.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)
        v10.Add(self.kw_group_lb, 1, wx.EXPAND)

        # Add the element to the sizer
        r7Sizer.Add(v10, 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
        v11 = wx.BoxSizer(wx.VERTICAL)
        # Keyword [label]
        txt = wx.StaticText(self.panel, -1, _("Keyword"))
        v11.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)
        v11.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(v11, 1, wx.EXPAND)

        # Add a horizontal spacer
        r7Sizer.Add((10, 0))

        # Create a VERTICAL sizer for the next element
        v12 = wx.BoxSizer(wx.VERTICAL)
        # Keyword transfer buttons
        add_kw = wx.Button(self.panel, wx.ID_FILE2, ">>", wx.DefaultPosition)
        v12.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)
        v12.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())
        v12.Add(kwm, 0, wx.EXPAND | wx.TOP, 10)
        # Add a spacer to increase the height of the Keywords section
        v12.Add((0, 60))
        kwm.SetToolTipString(_("Keyword Management"))
        wx.EVT_BUTTON(self, wx.ID_FILE4, self.OnKWManage)

        # Add the element to the sizer
        r7Sizer.Add(v12, 0)

        # Add a horizontal spacer
        r7Sizer.Add((10, 0))

        # Create a VERTICAL sizer for the next element
        v13 = wx.BoxSizer(wx.VERTICAL)

        # Whole Snapshot Keywords [label]
        txt = wx.StaticText(self.panel, -1, _("Whole Snapshot Keywords"))
        v13.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)
        v13.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(v13, 2, wx.EXPAND)

        # Add the row sizer to the main vertical sizer
        mainSizer.Add(r7Sizer, 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)
        # 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 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 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(minWidth, width), max(minHeight, height)))
        # Define the minimum size for this dialog as the current size
        self.SetSizeHints(max(minWidth, width), max(minHeight, 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)

        # 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 Snapshot Keywords ListBox
        # If the snapshot object has keywords ...
        for snapshotKeyword in self.obj.keyword_list:
            # ... add them to the keyword list
            self.ekw_lb.Append(snapshotKeyword.keywordPair)

        # Set initial focus to the Clip ID
        self.id_edit.SetFocus()
Esempio n. 16
0
    def __init__(self,
                 parent,
                 id,
                 libraryNum=0,
                 documentNum=0,
                 episodeNum=0,
                 collectionNum=0):
        # Remember the Library, Document, Episode or Collection that triggered creation of this report
        self.libraryNum = libraryNum
        self.documentNum = documentNum
        self.episodeNum = episodeNum
        self.collectionNum = collectionNum

        # Create a form to get the name of the file to receive the data
        # Define the form title
        title = _("Transana Analytic Data Export")
        # Create the form itself
        Dialogs.GenForm.__init__(self,
                                 parent,
                                 id,
                                 title, (550, 150),
                                 style=wx.DEFAULT_DIALOG_STYLE
                                 | wx.RESIZE_BORDER,
                                 useSizers=True,
                                 HelpContext='Analytic Data Export')

        # 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)

        # Header Message
        prompt = _('Please create a Transana Analytic Data File for export.')
        exportText = wx.StaticText(self.panel, -1, prompt)
        # Add the export message to the dialog box
        r1Sizer.Add(exportText, 0)

        # 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
        v1 = wx.BoxSizer(wx.VERTICAL)

        # Export Filename
        self.exportFile = self.new_edit_box(_("Export Filename"), v1, '')
        self.exportFile.SetDropTarget(EditBoxFileDropTarget(self.exportFile))
        # Add the element sizer to the row sizer
        r2Sizer.Add(v1, 1, wx.EXPAND)

        # Add a spacer to the row sizer
        r2Sizer.Add((10, 0))

        # Browse button
        browse = wx.Button(self.panel, wx.ID_FILE1, _("Browse"),
                           wx.DefaultPosition)
        wx.EVT_BUTTON(self, wx.ID_FILE1, self.OnBrowse)
        # Add the element to the row sizer
        r2Sizer.Add(browse, 0, wx.ALIGN_BOTTOM)
        # If Mac ...
        if 'wxMac' in wx.PlatformInfo:
            # ... add a spacer to avoid control clipping
            r2Sizer.Add((2, 0))

        # 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 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(550, width), max(100, height)))
        # Define the minimum size for this dialog as the current size, and define height as unchangeable
        self.SetSizeHints(max(550, width), max(100, height), -1,
                          max(100, height))
        # Center the form on screen
        TransanaGlobal.CenterOnPrimary(self)

        # Set focus to the Export File Name field
        self.exportFile.SetFocus()
Esempio n. 17
0
    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()
Esempio n. 18
0
    def __init__(self, parent, mode):
        """ Initialize the Batch Waveform Generator form.  "mode" is waveform" for the
            Batch Waveform Generator, "episode" for the Batch Episode Creation routine,
            or "snapshot" fo Batch Snapshot Creation. """
        # Remember the mode passed in.
        self.mode = mode
        # Based on the mode passed in, set the title and help context for the File Selection form
        if self.mode == 'waveform':
            formTitle = _('Batch Waveform Generator')
            helpContext = 'Batch Waveform Generator'
        elif self.mode == 'episode':
            formTitle = _("Batch Episode Creation")
            helpContext = 'Batch Episode Creation'
        elif self.mode == 'document':
            formTitle = _("Batch Document Creation")
            helpContext = 'Batch Document Creation'
        elif self.mode == 'snapshot':
            formTitle = _("Batch Snapshot Creation")
            helpContext = 'Batch Snapshot Creation'
        else:
            print "UNKNOWN BATCHFILEPROCESSOR MODE"

        # Create the Dialog box for the File Selection Form
        Dialogs.GenForm.__init__(self,
                                 parent,
                                 -1,
                                 formTitle, (500, 550),
                                 style=wx.DEFAULT_DIALOG_STYLE
                                 | wx.RESIZE_BORDER,
                                 useSizers=True,
                                 HelpContext=helpContext)

        # To look right, the Mac needs the Small Window Variant.
        if "__WXMAC__" in wx.PlatformInfo:
            self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)

        # 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)

        # Use the Video Root for the initial file path, if there is a Video Root
        if TransanaGlobal.configData.videoPath <> '':
            self.lastPath = TransanaGlobal.configData.videoPath
        # If there is no Video Root, use the Transana Program Directory
        else:
            self.lastPath = os.path.dirname(sys.argv[0])

        # Create the controls that will populate the File Selection Dialog window.
        # Create a Select Files button
        browse = wx.Button(self.panel, wx.ID_FILE1, _("Select Files"),
                           wx.DefaultPosition)
        # If Mac ...
        if 'wxMac' in wx.PlatformInfo:
            # ... add a spacer to avoid control clipping
            r1Sizer.Add((2, 0))
        # Add the element to the sizer
        r1Sizer.Add(browse, 1, wx.EXPAND)

        # Add a horizontal spacer to the row sizer
        r1Sizer.Add((10, 0))

        # Create a Select Directory button
        directories = wx.Button(self.panel, wx.ID_FILE2, _("Select Directory"),
                                wx.DefaultPosition)
        # Add the element to the sizer
        r1Sizer.Add(directories, 1, wx.EXPAND)
        # If Mac ...
        if 'wxMac' in wx.PlatformInfo:
            # ... add a spacer to avoid control clipping
            r1Sizer.Add((2, 0))

        # 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 label for the list of Files
        label = wx.StaticText(self.panel, -1, _('Selected Files:'))
        # Create a HORIZONTAL sizer for the next row
        r2Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Add the element to the sizer
        r2Sizer.Add(label, 0)

        # For Audio Extraction (waveform creation) ...
        if self.mode == "waveform":
            # ... create a checkbox for overwriting files
            self.overwrite = wx.CheckBox(self.panel, -1,
                                         _('Overwrite existing wave files?'))
            # place an option to overwrite existing wave files to the upper-right
            # of the ListBox.

            # Add a horizontal spacer to the row sizer
            r2Sizer.Add((10, 0), 1, wx.EXPAND)

            # Add the element to the sizer
            r2Sizer.Add(self.overwrite, 0, wx.ALIGN_RIGHT)

        # 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
        r3Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Create the List of Files listbox
        self.fileList = wx.ListBox(self.panel, -1, style=wx.LB_MULTIPLE)
        # Add the element to the sizer
        r3Sizer.Add(self.fileList, 1, wx.EXPAND)

        # Add the row sizer to the main vertical sizer
        mainSizer.Add(r3Sizer, 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)

        # Create a Remove Files button
        remfile = wx.Button(self.panel, wx.ID_FILE3,
                            _("Remove Selected File(s)"), wx.DefaultPosition)
        # If Mac ...
        if 'wxMac' in wx.PlatformInfo:
            # ... add a spacer to avoid control clipping
            btnSizer.Add((2, 0))
        # Add the element to the Button Sizer
        btnSizer.Add(remfile, 0)

        # 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))

        # Bind the events that we'll need.
        wx.EVT_BUTTON(self, wx.ID_FILE1, self.OnBrowse)
        wx.EVT_BUTTON(self, wx.ID_FILE2, self.BrowseDirectories)
        wx.EVT_BUTTON(self, wx.ID_FILE3, self.RemoveSelected)

        # 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(500, width), max(500, height)))
        # Define the minimum size for this dialog as the current size, and define height as unchangeable
        self.SetSizeHints(max(500, width), max(500, height))
        # Center the form on screen
        TransanaGlobal.CenterOnPrimary(self)
        # Initialize the dictionary of running conversions
        self.runningConversions = {}
        # Initialize the process variable
        self.process = None
Esempio n. 19
0
    def __init__(self, parent, defaultKWGroup=None, deleteEnabled=True):
        """Initialize a KWManager object."""
        # Remember the value for deleteEnabled
        self.deleteEnabled = deleteEnabled
        wx.Dialog.__init__(self, parent, -1, _("Keyword Management"), wx.DefaultPosition, wx.Size(550,420), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

        # To look right, the Mac needs the Small Window Variant.
        if "__WXMAC__" in wx.PlatformInfo:
            self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)

        # Define the minimum size for this dialog as the initial size
        self.SetSizeHints(550, 420)

        # Create the form's main VERTICAL sizer
        mainSizer = wx.BoxSizer(wx.VERTICAL)

        # Keyword Group
        txt = wx.StaticText(self, -1, _("Keyword Group"))
        mainSizer.Add(txt, 0, wx.LEFT | wx.RIGHT | wx.TOP, 10)
        mainSizer.Add((0, 3))

        # Create a HORIZONTAL sizer for the first row
        r1Sizer = wx.BoxSizer(wx.HORIZONTAL)

        self.kw_group = wx.Choice(self, 101, wx.DefaultPosition, wx.DefaultSize, [])
        r1Sizer.Add(self.kw_group, 5, wx.EXPAND)
        wx.EVT_CHOICE(self, 101, self.OnGroupSelect)

        r1Sizer.Add((10, 0))

        # Create a new Keyword Group button
        new_kwg = wx.Button(self, wx.ID_FILE1, _("Create a New Keyword Group"))
        r1Sizer.Add(new_kwg, 3, wx.EXPAND)
        wx.EVT_BUTTON(self, wx.ID_FILE1, self.OnNewKWG)

        mainSizer.Add(r1Sizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, 10)

        mainSizer.Add((0, 10))

        # Keywords label+listbox
        txt = wx.StaticText(self, -1, _("Keywords"))
        mainSizer.Add(txt, 0, wx.LEFT, 10)

        # Create a HORIZONTAL sizer for the first row
        r2Sizer = wx.BoxSizer(wx.HORIZONTAL)

        v1 = wx.BoxSizer(wx.VERTICAL)
        if 'wxMac' in wx.PlatformInfo:
            style=wx.LB_SINGLE
        else:
            style=wx.LB_SINGLE | wx.LB_SORT
        self.kw_lb = wx.ListBox(self, 100, wx.DefaultPosition, wx.DefaultSize, [], style=style)
        v1.Add(self.kw_lb, 1, wx.EXPAND)
        wx.EVT_LISTBOX(self, 100, self.OnKeywordSelect)
        wx.EVT_LISTBOX_DCLICK(self, 100, self.OnKeywordDoubleClick)

        r2Sizer.Add(v1, 5, wx.EXPAND)
        r2Sizer.Add((10, 0))

        v2 = wx.BoxSizer(wx.VERTICAL)
        # Add Keyword to List button
        add_kw = wx.Button(self, wx.ID_FILE2, _("Add Keyword to List"))
        v2.Add(add_kw, 0, wx.EXPAND | wx.BOTTOM, 10)
        wx.EVT_BUTTON(self, wx.ID_FILE2, self.OnAddKW)

        # Edit Keyword button
        self.edit_kw = wx.Button(self, -1, _("Edit Keyword"))
        v2.Add(self.edit_kw, 0, wx.EXPAND | wx.BOTTOM, 10)
        wx.EVT_BUTTON(self, self.edit_kw.GetId(), self.OnEditKW)
        self.edit_kw.Enable(False)
        
        # Delete Keyword from List button
        self.del_kw = wx.Button(self, wx.ID_FILE3, _("Delete Keyword from List"))
        v2.Add(self.del_kw, 0, wx.EXPAND | wx.BOTTOM, 10)
        wx.EVT_BUTTON(self, wx.ID_FILE3, self.OnDelKW)
        self.del_kw.Enable(False)
        

        # Definition box
        def_txt = wx.StaticText(self, -1, _("Definition"))
        v2.Add(def_txt, 0, wx.BOTTOM, 3)
        
        self.definition = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE)
        v2.Add(self.definition, 1, wx.EXPAND | wx.BOTTOM, 10)
        self.definition.Enable(False)

        btnSizer = wx.BoxSizer(wx.HORIZONTAL)        
        # Dialog Close button
        close = wx.Button(self, wx.ID_CLOSE, _("Close"))
        btnSizer.Add(close, 1, wx.EXPAND | wx.RIGHT, 10)
        close.SetDefault()
        wx.EVT_BUTTON(self, wx.ID_CLOSE, self.OnClose)

        # We don't want to use wx.ID_HELP here, as that causes the Help buttons to be replaced with little question
        # mark buttons on the Mac, which don't look good.
        ID_HELP = wx.NewId()

        # Dialog Help button
        helpBtn = wx.Button(self, ID_HELP, _("Help"))
        btnSizer.Add(helpBtn, 1, wx.EXPAND)
        wx.EVT_BUTTON(self, ID_HELP, self.OnHelp)

        v2.Add(btnSizer, 0, wx.EXPAND)

        r2Sizer.Add(v2, 3, wx.EXPAND)

        mainSizer.Add(r2Sizer, 1, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

        self.SetSizer(mainSizer)
        self.SetAutoLayout(True)
        self.Layout()
        TransanaGlobal.CenterOnPrimary(self)

        self.kw_groups = DBInterface.list_of_keyword_groups()
        for kwg in self.kw_groups:
            self.kw_group.Append(kwg)

        if len(self.kw_groups) > 0:
            if defaultKWGroup != None:
                selPos = self.kw_group.FindString(defaultKWGroup)
            else:
                selPos = 0
            self.kw_group.SetSelection(selPos)
            self.kw_list = DBInterface.list_of_keywords_by_group(self.kw_group.GetString(selPos))
        else:
            self.kw_list = []

        for kw in self.kw_list:
            self.kw_lb.Append(kw)
            
        if len(self.kw_list) > 0:
            self.kw_lb.SetSelection(0, False)

        self.ShowModal()
Esempio n. 20
0
    def __init__(self, parent, title, fileName, localDir, remoteDir,
                 direction):
        """ Set up the Dialog Box and all GUI Widgets. """
        # Initialize the last update time
        self.lastUpdate = time.time()

        # Set up local variables
        self.parent = parent

        size = (350, 200)
        # Create the Dialog Box itself, with no minimize/maximize/close buttons
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           title,
                           size=size,
                           style=wx.CAPTION)

        # Create a main VERTICAL sizer for the form
        mainSizer = wx.BoxSizer(wx.VERTICAL)

        # File label
        if 'unicode' in wx.PlatformInfo:
            # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
            prompt = unicode(_("File: %s"), 'utf8')
        else:
            prompt = _("File: %s")
        self.lblFile = wx.StaticText(self,
                                     -1,
                                     prompt % fileName,
                                     style=wx.ST_NO_AUTORESIZE)
        # Add the label to the Main Sizer
        mainSizer.Add(self.lblFile, 0, wx.ALL, 10)

        # Progress Bar
        self.progressBar = wx.Gauge(self,
                                    -1,
                                    100,
                                    style=wx.GA_HORIZONTAL | wx.GA_SMOOTH)
        # Add the element to the Main Sizer
        mainSizer.Add(self.progressBar, 1,
                      wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

        # Create a Row Sizer
        r1Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Bytes Transferred label
        if 'unicode' in wx.PlatformInfo:
            # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
            prompt = unicode(_("%d bytes of %d transferred"), 'utf8')
        else:
            prompt = _("%d bytes of %d transferred")
        self.lblBytes = wx.StaticText(self,
                                      -1,
                                      prompt % (100000000, 100000000),
                                      style=wx.ST_NO_AUTORESIZE)
        # Add the label to the Row Sizer
        r1Sizer.Add(self.lblBytes, 5, wx.EXPAND)

        # Percent Transferred label
        self.lblPercent = wx.StaticText(self,
                                        -1,
                                        "%5.1d %%" % 1000.1,
                                        style=wx.ST_NO_AUTORESIZE
                                        | wx.ALIGN_RIGHT)
        # Add the Element to the Row Sizer
        r1Sizer.Add(self.lblPercent, 1, wx.ALIGN_RIGHT)

        # Add the Row Sizer to the Main Sizer
        mainSizer.Add(r1Sizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
                      10)

        # Create a Row Sizer
        r2Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Elapsed Time label
        if 'unicode' in wx.PlatformInfo:
            # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
            prompt = unicode(_("Elapsed Time: %d:%02d:%02d"), 'utf8')
        else:
            prompt = _("Elapsed Time: %d:%02d:%02d")
        self.lblElapsedTime = wx.StaticText(self,
                                            -1,
                                            prompt % (0, 0, 0),
                                            style=wx.ST_NO_AUTORESIZE)
        # Add the element to the Row Sizer
        r2Sizer.Add(self.lblElapsedTime, 0)

        # Add a spacer
        r2Sizer.Add((1, 0), 1, wx.EXPAND)

        # Remaining Time label
        if 'unicode' in wx.PlatformInfo:
            # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
            prompt = unicode(_("Time Remaining: %d:%02d:%02d"), 'utf8')
        else:
            prompt = _("Time Remaining: %d:%02d:%02d")
        self.lblTimeRemaining = wx.StaticText(self,
                                              -1,
                                              prompt % (0, 0, 0),
                                              style=wx.ST_NO_AUTORESIZE
                                              | wx.ALIGN_RIGHT)
        # Add the element to the Row Sizer
        r2Sizer.Add(self.lblTimeRemaining, 0)

        # Add the Row Sizer to the Main Sizer
        mainSizer.Add(r2Sizer, 0, wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM,
                      10)

        # Transfer Speed label
        if 'unicode' in wx.PlatformInfo:
            # Encode with UTF-8 rather than TransanaGlobal.encoding because this is a prompt, not DB Data.
            prompt = unicode(_("Transfer Speed: %d k/sec"), 'utf8')
        else:
            prompt = _("Transfer Speed: %d k/sec")
        self.lblTransferSpeed = wx.StaticText(self,
                                              -1,
                                              prompt % 0,
                                              style=wx.ST_NO_AUTORESIZE)
        # Add the element to the Main Sizer
        mainSizer.Add(self.lblTransferSpeed, 0,
                      wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

        # Cancel Button
        self.btnCancel = wx.Button(self, wx.ID_CANCEL,
                                   _("Cancel Remaining Files"))
        # Add the element to the Main Sizer
        mainSizer.Add(self.btnCancel, 0,
                      wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnCancel)

        # Attach the main sizer to the form
        self.SetSizer(mainSizer)
        # Turn Auto Layout on
        self.SetAutoLayout(True)
        # Lay out the form
        self.Layout()
        # Center on the Screen
        TransanaGlobal.CenterOnPrimary(self)
        # Show the form
        self.Show()
        # make sure the loca directory ends with the proper path seperator character
        if localDir[-1] != os.sep:
            localDir = localDir + os.sep
        # Initialize variables used in file transfer
        BytesRead = 0
        # "cancelled" is intialized to false.  If the user cancels the file transfer,
        # this variable gets set to true to signal the need to interrupt the transfer.
        self.cancelled = False
        # Note the starting time of the transfer for progress reporting purposes
        self.StartTime = time.time()

        # If we are sending files from the sFTP Server to the local File System...
        if direction == sFTP_DOWNLOAD:
            self.SetTitle(_('Downloading . . .'))

            try:
                FileResult = parent.sFTPClient.get(
                    string.join([remoteDir, fileName], '/'),
                    os.path.join(localDir, fileName),
                    callback=self.UpdateDisplay)
            except IOError:
                prompt = unicode(_("Input / Output Error"),
                                 'utf8') + "\n%s\n" + unicode(
                                     _('Please press "Refresh".'), 'utf8')
                dlg = Dialogs.ErrorDialog(self, prompt % (sys.exc_info()[1]))
                dlg.ShowModal()
                dlg.Destroy()

        # If we are sending data from the local file system to the sFTP Server ...
        elif direction == sFTP_UPLOAD:
            self.SetTitle(_('Uploading . . .'))

            try:
                # Detect Strings (instead of Unicode objects) and decode them if needed.
                if isinstance(localDir, str):
                    localDir = localDir.decode(TransanaGlobal.encoding)
                if isinstance(remoteDir, str):
                    remoteDir = remoteDir.decode(TransanaGlobal.encoding)
                # Put the file and capture the result
                FileResult = parent.sFTPClient.put(
                    os.path.join(localDir, fileName),
                    string.join([remoteDir, fileName], '/'),
                    callback=self.UpdateDisplay)
            except IOError:
                prompt = unicode(_("Input / Output Error"),
                                 'utf8') + "\n%s\n" + unicode(
                                     _('Please press "Refresh".'), 'utf8')
                dlg = Dialogs.ErrorDialog(self, prompt % (sys.exc_info()[1]))
                dlg.ShowModal()
                dlg.Destroy()
Esempio n. 21
0
    def __init__(self,
                 parent,
                 msg,
                 header=_("Transana Confirmation"),
                 noDefault=False,
                 useOkCancel=False,
                 yesToAll=False,
                 includeEncoding=False):
        """ QuestionDialog Parameters:
                parent           Parent Window
                msg              Message to display
                header           Dialog box header, "Transana Confirmation" by default
                noDefault        Set the No or Cancel button as the default, instead of Yes or OK
                useOkCancel      Use OK / Cancel as the button labels rather than Yes / No
                yesToAll         Include the "Yes to All" option
                includeEncoding  Include Encoding selection for upgrading the single-user Windows database for 2.50 """

        # This should be easy, right?  Just use the OS MessageDialog like so:
        # wx.MessageDialog.__init__(self, parent, msg, _("Transana Information"), \
        #                     wx.OK | wx.CENTRE | wx.ICON_INFORMATION)
        # That's all there is to it, right?
        #
        # Yeah, right.  Unfortunately, on Windows, the MessageDialog isn't TRULY modal.  It's modal to the parent window
        # it's called from, but you can still select one of the other Transana Windows and do stuff.  This message
        # can even get hidden behind other windows, and cause all kinds of problems.  According to Robin Dunn,
        # writing my own class to do this is the only solution.

        # Set the default result to indicate failure
        self.result = -1
        # Remember the noDefault setting
        self.noDefault = noDefault
        # Remember if Encoding is included
        self.includeEncoding = includeEncoding
        # Define the default Window style
        dlgStyle = wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP

        # Create a small dialog box
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           header,
                           size=(350, 150),
                           style=dlgStyle)
        # Create a main vertical sizer
        box = wx.BoxSizer(wx.VERTICAL)
        # Create a horizontal sizer for the first row
        box2 = wx.BoxSizer(wx.HORIZONTAL)
        # Create a horizontal sizer for the buttons
        boxButtons = wx.BoxSizer(wx.HORIZONTAL)

        # Create an empty bitmap for the question mark graphic
        bitmap = wx.EmptyBitmap(32, 32)
        # Create a bitmap screen object for the graphic
        graphic = wx.StaticBitmap(self, -1,
                                  TransanaImages.ArtProv_QUESTION.GetBitmap())
        # Add the graphic to the first row horizontal sizer
        box2.Add(graphic, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, 10)

        # Create a text screen object for the dialog text
        message = wx.StaticText(self, -1, msg)
        # Add it to the first row sizer
        box2.Add(
            message, 0,
            wx.EXPAND | wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
            10)
        # Add the first row to the main sizer
        box.Add(box2, 0, wx.EXPAND)

        # Determine the appropriate text and ID values for the buttons.
        # if useOkCancel is True ...
        if useOkCancel:
            # ... set the buttons to OK and Cancel
            btnYesText = _("OK")
            btnYesID = wx.ID_OK
            btnNoText = _("Cancel")
            btnNoID = wx.ID_CANCEL
        # If useOkCancel is False (the default) ...
        else:
            # ... set the buttons to Yes and No
            btnYesText = _("&Yes")
            btnYesID = wx.ID_YES
            btnNoText = _("&No")
            btnNoID = wx.ID_NO
        # Create the first button, which is Yes or OK
        btnYes = wx.Button(self, btnYesID, btnYesText)
        # Bind the button event to its method
        btnYes.Bind(wx.EVT_BUTTON, self.OnButton)

        # If the "Yes to All" option is enabled
        if yesToAll:
            # ... create a YesToAll ID
            self.YESTOALLID = wx.NewId()
            # Create a Yes To All button
            self.btnYesToAll = wx.Button(self, self.YESTOALLID,
                                         _("Yes to All"))
            # Bind the button handler for the Yes To All button
            self.btnYesToAll.Bind(wx.EVT_BUTTON, self.OnButton)

        # Create the second button, which is No or Cancel
        self.btnNo = wx.Button(self, btnNoID, btnNoText)
        # Bind the button event to its method
        self.btnNo.Bind(wx.EVT_BUTTON, self.OnButton)
        # Add an expandable spacer to the button sizer
        boxButtons.Add((20, 1), 1)
        # If we're on the Mac, we want No/Cancel then Yes/OK
        if "__WXMAC__" in wx.PlatformInfo:
            # Add No first
            boxButtons.Add(self.btnNo, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10)
            # Add a spacer
            boxButtons.Add((20, 1))
            # If the "Yes to All" option is enabled
            if yesToAll:
                # Add No first
                boxButtons.Add(self.btnYesToAll, 0,
                               wx.ALIGN_CENTER | wx.BOTTOM, 10)
                # Add a spacer
                boxButtons.Add((20, 1))
            # Then add Yes
            boxButtons.Add(btnYes, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10)
        # If we're not on the Mac, we want Yes/OK then No/Cancel
        else:
            # Add Yes first
            boxButtons.Add(btnYes, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10)
            # Add a spacer
            boxButtons.Add((20, 1))
            # If the "Yes to All" option is enabled
            if yesToAll:
                # Add No first
                boxButtons.Add(self.btnYesToAll, 0,
                               wx.ALIGN_CENTER | wx.BOTTOM, 10)
                # Add a spacer
                boxButtons.Add((20, 1))
            # Then add No
            boxButtons.Add(self.btnNo, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10)
        # Add a final expandable spacer
        boxButtons.Add((20, 1), 1)
        # Add the button bar to the main sizer
        box.Add(boxButtons, 0, wx.ALIGN_CENTER | wx.EXPAND)

        # If we're supposed to include the Encoding prompt ...
        if includeEncoding:
            # Create a horizontal sizer for the first row
            box3 = wx.BoxSizer(wx.HORIZONTAL)
            # Define the options for the Encoding choice box
            choices = [
                '',
                _('Most languages from single-user Transana 2.1 - 2.42 on Windows'
                  ),
                _('Chinese from single-user Transana 2.1 - 2.42 on Windows'),
                _('Russian from single-user Transana 2.1 - 2.42 on Windows'),
                _('Eastern European data from single-user Transana 2.1 - 2.42 on Windows'
                  ),
                _('Greek data from single-user Transana 2.1 - 2.42 on Windows'
                  ),
                _('Japanese data from single-user Transana 2.1 - 2.42 on Windows'
                  ),
                _("All languages from OS X or MU database files")
            ]
            # Use a dictionary to define the encodings that go with each of the Encoding options
            self.encodingOptions = {
                '':
                None,
                _('Most languages from single-user Transana 2.1 - 2.42 on Windows'):
                'latin1',
                _('Chinese from single-user Transana 2.1 - 2.42 on Windows'):
                'gbk',
                _('Russian from single-user Transana 2.1 - 2.42 on Windows'):
                'koi8_r',
                _('Eastern European data from single-user Transana 2.1 - 2.42 on Windows'):
                'iso8859_2',
                _('Greek data from single-user Transana 2.1 - 2.42 on Windows'):
                'iso8859_7',
                _('Japanese data from single-user Transana 2.1 - 2.42 on Windows'):
                'cp932',
                _("All languages from OS X or MU database files"):
                'utf8'
            }
            # Create a Choice Box where the user can select an import encoding, based on information about how the
            # Transana-XML file in question was created.  This adds it to the Vertical Sizer created above.
            chLbl = wx.StaticText(self, -1, _('Language Option used:'))
            box3.Add(chLbl, 0, wx.LEFT | wx.TOP | wx.BOTTOM, 10)
            self.chImportEncoding = wx.Choice(self, -1, choices=choices)
            self.chImportEncoding.SetSelection(0)
            box3.Add(
                self.chImportEncoding, 1, wx.EXPAND | wx.ALIGN_CENTER
                | wx.ALIGN_CENTER_VERTICAL | wx.ALL, 10)
            box.Add(box3, 0, wx.EXPAND)

        # Turn AutoLayout On
        self.SetAutoLayout(True)
        # Set the form's main sizer
        self.SetSizer(box)
        # Fit the form
        self.Fit()
        # Lay the form out
        self.Layout()
        # Center the form on screen
        #        self.CentreOnScreen()
        # That's not working.  Let's try this ...
        TransanaGlobal.CenterOnPrimary(self)
Esempio n. 22
0
    def __init__(self, parent, id, title, coll_object):
        self.width = 400
        self.height = 210
        # Make the Keyword Edit List resizable by passing wx.RESIZE_BORDER style
        Dialogs.GenForm.__init__(self,
                                 parent,
                                 id,
                                 title, (self.width, self.height),
                                 style=wx.DEFAULT_DIALOG_STYLE
                                 | wx.RESIZE_BORDER,
                                 useSizers=True,
                                 HelpContext='Collection Properties')

        self.obj = coll_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)
        # Collection ID
        id_edit = self.new_edit_box(_("Collection ID"),
                                    v1,
                                    self.obj.id,
                                    maxLen=100)
        # Add the element to the row 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)
        # Owner
        owner_edit = self.new_edit_box(_("Owner"),
                                       v2,
                                       self.obj.owner,
                                       maxLen=100)
        # Add the element to the row sizer
        r1Sizer.Add(v2, 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
        v3 = wx.BoxSizer(wx.VERTICAL)
        # Comment
        comment_edit = self.new_edit_box(_("Comment"),
                                         v3,
                                         self.obj.comment,
                                         maxLen=255)
        # Add the element to the row sizer
        r2Sizer.Add(v3, 1, wx.EXPAND)

        # 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
        r3Sizer = wx.BoxSizer(wx.HORIZONTAL)

        # Create a VERTICAL sizer for the next element
        v4 = wx.BoxSizer(wx.VERTICAL)
        # Default KW Group
        self.kw_groups = DBInterface.list_of_keyword_groups()
        self.kwg_choice = self.new_choice_box(_("Default Keyword Group"), v4,
                                              [""] + self.kw_groups, 0)
        # Add the element to the row sizer
        r3Sizer.Add(v4, 1, wx.EXPAND)
        if (self.obj.keyword_group) and (self.kwg_choice.FindString(
                self.obj.keyword_group) != wx.NOT_FOUND):
            self.kwg_choice.SetStringSelection(self.obj.keyword_group)
        else:
            self.kwg_choice.SetSelection(0)

        if self.obj.parent <> 0:
            # Add a horizontal spacer to the row sizer
            r3Sizer.Add((10, 0))

            # Create a VERTICAL sizer for the next element
            v5 = wx.BoxSizer(wx.VERTICAL)
            # Parent Collection Name
            coll_parent_edit = self.new_edit_box(_("Parent Collection"), v5,
                                                 self.obj.parentName)
            # Add the element to the row sizer
            r3Sizer.Add(v5, 1, wx.EXPAND)
            coll_parent_edit.Enable(False)

        # 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 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(self.width, width), height))
        # Define the minimum size for this dialog as the current size, and define height as unchangeable
        self.SetSizeHints(max(self.width, width), height, -1, height)
        # Center the form on screen
        TransanaGlobal.CenterOnPrimary(self)

        # Set focus to Series ID
        id_edit.SetFocus()
Esempio n. 23
0
    def __init__(self,
                 parent,
                 errmsg,
                 dlgCaption=_("Transana Error"),
                 includeSkipCheck=False):
        # This should be easy, right?  Just use the OS MessageDialog like so:
        # wx.MessageDialog.__init__(self, parent, errmsg, _("Transana Error"), wx.OK | wx.CENTRE | wx.ICON_ERROR)
        # That's all there is to it, right?
        #
        # Yeah, right.  Unfortunately, on Windows, this dialog isn't TRULY modal.  It's modal to the parent window
        # it's called from, but you can still select one of the other Transana Windows and do stuff.  This message
        # can even get hidden behind other windows, and cause all kinds of problems.  According to Robin Dunn,
        # writing my own class to do this is the only solution.  Here goes.

        # Remember if we're supposed to include the checkbox to skip additional messages
        self.includeSkipCheck = includeSkipCheck

        # Create a Dialog box
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           dlgCaption,
                           size=(350, 150),
                           style=wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP)
        # Set "Window Variant" to small only for Mac to make fonts match better
        if "__WXMAC__" in wx.PlatformInfo:
            self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)

        # Create Vertical and Horizontal Sizers
        box = wx.BoxSizer(wx.VERTICAL)
        box2 = wx.BoxSizer(wx.HORIZONTAL)

        # Display the Error graphic in the dialog box
        graphic = wx.StaticBitmap(self, -1,
                                  TransanaImages.ArtProv_ERROR.GetBitmap())
        # Add the graphic to the Sizers
        box2.Add(graphic, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, 10)

        # Display the error message in the dialog box
        message = wx.StaticText(self, -1, errmsg)
        # Add the error message to the Sizers
        box2.Add(
            message, 0,
            wx.EXPAND | wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL | wx.ALL,
            10)
        box.Add(box2, 0, wx.EXPAND)

        # If we should add the "Skip Further messages" checkbox ...
        if self.includeSkipCheck:
            # ... then add the checkbox to the dialog
            self.skipCheck = wx.CheckBox(self, -1,
                                         _('Do not show this message again'))
            # ... and add the checkbox to the Sizers
            box.Add(self.skipCheck, 0, wx.ALIGN_CENTER | wx.ALL, 10)

        # Add an OK button
        btnOK = wx.Button(self, wx.ID_OK, _("OK"))
        # Add the OK button to the Sizers
        box.Add(btnOK, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10)
        # Make the OK button the default
        self.SetDefaultItem(btnOK)

        # Turn on Auto Layout
        self.SetAutoLayout(True)
        # Set the form sizer
        self.SetSizer(box)
        # Set the form size
        self.Fit()
        # Perform the Layout
        self.Layout()
        # Center the dialog on the screen
        #        self.CentreOnScreen()
        # That's not working.  Let's try this ...
        TransanaGlobal.CenterOnPrimary(self)
Esempio n. 24
0
    def __init__(self,parent,id,seriesNum=0, episodeNum=0, collectionNum=0):
        # Remember the Library, episode or collection that triggered creation of this export
        self.seriesNum = seriesNum
        self.episodeNum = episodeNum
        self.collectionNum = collectionNum

        # Set the encoding for export.
        # Use UTF-8 regardless of the current encoding for consistency in the Transana XML files
        EXPORT_ENCODING = 'utf8'

        # Create a form to get the name of the file to receive the data
        # Define the form title
        title = _("Transana Selective Data Export")
        Dialogs.GenForm.__init__(self, parent, id, title, (550,150), style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER,
                                 useSizers = True, HelpContext='Selective Data Export')
	# Create an invisible instance of RichTextEditCtrl. This allows us to
	# get away with converting fastsaved documents to RTF behind the scenes.
	# Then we can simply pull the RTF data out of this object and write it
	# to the desired file.
	self.invisibleSTC = RichTextEditCtrl(self)
	self.invisibleSTC.Show(False)

        # 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)

        # Export Message
        # If the XML filename path is not empty, we need to tell the user.
        prompt = _('Please create an Transana XML File for export.')
        exportText = wx.StaticText(self.panel, -1, prompt)

        # Add the export message to the dialog box
        r1Sizer.Add(exportText, 0)

        # 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
        v1 = wx.BoxSizer(wx.VERTICAL)
        # Export Filename Layout
        self.XMLFile = self.new_edit_box(_("Transana Export XML-Filename"), lay, '')
        self.XMLFile.SetDropTarget(EditBoxFileDropTarget(self.XMLFile))
        # Add the element sizer to the row sizer
        r2Sizer.Add(v1, 1, wx.EXPAND)

        # Add a spacer to the row sizer        
        r2Sizer.Add((10, 0))

        # Browse button
        browse = wx.Button(self.panel, wx.ID_FILE1, _("Browse"), wx.DefaultPosition)
        wx.EVT_BUTTON(self, wx.ID_FILE1, self.OnBrowse)
        # Add the element to the row sizer
        r2Sizer.Add(browse, 0, wx.ALIGN_BOTTOM)

        # 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 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(550, width), height))
        # Define the minimum size for this dialog as the current size, and define height as unchangeable
        self.SetSizeHints(max(550, width), height, -1, height)
        # Center the form on screen
        TransanaGlobal.CenterOnPrimary(self)
        # Set focus to the XML file field
        self.XMLFile.SetFocus()
Esempio n. 25
0
    def __init__(self,
                 parent,
                 label='',
                 clipStart=0,
                 clipDuration=0,
                 showModally=True):
        """ Initialize the Progress Dialog """

        # There's a bug.  I think it's an interaction between OS X 10.7.5 and earlier (but not 10.8.4), wxPython (version
        # unknown, but I've seen it in 2.8.12.1, 2.9.4.0, and a pre-release build of 2.9.5.0), and the build process.
        # Basically, if you open a wxFileDialog object, something bad happens with wxLocale such that subsequent calls
        # to wxProcess don't encode unicode file names correctly, so FFMpeg fails.  Only OS X 10.7.5, only when Transana
        # has been built (not running through the interpreter), only following the opening of a wxFileDialog, and only
        # with filenames with accented characters or characters from non-English languages.

        # The resolution to this bug is to reset the Locale here, based on Transana's current wxLocale setting in the
        # menuWindow object.
        self.locale = wx.Locale(TransanaGlobal.menuWindow.locale.Language)

        # Remember the Parent
        self.parent = parent
        # Remember whether we're MODAL or ALLOWING MULTIPLE THREADS
        self.showModally = showModally
        # Remember the start time and duration, if they are passed in.
        self.clipStart = clipStart
        self.clipDuration = clipDuration

        # Define the process variable
        self.process = None
        # Initialize a list to collect error messages
        self.errorMessages = []

        # Encode the prompt
        prompt = unicode(_('Media File Conversion Progress'), 'utf8')
        # Define the Dialog Box.  wx.STAY_ON_TOP required because this dialog can't be modal, but shouldn't be hidden or worked behind.
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           prompt,
                           size=(400, 160),
                           style=wx.CAPTION | wx.STAY_ON_TOP)

        # To look right, the Mac needs the Small Window Variant.
        if "__WXMAC__" in wx.PlatformInfo:
            self.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)

        # Create the main Sizer, which is Vertical
        sizer = wx.BoxSizer(wx.VERTICAL)
        # Create a horizontal sizer for the text below the progress bar.
        timeSizer = wx.BoxSizer(wx.HORIZONTAL)

        # For now, place an empty StaticText label on the Dialog
        self.lbl = wx.StaticText(self, -1, label)
        sizer.Add(self.lbl, 0, wx.ALIGN_LEFT | wx.ALL, 10)

        # Progress Bar
        self.progressBar = wx.Gauge(self,
                                    -1,
                                    100,
                                    style=wx.GA_HORIZONTAL | wx.GA_SMOOTH)
        sizer.Add(self.progressBar, 0,
                  wx.ALIGN_CENTER | wx.LEFT | wx.RIGHT | wx.EXPAND, 10)

        # Seconds Processed label
        # Encode the prompt
        prompt = unicode(_("%d:%02d:%02d of %d:%02d:%02d processed"), 'utf8')
        self.lblTime = wx.StaticText(self,
                                     -1,
                                     prompt % (0, 0, 0, 0, 0, 0),
                                     style=wx.ST_NO_AUTORESIZE)
        timeSizer.Add(self.lblTime, 0,
                      wx.ALIGN_LEFT | wx.LEFT | wx.RIGHT | wx.TOP, 10)
        timeSizer.Add((0, 5), 1, wx.EXPAND)

        # Percent Processed label
        self.lblPercent = wx.StaticText(self,
                                        -1,
                                        "%3d %%" % 0,
                                        style=wx.ST_NO_AUTORESIZE
                                        | wx.ALIGN_RIGHT)
        timeSizer.Add(self.lblPercent, 0,
                      wx.ALIGN_RIGHT | wx.LEFT | wx.RIGHT | wx.TOP, 10)
        sizer.Add(timeSizer, 1, wx.EXPAND)

        elapsedSizer = wx.BoxSizer(wx.HORIZONTAL)

        # Time Elapsed label
        # Encode the prompt
        prompt = unicode(_("%s elapsed"), 'utf8')
        self.lblElapsed = wx.StaticText(self,
                                        -1,
                                        prompt % '0:00:00',
                                        style=wx.ST_NO_AUTORESIZE
                                        | wx.ALIGN_LEFT)
        elapsedSizer.Add(self.lblElapsed, 0, wx.ALIGN_LEFT | wx.LEFT, 10)
        elapsedSizer.Add((0, 5), 1, wx.EXPAND)

        # Time Remaining label
        # Encode the prompt
        prompt = unicode(_("%s remaining"), 'utf8')
        self.lblRemaining = wx.StaticText(self,
                                          -1,
                                          prompt % '0:00:00',
                                          style=wx.ST_NO_AUTORESIZE
                                          | wx.ALIGN_RIGHT)
        elapsedSizer.Add(self.lblRemaining, 0, wx.ALIGN_RIGHT | wx.RIGHT, 10)
        sizer.Add(elapsedSizer, 1, wx.EXPAND | wx.BOTTOM, 4)

        # Cancel button
        # Encode the prompt
        prompt = unicode(_("Cancel"), 'utf8')
        self.btnCancel = wx.Button(self, -1, prompt)
        sizer.Add(self.btnCancel, 0, wx.ALIGN_CENTER | wx.BOTTOM, 10)
        self.btnCancel.Bind(wx.EVT_BUTTON, self.OnInterrupt)

        self.SetSizer(sizer)
        # Set this as the minimum size for the form.
        sizer.SetMinSize(wx.Size(350, 160))
        # Call Layout to "place" the widgits
        self.Layout()
        self.SetAutoLayout(True)
        self.Fit()

        # Create a Timer that will check for progress feedback
        self.timer = wx.Timer()
        self.timer.Bind(wx.EVT_TIMER, self.OnTimer)

        TransanaGlobal.CenterOnPrimary(self)