Beispiel #1
0
	def _processNewItem(self, itm, daboItem):
		"""After a menu item is created, perform any platform-specific handling."""
		id_ = itm.GetId()
		if id_ == wx.ID_ABOUT:
			# Put the about menu in the App Menu on Mac
			wx.App_SetMacAboutMenuItemId(id_)
			cap = daboItem.Parent.Caption
			wx.App_SetMacHelpMenuTitleName(cap)

		# Process any 'special' menus
		try:
			special = daboItem._special
		except AttributeError:
			return
		if special == "pref":
			# Put the prefs item in the App Menu on Mac
			self.Parent._mac_pref_menu_item_id = id_
			wx.App_SetMacPreferencesMenuItemId(id_)
Beispiel #2
0
    def __init__(self):
        # Create a Menu Bar
        wx.MenuBar.__init__(self)

        # Build the File menu
        self.filemenu = wx.Menu()
        self.filemenu.Append(MENU_FILE_NEW, _("&New"))
        self.filemenu.Append(MENU_FILE_NEWDATABASE, _("&Change Database"))
        self.filemenu.Append(MENU_FILE_FILEMANAGEMENT, _("File &Management"))
        self.filemenu.AppendSeparator()
        self.filemenu.Append(MENU_FILE_SAVE, _("&Save Document"))
        self.filemenu.Append(MENU_FILE_SAVEAS, _("Save Document &As"))
        self.filemenu.AppendSeparator()
        self.filemenu.Append(MENU_FILE_PRINTTRANSCRIPT, _("&Print Document"))
        self.filemenu.Append(MENU_FILE_PRINTERSETUP, _("P&rinter Setup"))
        self.filemenu.AppendSeparator()
        self.filemenu.Append(MENU_FILE_CLOSE_SNAPSHOTS,
                             _("Close All Snapshots"))
        self.filemenu.Append(MENU_FILE_CLOSE_REPORTS, _("Close All Reports"))
        self.filemenu.Append(MENU_FILE_EXIT, _("E&xit"))
        self.Append(self.filemenu, _("&File"))

        # Build the Document menu
        self.transcriptmenu = wx.Menu()
        self.transcriptmenu.Append(MENU_TRANSCRIPT_EDIT_UNDO,
                                   _("&Undo\tCtrl-Z"))
        self.transcriptmenu.Append(MENU_TRANSCRIPT_EDIT_CUT, _("Cu&t\tCtrl-X"))
        self.transcriptmenu.Append(MENU_TRANSCRIPT_EDIT_COPY,
                                   _("&Copy\tCtrl-C"))
        self.transcriptmenu.Append(MENU_TRANSCRIPT_EDIT_PASTE,
                                   _("&Paste\tCtrl-V"))
        self.transcriptmenu.AppendSeparator()
        self.transcriptmenu.Append(MENU_TRANSCRIPT_FONT, _("Format &Font"))
        if TransanaConstants.USESRTC:
            self.transcriptmenu.Append(MENU_TRANSCRIPT_PARAGRAPH,
                                       _("Format Paragrap&h"))
            self.transcriptmenu.Append(MENU_TRANSCRIPT_TABS, _("Format Ta&bs"))
        self.transcriptmenu.AppendSeparator()
        if TransanaConstants.USESRTC:
            self.transcriptmenu.Append(MENU_TRANSCRIPT_INSERT_IMAGE,
                                       _("&Insert Image"))
            self.transcriptmenu.AppendSeparator()
        self.transcriptmenu.Append(MENU_TRANSCRIPT_PRINT, _("&Print"))
        self.transcriptmenu.Append(MENU_TRANSCRIPT_PRINTERSETUP,
                                   _("P&rinter Setup"))
        self.transcriptmenu.AppendSeparator()
        # The Character Map is in tough shape.
        # 1.  It doesn't appear to return Font information along with the Character information, rendering it pretty useless
        # 2.  On some platforms, such as XP, it allows the selection of Unicode characters.  But Transana can't cope
        #     with Unicode at this point.
        # Let's just disable it completely for now.
        # self.transcriptmenu.Append(MENU_TRANSCRIPT_CHARACTERMAP, _("&Character Map"))
        self.transcriptmenu.Append(MENU_TRANSCRIPT_ORIENTATION,
                                   _("Change Document Splitter Orientation"))
        self.transcriptmenu.Append(MENU_TRANSCRIPT_AUTOTIMECODE,
                                   _("F&ixed-Increment Time Codes"))
        self.transcriptmenu.Append(MENU_TRANSCRIPT_TEXT_TIMECODE,
                                   _("Text Time Code Conversion"))
        self.transcriptmenu.Append(MENU_TRANSCRIPT_ADJUSTINDEXES,
                                   _("&Adjust Indexes"))
        self.transcriptmenu.AppendSeparator()
        self.transcriptmenu.Append(MENU_TRANSCRIPT_CLOSE_CURRENT,
                                   _("Close Current Document"))
        self.Append(self.transcriptmenu, _("&Document"))

        # Built the Tools menu
        self.toolsmenu = wx.Menu()
        self.toolsmenu.Append(MENU_TOOLS_NOTESBROWSER, _("&Notes Browser"))
        self.toolsmenu.Append(MENU_TOOLS_FILEMANAGEMENT, _("&File Management"))
        self.toolsmenu.Append(MENU_TOOLS_MEDIACONVERSION,
                              _("&Media Conversion"))
        self.toolsmenu.Append(MENU_TOOLS_IMPORT_DATABASE,
                              _("&Import Database"))
        self.toolsmenu.Append(MENU_TOOLS_EXPORT_DATABASE,
                              _("&Export Database"))
        self.toolsmenu.Append(MENU_TOOLS_COLORCONFIG,
                              _("&Graphics Color Configuration"))
        self.toolsmenu.Append(MENU_TOOLS_BATCHWAVEFORM,
                              _("&Batch Waveform Generator"))
        if not TransanaConstants.singleUserVersion:
            self.toolsmenu.Append(MENU_TOOLS_CHAT, _("&Chat Window"))
            self.toolsmenu.Append(MENU_TOOLS_RECORDLOCK,
                                  _("&Record Lock Utility"))
        self.Append(self.toolsmenu, _("Too&ls"))

        # Build the Options menu
        self.optionsmenu = wx.Menu()
        self.optionsmenu.Append(MENU_OPTIONS_SETTINGS, _("Program &Settings"))
        self.optionslanguagemenu = wx.Menu()

        # English should always be installed
        self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_EN,
                                        _("&English"),
                                        kind=wx.ITEM_RADIO)
        # Arabic
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'ar',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_AR,
                                            _("&Arabic"),
                                            kind=wx.ITEM_RADIO)
        # Danish
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'da',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_DA,
                                            _("&Danish"),
                                            kind=wx.ITEM_RADIO)
        # German
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'de',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_DE,
                                            _("&German"),
                                            kind=wx.ITEM_RADIO)
        # Spanish
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'es',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_ES,
                                            _("&Spanish"),
                                            kind=wx.ITEM_RADIO)
        # Finnish
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'fi',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_FI,
                                            _("Fi&nnish"),
                                            kind=wx.ITEM_RADIO)
        # French
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'fr',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_FR,
                                            _("&French"),
                                            kind=wx.ITEM_RADIO)
        # Hebrew
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'he',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_HE,
                                            _("&Hebrew"),
                                            kind=wx.ITEM_RADIO)
        # Italian
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'it',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_IT,
                                            _("&Italian"),
                                            kind=wx.ITEM_RADIO)
        # Dutch
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'nl',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_NL,
                                            _("D&utch"),
                                            kind=wx.ITEM_RADIO)
        # Norwegian Bokmal
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'nb',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_NB,
                                            _("Norwegian Bokmal"),
                                            kind=wx.ITEM_RADIO)
        # Norwegian Ny-norsk
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'nn',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_NN,
                                            _("Norwegian Ny-norsk"),
                                            kind=wx.ITEM_RADIO)
        # Polish
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'pl',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_PL,
                                            _("&Polish"),
                                            kind=wx.ITEM_RADIO)
        # Portuguese
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'pt',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_PT,
                                            _("P&ortuguese"),
                                            kind=wx.ITEM_RADIO)
        # Russian
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'ru',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_RU,
                                            _("&Russian"),
                                            kind=wx.ITEM_RADIO)
        # Swedish
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'sv',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_SV,
                                            _("S&wedish"),
                                            kind=wx.ITEM_RADIO)
        # Chinese
        dir = os.path.join(TransanaGlobal.programDir, 'locale', 'zh',
                           'LC_MESSAGES', 'Transana.mo')
        if os.path.exists(dir):
            self.optionslanguagemenu.Append(MENU_OPTIONS_LANGUAGE_ZH,
                                            _("&Chinese - Simplified"),
                                            kind=wx.ITEM_RADIO)
        self.optionsmenu.AppendMenu(MENU_OPTIONS_LANGUAGE, _("&Language"),
                                    self.optionslanguagemenu)
        self.optionsmenu.AppendSeparator()
        self.optionsmenu.Append(MENU_OPTIONS_QUICK_CLIPS,
                                _("&Quick Quote and Clip Mode"),
                                kind=wx.ITEM_CHECK)
        self.optionsmenu.Append(MENU_OPTIONS_QUICKCLIPWARNING,
                                _("Show Quick Quote and Clip Warning"),
                                kind=wx.ITEM_CHECK)
        self.optionsmenu.Append(MENU_OPTIONS_WORDTRACK,
                                _("Auto Word-&tracking"),
                                kind=wx.ITEM_CHECK)
        self.optionsmenu.Append(MENU_OPTIONS_AUTOARRANGE,
                                _("&Auto-Arrange"),
                                kind=wx.ITEM_CHECK)
        #        self.optionsmenu.Append(MENU_OPTIONS_LONGTRANSCRIPTEDIT, _("Long Document Editing"), kind=wx.ITEM_CHECK)
        #        self.optionsmenu.Enable(MENU_OPTIONS_LONGTRANSCRIPTEDIT, False)

        self.optionsmenu.AppendSeparator()

        # Add a menu for the Visualization Options
        self.optionsvisualizationmenu = wx.Menu()
        self.optionsvisualizationmenu.Append(
            MENU_OPTIONS_VISUALIZATION_WAVEFORM,
            _("&Waveform"),
            kind=wx.ITEM_RADIO)
        self.optionsvisualizationmenu.Append(
            MENU_OPTIONS_VISUALIZATION_KEYWORD,
            _("&Keyword"),
            kind=wx.ITEM_RADIO)
        self.optionsvisualizationmenu.Append(MENU_OPTIONS_VISUALIZATION_HYBRID,
                                             _("&Hybrid"),
                                             kind=wx.ITEM_RADIO)
        self.optionsmenu.AppendMenu(MENU_OPTIONS_VISUALIZATION,
                                    _("Media Vi&sualization Style"),
                                    self.optionsvisualizationmenu)

        self.optionsvideomenu = wx.Menu()
        self.optionsvideomenu.Append(MENU_OPTIONS_VIDEOSIZE_50,
                                     "&50%",
                                     kind=wx.ITEM_RADIO)
        self.optionsvideomenu.Append(MENU_OPTIONS_VIDEOSIZE_66,
                                     "&66%",
                                     kind=wx.ITEM_RADIO)
        self.optionsvideomenu.Append(MENU_OPTIONS_VIDEOSIZE_100,
                                     "&100%",
                                     kind=wx.ITEM_RADIO)
        self.optionsvideomenu.Append(MENU_OPTIONS_VIDEOSIZE_150,
                                     "15&0%",
                                     kind=wx.ITEM_RADIO)
        self.optionsvideomenu.Append(MENU_OPTIONS_VIDEOSIZE_200,
                                     "&200%",
                                     kind=wx.ITEM_RADIO)
        self.optionsmenu.AppendMenu(MENU_OPTIONS_VIDEOSIZE, _("&Media Size"),
                                    self.optionsvideomenu)
        self.optionspresentmenu = wx.Menu()
        self.optionspresentmenu.Append(MENU_OPTIONS_PRESENT_ALL,
                                       _("&All Windows"),
                                       kind=wx.ITEM_RADIO)
        self.optionspresentmenu.Append(MENU_OPTIONS_PRESENT_VIDEO,
                                       _("&Media Only"),
                                       kind=wx.ITEM_RADIO)
        self.optionspresentmenu.Append(MENU_OPTIONS_PRESENT_TRANS,
                                       _("Media and &Transcript Only"),
                                       kind=wx.ITEM_RADIO)
        self.optionspresentmenu.Append(MENU_OPTIONS_PRESENT_AUDIO,
                                       _("A&udio and Transcript Only"),
                                       kind=wx.ITEM_RADIO)
        self.optionsmenu.AppendMenu(MENU_OPTIONS_PRESENT,
                                    _("&Presentation Mode"),
                                    self.optionspresentmenu)
        self.Append(self.optionsmenu, _("&Options"))

        # Place the "check" by the correct language based on Transana's configuration settings
        self.SetLanguageMenuCheck(TransanaGlobal.configData.language)

        # Set Options Menu items to their initial values based on Configuration Data
        self.optionsmenu.Check(MENU_OPTIONS_QUICK_CLIPS,
                               TransanaGlobal.configData.quickClipMode)
        self.optionsmenu.Check(MENU_OPTIONS_QUICKCLIPWARNING,
                               TransanaGlobal.configData.quickClipWarning)
        self.optionsmenu.Check(MENU_OPTIONS_WORDTRACK,
                               TransanaGlobal.configData.wordTracking)
        self.optionsmenu.Check(MENU_OPTIONS_AUTOARRANGE,
                               TransanaGlobal.configData.autoArrange)

        # Set the Visualization Style to reflect the Configuration Data value
        if TransanaGlobal.configData.visualizationStyle == 'Keyword':
            self.optionsvisualizationmenu.Check(
                MENU_OPTIONS_VISUALIZATION_KEYWORD, True)
        elif TransanaGlobal.configData.visualizationStyle == 'Hybrid':
            self.optionsvisualizationmenu.Check(
                MENU_OPTIONS_VISUALIZATION_HYBRID, True)
        else:
            self.optionsvisualizationmenu.Check(
                MENU_OPTIONS_VISUALIZATION_WAVEFORM, True)

        # Set the VideoSize Menu to reflect the Configuration Data value
        if TransanaGlobal.configData.videoSize == 50:
            self.optionsmenu.Check(MENU_OPTIONS_VIDEOSIZE_50, True)
        elif TransanaGlobal.configData.videoSize == 66:
            self.optionsmenu.Check(MENU_OPTIONS_VIDEOSIZE_66, True)
        elif TransanaGlobal.configData.videoSize == 100:
            self.optionsmenu.Check(MENU_OPTIONS_VIDEOSIZE_100, True)
        elif TransanaGlobal.configData.videoSize == 150:
            self.optionsmenu.Check(MENU_OPTIONS_VIDEOSIZE_150, True)
        elif TransanaGlobal.configData.videoSize == 200:
            self.optionsmenu.Check(MENU_OPTIONS_VIDEOSIZE_200, True)

        # Disable the automatic "Window" menu on the Mac.  It's not accessible for i18n, etc.
        if 'wxMac' in wx.PlatformInfo:
            wx.MenuBar.SetAutoWindowMenu(False)

        # Build the Window Menu
        self.windowMenu = wx.Menu()
        self.windowMenu.Append(MENU_WINDOW_ALL_MAIN,
                               _("Bring Main Windows to Front"))
        self.windowMenu.Append(MENU_WINDOW_ALL_SNAPSHOT,
                               _("Close All Snapshots"))
        self.windowMenu.Append(MENU_WINDOW_CLOSE_REPORTS,
                               _("Close All Reports"))
        self.windowMenu.AppendSeparator()
        self.windowMenu.Append(MENU_WINDOW_DATA, _("Data"))
        self.windowMenu.Append(MENU_WINDOW_VIDEO, _("Media"))
        self.windowMenu.Append(MENU_WINDOW_TRANSCRIPT, _("Document"))
        self.windowMenu.Append(MENU_WINDOW_VISUALIZATION, _("Visualization"))
        self.windowMenu.Append(MENU_WINDOW_NOTESBROWSER, _("Notes Browser"))
        if not TransanaConstants.singleUserVersion:
            self.windowMenu.Append(MENU_WINDOW_CHAT, _("Chat"))
        self.windowMenu.AppendSeparator()
        self.Append(self.windowMenu, _("Window"))

        # Build the Help Menu
        self.helpmenu = wx.Menu()
        self.helpmenu.Append(MENU_HELP_MANUAL, _("&Manual"))
        self.helpmenu.Append(MENU_HELP_TUTORIAL, _("&Tutorial"))
        self.helpmenu.Append(MENU_HELP_NOTATION, _("Transcript &Notation"))
        self.helpmenu.Append(MENU_HELP_WEBSITE, _("&www.transana.org"))
        # self.helpmenu.Append(MENU_HELP_FUND, _("&Fund Transana"))
        self.helpmenu.Append(MENU_HELP_ABOUT, _("&About"))
        self.Append(self.helpmenu, _("&Help"))

        wx.App_SetMacHelpMenuTitleName(_("&Help"))
Beispiel #3
0
    def __init__(self, parent=None):
        style = wx.SYSTEM_MENU | wx.CAPTION | wx.MINIMIZE_BOX | wx.RESIZE_BORDER
        if misc.check_wx_version(2, 5):
            style |= wx.CLOSE_BOX
        wx.Frame.__init__(self,
                          parent,
                          -1,
                          "wxGlade v%s" % common.version,
                          style=style)
        self.CreateStatusBar(1)

        if parent is None: parent = self
        common.palette = self  # to provide a reference accessible
        # by the various widget classes
        icon = wx.EmptyIcon()
        bmp = wx.Bitmap(os.path.join(common.wxglade_path, "icons/icon.xpm"),
                        wx.BITMAP_TYPE_XPM)
        icon.CopyFromBitmap(bmp)
        self.SetIcon(icon)
        self.SetBackgroundColour(
            wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE))
        menu_bar = wx.MenuBar()
        file_menu = wx.Menu(style=wx.MENU_TEAROFF)
        view_menu = wx.Menu(style=wx.MENU_TEAROFF)
        help_menu = wx.Menu(style=wx.MENU_TEAROFF)
        wx.ToolTip_SetDelay(1000)

        # load the available code generators
        common.load_code_writers()
        # load the available widgets and sizers
        core_btns, custom_btns = common.load_widgets()
        sizer_btns = common.load_sizers()

        append_item = misc.append_item
        self.TREE_ID = TREE_ID = wx.NewId()
        append_item(view_menu, TREE_ID, _("Show &Tree\tF2"))
        self.PROPS_ID = PROPS_ID = wx.NewId()
        self.RAISE_ID = RAISE_ID = wx.NewId()
        append_item(view_menu, PROPS_ID, _("Show &Properties\tF3"))
        append_item(view_menu, RAISE_ID, _("&Raise All\tF4"))
        NEW_ID = wx.NewId()
        append_item(file_menu, NEW_ID, _("&New\tCtrl+N"), wx.ART_NEW)
        NEW_FROM_TEMPLATE_ID = wx.NewId()
        append_item(file_menu, NEW_FROM_TEMPLATE_ID,
                    _("New from &Template...\tShift+Ctrl+N"))
        OPEN_ID = wx.NewId()
        append_item(file_menu, OPEN_ID, _("&Open...\tCtrl+O"),
                    wx.ART_FILE_OPEN)
        SAVE_ID = wx.NewId()
        append_item(file_menu, SAVE_ID, _("&Save\tCtrl+S"), wx.ART_FILE_SAVE)
        SAVE_AS_ID = wx.NewId()
        append_item(file_menu, SAVE_AS_ID, _("Save As...\tShift+Ctrl+S"),
                    wx.ART_FILE_SAVE_AS)
        SAVE_TEMPLATE_ID = wx.NewId()
        append_item(file_menu, SAVE_TEMPLATE_ID, _("Save As Template..."))
        file_menu.AppendSeparator()
        RELOAD_ID = wx.ID_REFRESH  #wx.NewId()
        append_item(file_menu, RELOAD_ID, _("&Refresh\tf5"))  #, wx.ART_REDO)
        GENERATE_CODE_ID = wx.NewId()
        append_item(file_menu, GENERATE_CODE_ID, _("&Generate Code\tCtrl+G"),
                    wx.ART_EXECUTABLE_FILE)

        file_menu.AppendSeparator()
        IMPORT_ID = wx.NewId()
        append_item(file_menu, IMPORT_ID, _("&Import from XRC...\tCtrl+I"))

        EXIT_ID = wx.NewId()
        file_menu.AppendSeparator()
        append_item(file_menu, EXIT_ID, _('E&xit\tCtrl+Q'), wx.ART_QUIT)
        PREFS_ID = wx.ID_PREFERENCES  #NewId()
        view_menu.AppendSeparator()
        MANAGE_TEMPLATES_ID = wx.NewId()
        append_item(view_menu, MANAGE_TEMPLATES_ID, _('Templates Manager...'))
        view_menu.AppendSeparator()
        append_item(view_menu, PREFS_ID, _('Preferences...'))
        #wx.ART_HELP_SETTINGS)
        menu_bar.Append(file_menu, _("&File"))
        menu_bar.Append(view_menu, _("&View"))
        TUT_ID = wx.NewId()
        append_item(help_menu, TUT_ID, _('Contents\tF1'), wx.ART_HELP)
        ABOUT_ID = wx.ID_ABOUT  #wx.NewId()
        append_item(help_menu, ABOUT_ID, _('About...'))  #, wx.ART_QUESTION)
        menu_bar.Append(help_menu, _('&Help'))
        parent.SetMenuBar(menu_bar)
        # Mac tweaks...
        if wx.Platform == "__WXMAC__":
            wx.App_SetMacAboutMenuItemId(ABOUT_ID)
            wx.App_SetMacPreferencesMenuItemId(PREFS_ID)
            wx.App_SetMacExitMenuItemId(EXIT_ID)
            wx.App_SetMacHelpMenuTitleName(_('&Help'))

        # file history support
        if misc.check_wx_version(2, 3, 3):
            self.file_history = wx.FileHistory(
                config.preferences.number_history)
            self.file_history.UseMenu(file_menu)
            files = config.load_history()
            files.reverse()
            for path in files:
                self.file_history.AddFileToHistory(path.strip())

            def open_from_history(event):
                if not self.ask_save(): return
                infile = self.file_history.GetHistoryFile(event.GetId() -
                                                          wx.ID_FILE1)
                # ALB 2004-10-15 try to restore possible autosave content...
                if common.check_autosaved(infile) and \
                       wx.MessageBox(_("There seems to be auto saved data for "
                                    "this file: do you want to restore it?"),
                                    _("Auto save detected"),
                                    style=wx.ICON_QUESTION|wx.YES_NO) == wx.YES:
                    common.restore_from_autosaved(infile)
                else:
                    common.remove_autosaved(infile)
                self._open_app(infile)

            wx.EVT_MENU_RANGE(self, wx.ID_FILE1, wx.ID_FILE9,
                              open_from_history)

        wx.EVT_MENU(self, TREE_ID, self.show_tree)
        wx.EVT_MENU(self, PROPS_ID, self.show_props_window)
        wx.EVT_MENU(self, RAISE_ID, self.raise_all)
        wx.EVT_MENU(self, NEW_ID, self.new_app)
        wx.EVT_MENU(self, NEW_FROM_TEMPLATE_ID, self.new_app_from_template)
        wx.EVT_MENU(self, OPEN_ID, self.open_app)
        wx.EVT_MENU(self, SAVE_ID, self.save_app)
        wx.EVT_MENU(self, SAVE_AS_ID, self.save_app_as)
        wx.EVT_MENU(self, SAVE_TEMPLATE_ID, self.save_app_as_template)

        def generate_code(event):
            common.app_tree.app.generate_code()

        wx.EVT_MENU(self, GENERATE_CODE_ID, generate_code)
        wx.EVT_MENU(self, EXIT_ID, lambda e: self.Close())
        wx.EVT_MENU(self, TUT_ID, self.show_tutorial)
        wx.EVT_MENU(self, ABOUT_ID, self.show_about_box)
        wx.EVT_MENU(self, PREFS_ID, self.edit_preferences)
        wx.EVT_MENU(self, MANAGE_TEMPLATES_ID, self.manage_templates)
        wx.EVT_MENU(self, IMPORT_ID, self.import_xrc)
        wx.EVT_MENU(self, RELOAD_ID, self.reload_app)

        PREVIEW_ID = wx.NewId()

        def preview(event):
            if common.app_tree.cur_widget is not None:
                p = misc.get_toplevel_widget(common.app_tree.cur_widget)
                if p is not None:
                    p.preview(None)

        wx.EVT_MENU(self, PREVIEW_ID, preview)

        self.accel_table = wx.AcceleratorTable([
            (wx.ACCEL_CTRL, ord('N'), NEW_ID),
            (wx.ACCEL_CTRL, ord('O'), OPEN_ID),
            (wx.ACCEL_CTRL, ord('S'), SAVE_ID),
            (wx.ACCEL_CTRL | wx.ACCEL_SHIFT, ord('S'), SAVE_AS_ID),
            (wx.ACCEL_CTRL, ord('G'), GENERATE_CODE_ID),
            (wx.ACCEL_CTRL, ord('I'), IMPORT_ID),
            (0, wx.WXK_F1, TUT_ID),
            (wx.ACCEL_CTRL, ord('Q'), EXIT_ID),
            (0, wx.WXK_F5, RELOAD_ID),
            (0, wx.WXK_F2, TREE_ID),
            (0, wx.WXK_F3, PROPS_ID),
            (0, wx.WXK_F4, RAISE_ID),
            (wx.ACCEL_CTRL, ord('P'), PREVIEW_ID),
        ])

        # Tutorial window
        ##         self.tut_frame = None
        # layout
        # if there are custom components, add the toggle box...
        if custom_btns:
            main_sizer = wx.BoxSizer(wx.VERTICAL)
            show_core_custom = ToggleButtonBox(
                self, -1, [_("Core components"),
                           _("Custom components")], 0)

            if misc.check_wx_version(2, 5):
                core_sizer = wx.FlexGridSizer(
                    0, config.preferences.buttons_per_row)
                custom_sizer = wx.FlexGridSizer(
                    0, config.preferences.buttons_per_row)
            else:
                core_sizer = wx.GridSizer(0,
                                          config.preferences.buttons_per_row)
                custom_sizer = wx.GridSizer(0,
                                            config.preferences.buttons_per_row)
            self.SetAutoLayout(True)
            # core components
            for b in core_btns:
                core_sizer.Add(b)
            for sb in sizer_btns:
                core_sizer.Add(sb)
            # custom components
            for b in custom_btns:
                custom_sizer.Add(b)
                if misc.check_wx_version(2, 5):
                    custom_sizer.Show(b, False)
            custom_sizer.Layout()
            main_sizer.Add(show_core_custom, 0, wx.EXPAND)
            main_sizer.Add(core_sizer, 0, wx.EXPAND)
            main_sizer.Add(custom_sizer, 0, wx.EXPAND)
            self.SetSizer(main_sizer)
            if not misc.check_wx_version(2, 5):
                main_sizer.Show(custom_sizer, False)
            #main_sizer.Show(1, False)
            main_sizer.Fit(self)
            # events to display core/custom components
            if misc.check_wx_version(2, 5):

                def on_show_core_custom(event):
                    show_core = True
                    show_custom = False
                    if event.GetValue() == 1:
                        show_core = False
                        show_custom = True
                    for b in custom_btns:
                        custom_sizer.Show(b, show_custom)
                    for b in core_btns:
                        core_sizer.Show(b, show_core)
                    for b in sizer_btns:
                        core_sizer.Show(b, show_core)
                    core_sizer.Layout()
                    custom_sizer.Layout()
                    main_sizer.Layout()
            else:

                def on_show_core_custom(event):
                    to_show = core_sizer
                    to_hide = custom_sizer
                    if event.GetValue() == 1:
                        to_show, to_hide = to_hide, to_show
                    main_sizer.Show(to_show, True)
                    main_sizer.Show(to_hide, False)
                    main_sizer.Layout()

            EVT_TOGGLE_BOX(self, show_core_custom.GetId(), on_show_core_custom)
        # ... otherwise (the common case), just add the palette of core buttons
        else:
            sizer = wx.GridSizer(0, config.preferences.buttons_per_row)
            self.SetAutoLayout(True)
            # core components
            for b in core_btns:
                sizer.Add(b)
            for sb in sizer_btns:
                sizer.Add(sb)
            self.SetSizer(sizer)
            sizer.Fit(self)

        # Properties window
        frame_style = wx.DEFAULT_FRAME_STYLE
        frame_tool_win = config.preferences.frame_tool_win
        if frame_tool_win:
            frame_style |= wx.FRAME_NO_TASKBAR | wx.FRAME_FLOAT_ON_PARENT
            frame_style &= ~wx.MINIMIZE_BOX
            if wx.Platform != '__WXGTK__': frame_style |= wx.FRAME_TOOL_WINDOW

        self.frame2 = wx.Frame(self,
                               -1,
                               _('Properties - <app>'),
                               style=frame_style)
        self.frame2.SetBackgroundColour(
            wx.SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE))
        self.frame2.SetIcon(icon)

        sizer_tmp = wx.BoxSizer(wx.VERTICAL)
        property_panel = wxGladePropertyPanel(self.frame2, -1)

        #---- 2003-06-22 Fix for what seems to be a GTK2 bug (notebooks)
        misc.hidden_property_panel = wx.Panel(self.frame2, -1)
        sz = wx.BoxSizer(wx.VERTICAL)
        sz.Add(property_panel, 1, wx.EXPAND)
        sz.Add(misc.hidden_property_panel, 1, wx.EXPAND)
        self.frame2.SetSizer(sz)
        sz.Show(misc.hidden_property_panel, False)
        self.property_frame = self.frame2
        #--------------------------------------------------------

        property_panel.SetAutoLayout(True)
        self.hidden_frame = wx.Frame(self, -1, "")
        self.hidden_frame.Hide()
        sizer_tmp.Add(property_panel, 1, wx.EXPAND)
        self.frame2.SetAutoLayout(True)
        self.frame2.SetSizer(sizer_tmp)
        sizer_tmp = wx.BoxSizer(wx.VERTICAL)

        def hide_frame2(event):
            #menu_bar.Check(PROPS_ID, False)
            self.frame2.Hide()

        wx.EVT_CLOSE(self.frame2, hide_frame2)
        wx.EVT_CLOSE(self, self.cleanup)
        common.property_panel = property_panel
        # Tree of widgets
        self.tree_frame = wx.Frame(self,
                                   -1,
                                   _('wxGlade: Tree'),
                                   style=frame_style)
        self.tree_frame.SetIcon(icon)

        import application
        app = application.Application(common.property_panel)
        common.app_tree = WidgetTree(self.tree_frame, app)
        self.tree_frame.SetSize((300, 300))

        app.notebook.Show()
        sizer_tmp.Add(app.notebook, 1, wx.EXPAND)
        property_panel.SetSizer(sizer_tmp)
        sizer_tmp.Fit(property_panel)

        def on_tree_frame_close(event):
            #menu_bar.Check(TREE_ID, False)
            self.tree_frame.Hide()

        wx.EVT_CLOSE(self.tree_frame, on_tree_frame_close)
        # check to see if there are some remembered values
        prefs = config.preferences
        if prefs.remember_geometry:
            #print 'initializing geometry'
            try:
                x, y, w, h = prefs.get_geometry('main')
                misc.set_geometry(self, (x, y))
            except Exception, e:
                pass
            misc.set_geometry(self.frame2, prefs.get_geometry('properties'))
            misc.set_geometry(self.tree_frame, prefs.get_geometry('tree'))
Beispiel #4
0
    def __init__(self, img_viewer, path, **kwds):
        wx.Frame.__init__(self, None, -1, "")
        self.window_1 = wx.SplitterWindow(self, -1, style=0)
        self.window_1_pane_1 = wx.Panel(self.window_1, -1, style=0)
        self.window_2 = wx.SplitterWindow(self.window_1_pane_1, -1, style=0)
        self.window_2_pane_1 = wx.Panel(self.window_2, -1, style=0)
        if wx.Platform == '__WXGTK__':
            nbstyle = wx.NB_BOTTOM
        else:
            nbstyle = 0
        self.preview_notebook = wx.Notebook(self.window_2, -1, style=nbstyle)
        #self.preview_panel = preview.PreviewPanel(self.window_2, -1)
        self.preview_panel = preview.PreviewPanel(self.preview_notebook, -1)
        self.exif_info = exif_info.ExifInfo(self.preview_notebook)
        self.preview_notebook.AddPage(self.preview_panel, _("Preview"))
        self.preview_notebook.AddPage(self.exif_info, _("Exif data"))
        
        self.window_1_pane_2 = wx.Panel(self.window_1, -1, style=0)
        self.statusbar = self.CreateStatusBar(4)

        self.notebook = wx.Notebook(self.window_2_pane_1, -1)
        self.dir_ctrl = dirctrl.DirCtrl(self.notebook, -1, 
                                        style=wx.SUNKEN_BORDER |
                                        wx.DIRCTRL_DIR_ONLY)
        self.bookmarks = bmarks.BookMarksCtrl(self.notebook)
        self.albums = albums.AlbumsCtrl(self.notebook)
            
        self.viewer = img_viewer
        self.viewer.cornice_browser = self
        
        self.options = kwds
        self.picture_list = picture_list.PictureList(self.window_1_pane_2, -1,
                                                     self.options, self)
        self.albums.picture_list = self.picture_list
        
        # Menu Bar
        res = wx.xrc.XmlResource.Get()
        res.Load('resources.xrc')
        self.SetMenuBar(res.LoadMenuBar('menubar'))
        self.bind_menubar_events()
        
        if wx.Platform == '__WXMAC__':
            wx.App_SetMacAboutMenuItemId(wx.xrc.XRCID('about'))
            wx.App_SetMacPreferencesMenuItemId(wx.xrc.XRCID('preferences'))
            wx.App_SetMacExitMenuItemId(wx.xrc.XRCID('exit'))
            wx.App_SetMacHelpMenuTitleName('Help')
        # Tool Bar
##         res.Load('toolbars.xrc')
        common.load_from_theme('toolbars.xrc')
        self.SetToolBar(res.LoadToolBar(self, 'browser_toolbar'))
        index = common.config.getint('cornice', 'default_view')
        if index == 0:
            self.GetToolBar().ToggleTool(wx.xrc.XRCID('report_view'), True)
            self.GetMenuBar().Check(wx.xrc.XRCID('report_view'), True)
        else:
            self.GetToolBar().ToggleTool(wx.xrc.XRCID('thumbs_view'), True)
            self.GetMenuBar().Check(wx.xrc.XRCID('thumbs_view'), True)

        self.__do_layout()
        self.__set_properties()

        if common.config.getboolean('cornice', 'show_hidden'):
            self.GetMenuBar().Check(wx.xrc.XRCID('show_hidden'), True)
            self.dir_ctrl.ShowHidden(True)

        self.dir_ctrl.SetPath(path)
        #--- hack to fix bug of dir_ctrl ---
        tree = self.dir_ctrl.GetTreeCtrl()
        tree.EnsureVisible(tree.GetSelection())
        #-----------------------------------
        if common.config.getint('cornice', 'default_view') == 1: 
            # do this later, otherwise if started in thumbs view, the layout
            # is messed up...
            wx.CallAfter(self.picture_list.set_path, path)
        else:
            self.picture_list.set_path(path)

        # dir selection... and thumbs/report view
        TIMER_ID = wx.NewId()
        self.which_case = 0 # 0 = dir_selection, 1 = details, 2 = thumbnails
        self.set_path_timer = wx.Timer(self, TIMER_ID)
        ###wx.EVT_TIMER(self, TIMER_ID, self.on_timer)
        wx.EvtHandler.Bind(self, wx.EVT_TIMER, self.on_timer, id=TIMER_ID)
        ###wx.EVT_TREE_SEL_CHANGED(self.dir_ctrl, -1, #self.dir_ctrl.GetTreeCtrl().GetId(),
        ###                        self.on_tree_sel_changed)
        wx.EvtHandler.Bind(self.dir_ctrl, wx.EVT_TREE_SEL_CHANGED, self.on_tree_sel_changed, id=-1)
        
        ###wx.EVT_IDLE(self, self.on_idle)
        wx.EvtHandler.Bind(self, wx.EVT_IDLE, self.on_idle)

        ###picture_list.EVT_PL_CHANGE_PATH(self.picture_list, -1,
                                        ###self.on_pl_change_path)
        wx.EvtHandler.Bind(self.picture_list, picture_list.EVT_PL_CHANGE_PATH, self.on_pl_change_path, id=-1)

        ID_FOCUS_PATH = wx.NewId()
        self.SetAcceleratorTable(wx.AcceleratorTable([
            (wx.ACCEL_CTRL, ord('l'), ID_FOCUS_PATH)
            ]))
        # focus the dircompleter...
        #wx.EVT_MENU(self, ID_FOCUS_PATH, self.picture_list.focus_path)
        wx.EvtHandler.Bind(self, wx.EVT_MENU, self.picture_list.focus_path, id=ID_FOCUS_PATH)

        self.show_exif(False)
Beispiel #5
0
    def create_menu(self, parent):
        menu_bar = wx.MenuBar()

        compat.wx_ToolTip_SetDelay(1000)
        compat.wx_ToolTip_SetAutoPop(30000)

        append_menu_item = misc.append_menu_item

        # File menu
        file_menu = wx.Menu(style=wx.MENU_TEAROFF)

        NEW = append_menu_item(file_menu, -1, _("&New\tCtrl+N"), wx.ART_NEW)
        misc.bind_menu_item(self, NEW, self.new_app)

        item = append_menu_item(file_menu, -1,
                                _("New from &Template...\tShift+Ctrl+N"))
        misc.bind_menu_item(self, item, self.new_app_from_template)

        OPEN = append_menu_item(file_menu, -1, _("&Open...\tCtrl+O"),
                                wx.ART_FILE_OPEN)
        misc.bind_menu_item(self, OPEN, self.open_app)

        SAVE = append_menu_item(file_menu, -1, _("&Save\tCtrl+S"),
                                wx.ART_FILE_SAVE)
        misc.bind_menu_item(self, SAVE, self.save_app)

        SAVE_AS = append_menu_item(file_menu, -1, _("Save As..."),
                                   wx.ART_FILE_SAVE_AS)
        misc.bind_menu_item(self, SAVE_AS, self.save_app_as)

        item = append_menu_item(file_menu, -1, _("Save As Template..."))
        misc.bind_menu_item(self, item, self.save_app_as_template)

        file_menu.AppendSeparator(
        )  # ----------------------------------------------------------------------------------

        item = append_menu_item(file_menu, wx.ID_REFRESH,
                                _("&Refresh Preview\tF5"))
        misc.bind_menu_item(self, item, self.preview)

        GENERATE_CODE = append_menu_item(file_menu, -1,
                                         _("&Generate Code\tCtrl+G"),
                                         wx.ART_EXECUTABLE_FILE)
        misc.bind_menu_item(self, GENERATE_CODE,
                            lambda: common.app_tree.app.generate_code())

        file_menu.AppendSeparator(
        )  # ----------------------------------------------------------------------------------

        item = append_menu_item(file_menu, -1, _("&Import from XRC..."))
        misc.bind_menu_item(self, item, self.import_xrc)

        file_menu.AppendSeparator(
        )  # ----------------------------------------------------------------------------------

        EXIT = append_menu_item(file_menu, -1, _('E&xit\tCtrl+Q'), wx.ART_QUIT)
        misc.bind_menu_item(self, EXIT, self.Close)

        menu_bar.Append(file_menu, _("&File"))

        # View menu
        view_menu = wx.Menu(style=wx.MENU_TEAROFF)

        TREE = append_menu_item(view_menu, -1, _("Show &Tree\tF2"))
        misc.bind_menu_item(self, TREE, self.show_tree)

        PROPS = append_menu_item(view_menu, -1, _("Show &Properties\tF3"))
        misc.bind_menu_item(self, PROPS, self.show_props_window)

        RAISE = append_menu_item(view_menu, -1, _("&Raise All\tF4"))
        misc.bind_menu_item(self, RAISE, self.raise_all)

        DESIGN = append_menu_item(view_menu, -1, _("Show &Design\tF6"))
        misc.bind_menu_item(self, DESIGN, self.show_design_window)

        view_menu.AppendSeparator(
        )  # ----------------------------------------------------------------------------------

        item = append_menu_item(view_menu, -1, _('Template Manager...'))
        misc.bind_menu_item(self, item, self.manage_templates)

        view_menu.AppendSeparator(
        )  # ----------------------------------------------------------------------------------

        item = append_menu_item(view_menu, wx.ID_PREFERENCES,
                                _('Preferences...'))
        misc.bind_menu_item(self, item, self.edit_preferences)

        menu_bar.Append(view_menu, _("&View"))

        # Help menu
        help_menu = wx.Menu(style=wx.MENU_TEAROFF)

        MANUAL = append_menu_item(help_menu, -1, _('Manual\tF1'), wx.ART_HELP)
        misc.bind_menu_item(self, MANUAL, self.show_manual)
        #item = append_menu_item(help_menu, -1, _('Tutorial'))
        #misc.bind_menu_item(self, item, self.show_tutorial)
        help_menu.AppendSeparator(
        )  # ----------------------------------------------------------------------------------

        i = append_menu_item(help_menu, -1, _('Mailing list'))
        misc.bind_menu_item(self, i, self.show_mailing_list)
        i = append_menu_item(help_menu, -1, _('Bug tracker'))
        misc.bind_menu_item(self, i, self.show_bug_tracker)
        i = append_menu_item(help_menu, -1, _('Releases'))
        misc.bind_menu_item(self, i, self.show_releases)
        help_menu.AppendSeparator(
        )  # ----------------------------------------------------------------------------------

        item = append_menu_item(help_menu, wx.ID_ABOUT, _('About'))
        misc.bind_menu_item(self, item, self.show_about_box)

        menu_bar.Append(help_menu, _('&Help'))

        parent.SetMenuBar(menu_bar)
        # Mac tweaks...
        if wx.Platform == "__WXMAC__":
            if compat.IS_PHOENIX:
                wx.PyApp.SetMacAboutMenuItemId(wx.ID_ABOUT)
                wx.PyApp.SetMacPreferencesMenuItemId(wx.ID_PREFERENCES)
                wx.PyApp.SetMacExitMenuItemId(wx.ID_EXIT)
                wx.PyApp.SetMacHelpMenuTitleName(_('&Help'))
            else:
                wx.App_SetMacAboutMenuItemId(wx.ID_ABOUT)
                wx.App_SetMacPreferencesMenuItemId(wx.ID_PREFERENCES)
                wx.App_SetMacExitMenuItemId(wx.ID_EXIT)
                wx.App_SetMacHelpMenuTitleName(_('&Help'))

        # file history support
        self.file_history = wx.FileHistory(config.preferences.number_history)
        self.file_history.UseMenu(file_menu)
        files = common.load_file_history()
        files.reverse()
        for path in files:
            self.file_history.AddFileToHistory(path.strip())

        self.Bind(wx.EVT_MENU_RANGE,
                  self.open_from_history,
                  id=wx.ID_FILE1,
                  id2=wx.ID_FILE9)
Beispiel #6
0
    def create_menu(self, parent):
        menu_bar = wx.MenuBar()
        file_menu = wx.Menu(style=wx.MENU_TEAROFF)
        view_menu = wx.Menu(style=wx.MENU_TEAROFF)
        help_menu = wx.Menu(style=wx.MENU_TEAROFF)
        compat.wx_ToolTip_SetDelay(1000)
        compat.wx_ToolTip_SetAutoPop(30000)

        append_menu_item = misc.append_menu_item
        self.TREE_ID = TREE_ID = wx.NewId()
        append_menu_item(view_menu, TREE_ID, _("Show &Tree\tF2"))
        self.PROPS_ID = PROPS_ID = wx.NewId()
        self.RAISE_ID = RAISE_ID = wx.NewId()
        append_menu_item(view_menu, PROPS_ID, _("Show &Properties\tF3"))
        append_menu_item(view_menu, RAISE_ID, _("&Raise All\tF4"))
        NEW_ID = wx.NewId()
        append_menu_item(file_menu, NEW_ID, _("&New\tCtrl+N"), wx.ART_NEW)
        NEW_FROM_TEMPLATE_ID = wx.NewId()
        append_menu_item(file_menu, NEW_FROM_TEMPLATE_ID,
                         _("New from &Template...\tShift+Ctrl+N"))
        OPEN_ID = wx.NewId()
        append_menu_item(file_menu, OPEN_ID, _("&Open...\tCtrl+O"),
                         wx.ART_FILE_OPEN)
        SAVE_ID = wx.NewId()
        append_menu_item(file_menu, SAVE_ID, _("&Save\tCtrl+S"),
                         wx.ART_FILE_SAVE)
        SAVE_AS_ID = wx.NewId()
        append_menu_item(file_menu, SAVE_AS_ID, _("Save As...\tShift+Ctrl+S"),
                         wx.ART_FILE_SAVE_AS)
        SAVE_TEMPLATE_ID = wx.NewId()
        append_menu_item(file_menu, SAVE_TEMPLATE_ID, _("Save As Template..."))
        file_menu.AppendSeparator()

        append_menu_item(file_menu, wx.ID_REFRESH, _("&Refresh Preview\tF5"))

        GENERATE_CODE_ID = wx.NewId()
        append_menu_item(file_menu, GENERATE_CODE_ID,
                         _("&Generate Code\tCtrl+G"), wx.ART_EXECUTABLE_FILE)

        file_menu.AppendSeparator()
        IMPORT_ID = wx.NewId()
        append_menu_item(file_menu, IMPORT_ID, _("&Import from XRC..."))

        EXIT_ID = wx.NewId()
        file_menu.AppendSeparator()
        append_menu_item(file_menu, EXIT_ID, _('E&xit\tCtrl+Q'), wx.ART_QUIT)
        PREFS_ID = wx.ID_PREFERENCES
        view_menu.AppendSeparator()
        MANAGE_TEMPLATES_ID = wx.NewId()
        append_menu_item(view_menu, MANAGE_TEMPLATES_ID,
                         _('Template Manager...'))
        view_menu.AppendSeparator()
        append_menu_item(view_menu, PREFS_ID, _('Preferences...'))
        menu_bar.Append(file_menu, _("&File"))
        menu_bar.Append(view_menu, _("&View"))

        MANUAL_ID = wx.NewId()
        append_menu_item(help_menu, MANUAL_ID, _('Manual\tF1'), wx.ART_HELP)
        TUTORIAL_ID = wx.NewId()
        append_menu_item(help_menu, TUTORIAL_ID, _('Tutorial'))
        help_menu.AppendSeparator()
        ABOUT_ID = wx.ID_ABOUT
        append_menu_item(help_menu, ABOUT_ID, _('About'))
        menu_bar.Append(help_menu, _('&Help'))

        parent.SetMenuBar(menu_bar)
        # Mac tweaks...
        if wx.Platform == "__WXMAC__":
            wx.App_SetMacAboutMenuItemId(ABOUT_ID)
            wx.App_SetMacPreferencesMenuItemId(PREFS_ID)
            wx.App_SetMacExitMenuItemId(EXIT_ID)
            wx.App_SetMacHelpMenuTitleName(_('&Help'))

        # file history support
        self.file_history = wx.FileHistory(config.preferences.number_history)
        self.file_history.UseMenu(file_menu)
        files = common.load_history()
        files.reverse()
        for path in files:
            self.file_history.AddFileToHistory(path.strip())

        wx.EVT_MENU_RANGE(self, wx.ID_FILE1, wx.ID_FILE9,
                          self.open_from_history)

        wx.EVT_MENU(self, TREE_ID, self.show_tree)
        wx.EVT_MENU(self, PROPS_ID, self.show_props_window)
        wx.EVT_MENU(self, RAISE_ID, self.raise_all)
        wx.EVT_MENU(self, NEW_ID, self.new_app)
        wx.EVT_MENU(self, NEW_FROM_TEMPLATE_ID, self.new_app_from_template)
        wx.EVT_MENU(self, OPEN_ID, self.open_app)
        wx.EVT_MENU(self, SAVE_ID, self.save_app)
        wx.EVT_MENU(self, SAVE_AS_ID, self.save_app_as)
        wx.EVT_MENU(self, SAVE_TEMPLATE_ID, self.save_app_as_template)

        def generate_code(event):
            common.app_tree.app.generate_code()

        wx.EVT_MENU(self, GENERATE_CODE_ID, generate_code)
        wx.EVT_MENU(self, EXIT_ID, lambda e: self.Close())
        wx.EVT_MENU(self, MANUAL_ID, self.show_manual)
        wx.EVT_MENU(self, TUTORIAL_ID, self.show_tutorial)
        wx.EVT_MENU(self, ABOUT_ID, self.show_about_box)
        wx.EVT_MENU(self, PREFS_ID, self.edit_preferences)
        wx.EVT_MENU(self, MANAGE_TEMPLATES_ID, self.manage_templates)
        wx.EVT_MENU(self, IMPORT_ID, self.import_xrc)
        wx.EVT_MENU(self, wx.ID_REFRESH, self.preview)  # self.reload_app)

        PREVIEW_ID = wx.NewId()
        wx.EVT_MENU(self, PREVIEW_ID, self.preview)

        self.accel_table = wx.AcceleratorTable([
            (wx.ACCEL_CTRL, ord('N'), NEW_ID),
            (wx.ACCEL_CTRL, ord('O'), OPEN_ID),
            (wx.ACCEL_CTRL, ord('S'), SAVE_ID),
            (wx.ACCEL_CTRL | wx.ACCEL_SHIFT, ord('S'), SAVE_AS_ID),
            (wx.ACCEL_CTRL, ord('G'), GENERATE_CODE_ID),
            #(wx.ACCEL_CTRL, ord('I'), IMPORT_ID),
            (0, wx.WXK_F1, MANUAL_ID),
            (wx.ACCEL_CTRL, ord('Q'), EXIT_ID),
            (0, wx.WXK_F5, wx.ID_REFRESH),
            (0, wx.WXK_F2, TREE_ID),
            (0, wx.WXK_F3, PROPS_ID),
            (0, wx.WXK_F4, RAISE_ID),
            (wx.ACCEL_CTRL, ord('P'), PREVIEW_ID),
        ])
Beispiel #7
0
    def __init__(self, parent, id, title):

        wx.Frame.__init__(self, parent, id, title, (-1,-1), wx.Size(400,550))

        # Now Create the menu bar and items
        self.MenuBar = wx.MenuBar()
        FileMenu = wx.Menu()
        #hack
        about = FileMenu.Append(-1, 'About...')
        self.Bind(wx.EVT_MENU,self.OnAbout,about)
        
        FileMenu.Append(200, 'Page Setup', 'Setup the printer page')
        wx.EVT_MENU(self, 200, self.OnFilePageSetup)
        FileMenu.Append(201, 'Print Preview', 'Show the current plot on page')
        wx.EVT_MENU(self, 201, self.OnFilePrintPreview)
        FileMenu.Append(202, 'Print Plot', 'Print the current plot')
        wx.EVT_MENU(self, 202, self.OnFilePrint)
        FileMenu.Append(203, 'Save Plot', 'Save current plot')
        wx.EVT_MENU(self, 203, self.OnSaveFile)
        FileMenu.Append(205, 'Q&uit', 'Quit this Application')
        wx.EVT_MENU(self,205, self.OnFileExit)
        wx.App_SetMacExitMenuItemId(205) #mac-ify
        self.MenuBar.Append(FileMenu, '&File')
        
        #Plot Menu, shamelessly stolen from wx.lib.plot.TestFrame
        PlotMenu = wx.Menu()
        PlotMenu.Append(211, '&Redraw', 'Redraw plot')
        self.Bind(wx.EVT_MENU,self.OnPlotRedraw, id=211)
        PlotMenu.Append(212, '&Clear', 'Clear canvas')
        self.Bind(wx.EVT_MENU,self.OnPlotClear, id=212)
        PlotMenu.Append(213, '&Scale', 'Scale canvas')
        self.Bind(wx.EVT_MENU,self.OnPlotScale, id=213) 
        PlotMenu.Append(214, 'Enable &Zoom', 'Enable Mouse Zoom', kind=wx.ITEM_CHECK)
        self.Bind(wx.EVT_MENU,self.OnEnableZoom, id=214) 
        PlotMenu.Append(215, 'Enable &Grid', 'Turn on Grid', kind=wx.ITEM_CHECK)
        self.Bind(wx.EVT_MENU,self.OnEnableGrid, id=215)
        PlotMenu.Append(220, 'Enable &Legend', 'Turn on Legend', kind=wx.ITEM_CHECK)
        self.Bind(wx.EVT_MENU,self.OnEnableLegend, id=220)
        PlotMenu.Append(222, 'Enable &Point Label', 'Show Closest Point', kind=wx.ITEM_CHECK)
        self.Bind(wx.EVT_MENU,self.OnEnablePointLabel, id=222)
        PlotMenu.Append(235, '&Plot Reset', 'Reset to original plot')
        self.Bind(wx.EVT_MENU,self.OnReset, id=235)
        self.MenuBar.Append(PlotMenu, '&Plot')

        #Help Menu
        HelpMenu = wx.Menu()
        HelpMenu.Append(300, '&About', 'About...')
        wx.EVT_MENU(self, 300, self.OnAbout)
        
        if "__WXMAC__" in wx.PlatformInfo:
            #macify
            wx.App.SetMacAboutMenuItemId(300)
            wx.App_SetMacHelpMenuTitleName("&Help")
        else:
            self.MenuBar.Append(HelpMenu, "&Help")
        self.SetMenuBar(self.MenuBar)
        self.CreateStatusBar(1)
        self.SetStatusText("")
        
        #load presets
        try:
            preset_path = os.path.join(self.get_main_dir(), "presets.txt")
            if sys.platform == "darwin":
                preset_path = os.path.join(self.get_main_dir(), "../Resources/", "presets.txt")
            presets_file = open(preset_path,'r')
            presets = eval(presets_file.read())
        except SyntaxError:
            dlg = wx.MessageDialog(self,"Syntax error in presets.txt. Make sure there are no empty lines or statements.","Parse error",wx.OK | wx.ICON_INFORMATION)
            dlg.ShowModal()
            dlg.Destroy()
            presets = {'Error reading presets.txt':{}}
        
        #create tabs
        self.nb = wx.Notebook(self,-1)
        self.Params = ParamsPanel(self.nb, -1, presets)
        self.Results = ResultsPanel(self.nb, -1)
        self.Advanced = AdvancedPanel(self.nb, -1)
        
        self.nb.AddPage(self.Params, "Parameters")
        self.nb.AddPage(self.Results, "Results")
        self.nb.AddPage(self.Advanced, "Advanced")
Beispiel #8
0
    def updateMenus(self):
        """Create the main frame menus based on menuItems array."""

        global menuItems
        self.menuCommandMap = {}

        # Array of menus. Number to wxMenu.
        self.menus = {}

        # Three levels of priority.
        for level in range(len(menuItems)):
            if len(menuItems[level]) == 0:
                # No menu for this.
                self.menus[level] = None
                continue

            self.menus[level] = wx.Menu()
            self.menuBar.Append(self.menus[level],
                                language.translate("menu-" + str(level)))

            # Sort the items based on groups, and append separators where necessary.
            menuItems[level].sort(lambda x, y: cmp(x[3], y[3]))
            separated = []
            previousItem = None
            for item in menuItems[level]:
                if previousItem and previousItem[3] != item[3]:
                    separated.append(('-', '', False, item[3]))
                separated.append(item)
                previousItem = item

            # Create the menu items.
            for itemId, itemCommand, itemSeparate, itemGroup in separated:
                if itemId == '-':
                    # This is just a separator.
                    self.menus[level].AppendSeparator()
                    continue

                if itemSeparate and self.menus[level].GetMenuItemCount() > 0:
                    self.menus[level].AppendSeparator()

                menuItemId = 'menu-' + itemId

                accel = ''
                if language.isDefined(menuItemId + '-accel'):
                    accel = "\t" + language.translate(menuItemId + '-accel')

                # Generate a new ID for the item.
                wxId = wx.NewId()
                self.menuCommandMap[wxId] = itemCommand
                self.menus[level].Append(
                    wxId, uniConv(language.translate(menuItemId) + accel))
                wx.EVT_MENU(self, wxId, self.onPopupCommand)

                if host.isMac():
                    # Special menu items on Mac.
                    if itemId == 'about':
                        wx.App_SetMacAboutMenuItemId(wxId)
                    if itemId == 'quit':
                        wx.App_SetMacExitMenuItemId(wxId)
                    if itemId == 'show-snowberry-settings':
                        wx.App_SetMacPreferencesMenuItemId(wxId)

        if host.isMac():
            # Special Help menu on Mac.
            wx.App_SetMacHelpMenuTitleName(
                language.translate('menu-' + str(MENU_HELP)))

        self.SetMenuBar(self.menuBar)