Esempio n. 1
0
 def OnNewsAndUpdates(self, evt):
     MyUpdateDialog.check_and_update(self.frame, self.pref, True)
Esempio n. 2
0
	def OnNewsAndUpdates(self, evt):
		MyUpdateDialog.check_and_update(self.frame, self.pref, True)
Esempio n. 3
0
 def __init__(self, res):
     SDIMainFrame.__init__(
         self,
         res,
         'MainFrame',
         'songpress',
         'Skeed',
         _('song'),
         'crd',
         _('Songpress - Il Canzonatore'),
         glb.AddPath('img/songpress.ico'),
         glb.VERSION,
         _("http://www.skeed.it/songpress"),
         (_(u"Copyright (c) 2009-{year} Luca Allulli - Skeed\nLocalization:\n{translations}"
            )).format(year=glb.YEAR,
                      translations="\n".join([
                          u"- {}: {}".format(glb.languages[x],
                                             glb.translators[x])
                          for x in glb.languages
                      ])),
         _("Licensed under the terms and conditions of the GNU General Public License, version 2"
           ),
         _("Special thanks to:\n  * The Pyhton programming language (http://www.python.org)\n  * wxWidgets (http://www.wxwidgets.org)\n  * wxPython (http://www.wxpython.org)\n  * Editra (http://editra.org/) (for the error reporting dialog and... the editor itself!)\n  * python-pptx (for PowerPoint export)"
           ),
         _import_formats,
     )
     self.pref = Preferences()
     self.SetDefaultExtension(self.pref.defaultExtension)
     self.text = Editor(self)
     dt = SDIDropTarget(self)
     self.text.SetDropTarget(dt)
     self.frame.Bind(wx.stc.EVT_STC_UPDATEUI, self.OnUpdateUI, self.text)
     # Other objects
     self.previewCanvas = PreviewCanvas(self.frame, self.pref.format,
                                        self.pref.notations,
                                        self.pref.decorator)
     self.AddMainPane(self.text)
     self.AddPane(self.previewCanvas.main_panel,
                  aui.AuiPaneInfo().Right().BestSize(240, 400),
                  _('Preview'), 'preview')
     if self.previewCanvas.link is not None:
         self.previewCanvas.main_panel.Bind(wx.adv.EVT_HYPERLINK,
                                            self.OnCopyAsImage,
                                            self.previewCanvas.link)
     self.mainToolBar = aui.AuiToolBar(self.frame,
                                       wx.ID_ANY,
                                       wx.DefaultPosition,
                                       agwStyle=aui.AUI_TB_PLAIN_BACKGROUND)
     self.mainToolBar.SetToolBitmapSize(wx.Size(16, 16))
     self.AddTool(self.mainToolBar, 'new', 'img/new.png', _("New"),
                  _("Create a new song"))
     self.AddTool(self.mainToolBar, 'open', 'img/open.png', _("Open"),
                  _("Open an existing song"))
     self.AddTool(self.mainToolBar, 'save', 'img/save.png', _("Save"),
                  _("Save song with the current filename"))
     self.mainToolBar.AddSeparator()
     self.undoTool = self.AddTool(self.mainToolBar, 'undo', 'img/undo.png',
                                  _("Undo"), _("Undo last edit"))
     self.redoTool = self.AddTool(self.mainToolBar, 'redo', 'img/redo.png',
                                  _("Redo"),
                                  _("Redo previously undone edit"))
     self.redoTool = wx.xrc.XRCID('redo')
     self.mainToolBar.AddSeparator()
     self.cutTool = self.AddTool(self.mainToolBar, 'cut', 'img/cut.png',
                                 _("Cut"),
                                 _("Move selected text in the clipboard"))
     self.copyTool = self.AddTool(self.mainToolBar, 'copy', 'img/copy.png',
                                  _("Copy"),
                                  _("Copy selected text in the clipboard"))
     self.copyOnlyTextTool = wx.xrc.XRCID('copyOnlyText')
     if platform.system() == 'Windows':
         self.AddTool(
             self.mainToolBar, 'copyAsImage', 'img/copyAsImage2.png',
             _("Copy as Image"),
             _("Copy the whole FORMATTED song (or selected verses) to the clipboard"
               ))
     self.pasteTool = self.AddTool(
         self.mainToolBar, 'paste', 'img/paste.png', _("Paste"),
         _("Read text from the clipboard and place it at the cursor position"
           ))
     self.pasteChordsTool = self.AddTool(
         self.mainToolBar, 'pasteChords', 'img/pasteChords.png',
         _("PasteChords"),
         _("Integrate chords of copied text into current selection"))
     self.mainToolBar.Realize()
     self.mainToolBarPane = self.AddPane(
         self.mainToolBar,
         aui.AuiPaneInfo().ToolbarPane().Top().Row(1).Position(1),
         _('Standard'), 'standard')
     self.formatToolBar = aui.AuiToolBar(
         self.frame, wx.ID_ANY, agwStyle=aui.AUI_TB_PLAIN_BACKGROUND)
     self.formatToolBar.SetExtraStyle(aui.AUI_TB_PLAIN_BACKGROUND)
     self.fontChooser = FontComboBox(self.formatToolBar, -1,
                                     self.pref.format.face)
     self.formatToolBar.AddControl(self.fontChooser)
     self.frame.Bind(wx.EVT_COMBOBOX, self.OnFontSelected, self.fontChooser)
     wx.UpdateUIEvent.SetUpdateInterval(500)
     self.frame.Bind(wx.EVT_UPDATE_UI, self.OnIdle, self.frame)
     self.frame.Bind(wx.EVT_TEXT_CUT, self.OnTextCutCopy, self.text)
     self.frame.Bind(wx.EVT_TEXT_COPY, self.OnTextCutCopy, self.text)
     self.fontChooser.Bind(wx.EVT_TEXT_ENTER, self.OnFontSelected,
                           self.fontChooser)
     self.fontChooser.Bind(wx.EVT_KILL_FOCUS, self.OnFontSelected,
                           self.fontChooser)
     self.AddTool(self.formatToolBar, 'title', 'img/title.png',
                  _("Insert title"),
                  _("Insert a command to display song title"))
     self.AddTool(self.formatToolBar, 'chord', 'img/chord.png',
                  _("Insert chord"),
                  _("Insert square brackets that will host a chord"))
     self.AddTool(self.formatToolBar, 'chorus', 'img/chorus.png',
                  _("Insert chorus"),
                  _("Insert a couple of commands that will contain chorus"))
     self.AddTool(
         self.formatToolBar,
         'verseWithCustomLabelOrWithoutLabel',
         'img/verse.png',
         _("Insert verse with custom label or without label"),
         _("Insert a commands that will display a verse with a custom label"
           ),
     )
     labelVersesTool = self.formatToolBar.AddToggleTool(  # AddToggleTool (agw) or AddTool
         wx.xrc.XRCID('labelVerses'),
         wx.Bitmap(wx.Image(glb.AddPath("img/labelVerses.png"))),
         wx.NullBitmap,
         True,
         None,
         _("Show verse labels"),
         _("Show or hide verse and chorus labels"),
     )
     self.labelVersesToolId = labelVersesTool.GetId()
     showChordsIcon = wx.StaticBitmap(
         self.formatToolBar, -1,
         wx.Bitmap(wx.Image(glb.AddPath('img/showChords.png'))))
     self.formatToolBar.AddControl(showChordsIcon)
     self.showChordsChooser = wx.Slider(self.formatToolBar, -1, 0, 0, 2,
                                        wx.DefaultPosition, (100, -1),
                                        wx.SL_AUTOTICKS | wx.SL_HORIZONTAL)
     tt1 = wx.ToolTip(_("Hide or show chords in formatted song"))
     tt2 = wx.ToolTip(_("Hide or show chords in formatted song"))
     self.showChordsChooser.SetToolTip(tt1)
     showChordsIcon.SetToolTip(tt2)
     self.frame.Bind(wx.EVT_SCROLL, self.OnFontSelected,
                     self.showChordsChooser)
     self.formatToolBar.AddControl(self.showChordsChooser, "pippo")
     self.formatToolBar.Realize()
     self.formatToolBarPane = self.AddPane(
         self.formatToolBar,
         aui.AuiPaneInfo().ToolbarPane().Top().Row(1).Position(2),
         _('Format'), 'format')
     self.BindMyMenu()
     self.frame.Bind(EVT_TEXT_CHANGED, self.OnTextChanged)
     self.exportMenuId = xrc.XRCID('export')
     self.exportToClipboardAsAVectorImage = xrc.XRCID(
         'exportToClipboardAsAVectorImage')
     self.exportAsEmfMenuId = xrc.XRCID('exportAsEmf')
     self.cutMenuId = xrc.XRCID('cut')
     self.copyMenuId = xrc.XRCID('copy')
     self.copyAsImageMenuId = xrc.XRCID('copyAsImage')
     self.pasteMenuId = xrc.XRCID('paste')
     self.pasteChordsMenuId = xrc.XRCID('pasteChords')
     self.removeChordsMenuId = xrc.XRCID('removeChords')
     self.labelVersesMenuId = xrc.XRCID('labelVerses')
     self.noChordsMenuId = xrc.XRCID('noChords')
     self.oneVerseForEachChordPatternMenuId = xrc.XRCID(
         'oneVerseForEachChordPattern')
     self.wholeSongMenuId = xrc.XRCID('wholeSong')
     if platform.system() != 'Windows':
         self.menuBar.GetMenu(0).FindItemById(
             self.exportMenuId).GetSubMenu().Delete(
                 self.exportToClipboardAsAVectorImage)
         self.menuBar.GetMenu(1).Delete(self.copyAsImageMenuId)
         self.menuBar.GetMenu(0).FindItemById(
             self.exportMenuId).GetSubMenu().Delete(self.exportAsEmfMenuId)
     self.findReplaceDialog = None
     self.CheckLabelVerses()
     self.SetFont()
     self.text.SetFont(self.pref.editorFace, self.pref.editorSize)
     self.FinalizePaneInitialization()
     # Reassign caption value to override caption saved in preferences (it could be another language)
     self._mgr.GetPane('preview').caption = _('Preview')
     self._mgr.GetPane('standard').caption = _('Standard')
     self._mgr.GetPane('format').caption = _('Format')
     if 'firstTimeEasyKey' in self.pref.notices:
         msg = _(
             "You are not a skilled guitarist? Songpress can help you: when you open a song, it can detect if chords are difficult. If this is the case, Songpress will alert you, and offer to transpose your song to the easiest key, automatically.\n\nDo you want to turn this option on?"
         )
         d = wx.MessageDialog(self.frame, msg, _("Songpress"),
                              wx.YES_NO | wx.ICON_QUESTION)
         if d.ShowModal() == wx.ID_YES:
             self.pref.autoAdjustEasyKey = True
             msg = _(
                 "Please take a minute to set up your skill as a guitarist. For each group of chords, tell Songpress how much you like them."
             )
             d = wx.MessageDialog(self.frame, msg, _("Songpress"), wx.OK)
             d.ShowModal()
             f = MyPreferencesDialog(self.frame, self.pref, easyChords)
             f.notebook.SetSelection(1)
             if f.ShowModal() == wx.ID_OK:
                 self.text.SetFont(self.pref.editorFace,
                                   int(self.pref.editorSize))
                 self.SetDefaultExtension(self.pref.defaultExtension)
     MyUpdateDialog.check_and_update(self.frame, self.pref)
     self.frame.Maximize(True)
Esempio n. 4
0
	def __init__(self, res):
		SDIMainFrame.__init__(
			self,
			res,
			'MainFrame',
			'songpress',
			'Skeed',
			_('song'),
			'crd',
			_('Songpress - Il Canzonatore'),
			glb.AddPath('img/songpress.ico'),
			glb.VERSION,
			_("http://www.skeed.it/songpress"),
			(_(u"Copyright (c) 2009-{year} Luca Allulli - Skeed\nLocalization:\n{translations}")).format(
				year=glb.YEAR,
				translations="\n".join([u"- {}: {}".format(glb.languages[x], glb.translators[x]) for x in glb.languages])
			),
			_("Licensed under the terms and conditions of the GNU General Public License, version 2"),
			_("Special thanks to:\n  * The Pyhton programming language (http://www.python.org)\n  * wxWidgets (http://www.wxwidgets.org)\n  * wxPython (http://www.wxpython.org)\n  * Editra (http://editra.org/) (for the error reporting dialog and... the editor itself!)"),
			_import_formats,
		)
		self.pref = Preferences()
		self.SetDefaultExtension(self.pref.defaultExtension)
		self.text = Editor(self)
		dt = SDIDropTarget(self)
		self.text.SetDropTarget(dt)
		self.frame.Bind(wx.stc.EVT_STC_UPDATEUI, self.OnUpdateUI, self.text)
		# Other objects
		self.previewCanvas = PreviewCanvas(self.frame, self.pref.format, self.pref.notations, self.pref.decorator)
		self.AddMainPane(self.text)
		#self.previewCanvas.main_panel.SetSize(wx.Size(400, 800))
		self.previewCanvasPane = self.AddPane(self.previewCanvas.main_panel, wx.aui.AuiPaneInfo().Right(), _('Preview'), 'preview')
		self.previewCanvas.main_panel.Bind(wx.EVT_HYPERLINK, self.OnCopyAsImage, self.previewCanvas.link)
		#self.previewCanvasPane.BestSize(wx.Size(400,800))
		# self.mainToolBar2 = wx.aui.AuiToolBar(self.frame, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize)
		self.mainToolBar = wx.ToolBar(self.frame, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize)
		self.mainToolBar.SetToolBitmapSize(wx.Size(16, 16))
		self.mainToolBar.AddTool(wx.xrc.XRCID('new'), wx.BitmapFromImage(wx.Image(glb.AddPath(glb.AddPath("img/new.png")))),
			shortHelpString = _("New"),
			longHelpString = _("Create a new song")
		)
		self.mainToolBar.AddTool(wx.xrc.XRCID('open'), wx.BitmapFromImage(wx.Image(glb.AddPath("img/open.png"))),
			shortHelpString = _("Open"),
			longHelpString = _("Open an existing song")
		)
		self.mainToolBar.AddTool(wx.xrc.XRCID('save'), wx.BitmapFromImage(wx.Image(glb.AddPath("img/save.png"))),
			shortHelpString = _("Save"),
			longHelpString = _("Save song with the current filename")
		)
		self.mainToolBar.AddSeparator()
		self.undoTool = wx.xrc.XRCID('undo')
		self.mainToolBar.AddTool(self.undoTool, wx.BitmapFromImage(wx.Image(glb.AddPath("img/undo.png"))),
			shortHelpString = _("Undo"),
			longHelpString = _("Undo last edit")
		)
		self.redoTool = wx.xrc.XRCID('redo')
		self.mainToolBar.AddTool(self.redoTool, wx.BitmapFromImage(wx.Image(glb.AddPath("img/redo.png"))),
			shortHelpString = _("Redo"),
			longHelpString = _("Redo previously undone edit")
		)
		self.mainToolBar.AddSeparator()
		self.cutTool = wx.xrc.XRCID('cut')
		self.mainToolBar.AddTool(self.cutTool, wx.BitmapFromImage(wx.Image(glb.AddPath("img/cut.png"))),
			shortHelpString = _("Cut"),
			longHelpString = _("Move selected text in the clipboard")
		)
		self.copyTool = wx.xrc.XRCID('copy')
		self.mainToolBar.AddTool(self.copyTool, wx.BitmapFromImage(wx.Image(glb.AddPath("img/copy.png"))),
			shortHelpString = _("Copy"),
			longHelpString = _("Copy selected text in the clipboard")
		)
		self.copyOnlyTextTool = wx.xrc.XRCID('copyOnlyText')
		if platform.system() == 'Windows':
			self.mainToolBar.AddTool(wx.xrc.XRCID('copyAsImage'), wx.BitmapFromImage(wx.Image(glb.AddPath("img/copyAsImage2.png"))),
				shortHelpString = _("Copy as Image"),
				longHelpString = _("Copy the whole FORMATTED song (or selected verses) to the clipboard")
			)
		self.pasteTool = wx.xrc.XRCID('paste')
		self.mainToolBar.AddTool(self.pasteTool, wx.BitmapFromImage(wx.Image(glb.AddPath("img/paste.png"))),
			shortHelpString = _("Paste"),
			longHelpString = _("Read text from the clipboard and place it at the cursor position")
		)
		self.pasteChordsTool = wx.xrc.XRCID('pasteChords')
		self.mainToolBar.AddTool(self.pasteChordsTool, wx.BitmapFromImage(wx.Image(glb.AddPath("img/pasteChords.png"))),
			shortHelpString = _("PasteChords"),
			longHelpString = _("Integrate chords of copied text into current selection")
		)
		self.mainToolBar.Realize()
		self.mainToolBarPane = self.AddPane(self.mainToolBar, wx.aui.AuiPaneInfo().ToolbarPane().Top().Row(1).Position(1), _('Standard'), 'standard')
		self.formatToolBar = wx.ToolBar(self.frame, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize,
			wx.TB_FLAT | wx.TB_NODIVIDER)
		self.fontChooser = FontComboBox(self.formatToolBar, -1, self.pref.format.face)
		self.formatToolBar.AddControl(self.fontChooser)
		self.frame.Bind(wx.EVT_COMBOBOX, self.OnFontSelected, self.fontChooser)
		wx.UpdateUIEvent.SetUpdateInterval(500)
		self.frame.Bind(wx.EVT_UPDATE_UI, self.OnIdle, self.frame)
		self.frame.Bind(wx.EVT_TEXT_CUT, self.OnTextCutCopy, self.text)
		self.frame.Bind(wx.EVT_TEXT_COPY, self.OnTextCutCopy, self.text)
		self.fontChooser.Bind(wx.EVT_TEXT_ENTER, self.OnFontSelected, self.fontChooser)
		self.fontChooser.Bind(wx.EVT_KILL_FOCUS, self.OnFontSelected, self.fontChooser)
		self.formatToolBar.AddTool(wx.xrc.XRCID('title'), wx.BitmapFromImage(wx.Image(glb.AddPath("img/title.png"))),
			shortHelpString = _("Insert title"),
			longHelpString = _("Insert a command to display song title")
		)
		self.formatToolBar.AddTool(wx.xrc.XRCID('chord'), wx.BitmapFromImage(wx.Image(glb.AddPath("img/chord.png"))),
			shortHelpString = _("Insert chord"),
			longHelpString = _("Insert square brackets that will host a chord")
		)
		self.formatToolBar.AddTool(wx.xrc.XRCID('chorus'), wx.BitmapFromImage(wx.Image(glb.AddPath("img/chorus.png"))),
			shortHelpString = _("Insert chorus"),
			longHelpString = _("Insert a couple of commands that will contain chorus")
		)
		self.formatToolBar.AddTool(wx.xrc.XRCID('verseWithCustomLabelOrWithoutLabel'), wx.BitmapFromImage(wx.Image(glb.AddPath("img/verse.png"))),
			shortHelpString = _("Insert verse with custom label or without label"),
			longHelpString = _("Insert a commands that will display a verse with a custom label")
		)
		labelVersesTool = self.formatToolBar.AddTool(wx.xrc.XRCID('labelVerses'), wx.BitmapFromImage(wx.Image(glb.AddPath("img/labelVerses.png"))), isToggle=True,
			shortHelpString = _("Show verse labels"),
			longHelpString = _("Show or hide verse and chorus labels")
		)
		self.labelVersesToolId = labelVersesTool.GetId()
		showChordsIcon = wx.StaticBitmap(self.formatToolBar, -1, wx.Bitmap('img/showChords.png'))
		self.formatToolBar.AddControl(showChordsIcon)
		self.showChordsChooser = wx.Slider(self.formatToolBar, -1, 0, 0, 2, wx.DefaultPosition, (100, -1), wx.SL_AUTOTICKS|wx.SL_HORIZONTAL)
		tt1 = wx.ToolTip(_("Hide or show chords in formatted song"))
		tt2 = wx.ToolTip(_("Hide or show chords in formatted song"))
		self.showChordsChooser.SetToolTip(tt1)
		showChordsIcon.SetToolTip(tt2)
		self.frame.Bind(wx.EVT_SCROLL, self.OnFontSelected, self.showChordsChooser)
		self.formatToolBar.AddControl(
			self.showChordsChooser,
			"pippo"
		)
		self.formatToolBar.Realize()
		self.formatToolBarPane = self.AddPane(self.formatToolBar, wx.aui.AuiPaneInfo().ToolbarPane().Top().Row(1).Position(2), _('Format'), 'format')
		self.BindMyMenu()
		self.frame.Bind(EVT_TEXT_CHANGED, self.OnTextChanged)
		self.exportMenuId = xrc.XRCID('export')
		self.exportToClipboardAsAVectorImage = xrc.XRCID('exportToClipboardAsAVectorImage')
		self.exportAsEmfMenuId = xrc.XRCID('exportAsEmf')
		self.cutMenuId = xrc.XRCID('cut')
		self.copyMenuId = xrc.XRCID('copy')
		self.copyAsImageMenuId = xrc.XRCID('copyAsImage')
		self.pasteMenuId = xrc.XRCID('paste')
		self.pasteChordsMenuId = xrc.XRCID('pasteChords')
		self.removeChordsMenuId = xrc.XRCID('removeChords')
		self.labelVersesMenuId = xrc.XRCID('labelVerses')
		self.noChordsMenuId = xrc.XRCID('noChords')
		self.oneVerseForEachChordPatternMenuId = xrc.XRCID('oneVerseForEachChordPattern')
		self.wholeSongMenuId = xrc.XRCID('wholeSong')
		if platform.system() != 'Windows':
			self.menuBar.GetMenu(0).FindItemById(self.exportMenuId).GetSubMenu().Delete(self.exportToClipboardAsAVectorImage)
			self.menuBar.GetMenu(1).Delete(self.copyAsImageMenuId)
			self.menuBar.GetMenu(0).FindItemById(self.exportMenuId).GetSubMenu().Delete(self.exportAsEmfMenuId)
		self.findReplaceDialog = None
		self.CheckLabelVerses()
		self.SetFont()
		self.text.SetFont(self.pref.editorFace, self.pref.editorSize)
		self.FinalizePaneInitialization()
		# Reassign caption value to override caption saved in preferences (it could be another language)
		self.previewCanvasPane.caption = _('Preview')
		self.mainToolBar.caption = _('Standard')
		self.formatToolBar.caption = _('Format')
		if 'firstTimeEasyKey' in self.pref.notices:
			msg = _("You are not a skilled guitarist? Songpress can help you: when you open a song, it can detect if chords are difficult. If this is the case, Songpress will alert you, and offer to transpose your song to the easiest key, automatically.\n\nDo you want to turn this option on?")
			d = wx.MessageDialog(self.frame, msg, _("Songpress"), wx.YES_NO | wx.ICON_QUESTION)
			if d.ShowModal() == wx.ID_YES:
				self.pref.autoAdjustEasyKey = True
				msg = _("Please take a minute to set up your skill as a guitarist. For each group of chords, tell Songpress how much you like them.")
				d = wx.MessageDialog(self.frame, msg, _("Songpress"), wx.OK)
				d.ShowModal()
				f = MyPreferencesDialog(self.frame, self.pref, easyChords)
				f.notebook.SetSelection(1)
				if f.ShowModal() == wx.ID_OK:
					self.text.SetFont(self.pref.editorFace, int(self.pref.editorSize))
					self.SetDefaultExtension(self.pref.defaultExtension)
		MyUpdateDialog.check_and_update(self.frame, self.pref)