Exemplo n.º 1
0
 def DrawOnDC(self, dc):
     decorator = self.pref.decorator if self.pref.labelVerses else SongDecorator(
     )
     r = Renderer(self.pref.format, decorator, self.pref.notations)
     start, end = self.text.GetSelection()
     if start == end:
         w, h = r.Render(self.text.GetText(), dc)
     else:
         w, h = r.Render(self.text.GetText(), dc,
                         self.text.LineFromPosition(start),
                         self.text.LineFromPosition(end))
     return w, h
Exemplo n.º 2
0
 def OnExportAsHtml(self, evt):
     n = self.AskExportFileName(_("HTML file"), "html")
     if n is not None:
         h = HtmlExporter(self.pref.format)
         r = Renderer(self.pref.format, h, self.pref.notations)
         start, end = self.text.GetSelection()
         if start == end:
             r.Render(self.text.GetText(), None)
         else:
             r.Render(self.text.GetText(), None,
                      self.text.LineFromPosition(start),
                      self.text.LineFromPosition(end))
         with open(n, "w", encoding='utf-8') as f:
             f.write(h.getHtml())
             f.close()
Exemplo n.º 3
0
 def checkParams(self, fractal):
     for current in filenames:
         args = Arguer.Argue([
             fractal, current, '--dim', filenames[current], '--zoom', '2',
             '--pan', '[-1.0,1.0]', '--iters', '50', '--com', '[-0.75,0.11]'
         ])
         r = Renderer.Render(args).draw()
         args = Arguer.Argue([
             fractal, current, '--dim', filenames[current], '--zoom', '5',
             '--pan', '[2.5,-0.5]', '--iters', '13'
         ])
         r = Renderer.Render(args).draw()
         self.assertTrue(os.path.isfile(current))
         self.assertTrue(
             self.checkDims(
                 filenames[current][:filenames[current].index('x')],
                 filenames[current][filenames[current].index('x') + 1:],
                 current))
Exemplo n.º 4
0
class PreviewCanvas(object):
    def __init__(self,
                 parent,
                 sf,
                 notations,
                 sd=SongDecorator(),
                 embedded=False):
        object.__init__(self)
        show_link = not embedded and platform.system() != 'Linux'
        self.link = None
        if show_link:
            self.main_panel = wx.Window(parent)
            bSizer = wx.BoxSizer(wx.VERTICAL)
            self.link = wx.adv.HyperlinkCtrl(
                self.main_panel, 0, _("Copy formatted song to clipboard"), '')
            tt = wx.ToolTip(
                _("Copy formatted song to clipboard, so that it can be pasted in any program and printed"
                  ))
            self.link.SetToolTip(tt)
            bSizer.Add(self.link, 0, wx.EXPAND)
            parent = self.main_panel
        self.panel = wx.ScrolledWindow(parent, style=wx.BORDER_DOUBLE)
        self.panel.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)
        self.pixedScrolled = 10
        self.panel.SetScrollbars(self.pixedScrolled, self.pixedScrolled, 0, 0)
        self.panel.Bind(wx.EVT_PAINT, self.OnPaint, self.panel)
        self.panel.SetBackgroundColour(wx.WHITE)
        self.text = ""
        if show_link:
            bSizer.Add(self.panel, 1, wx.EXPAND)
        else:
            self.main_panel = self.panel
        #SongFormat
        self.renderer = Renderer(sf, sd, notations)
        if show_link:
            self.main_panel.SetSizer(bSizer)
            self.main_panel.Layout()

    def OnPaint(self, e):
        #print("OnPaint")
        dc = wx.AutoBufferedPaintDC(self.panel)
        self.panel.PrepareDC(dc)
        dc.SetBackground(wx.WHITE_BRUSH)
        dc.Clear()
        w, h = self.renderer.Render(self.text, dc)
        self.panel.SetVirtualSize(wx.Size(w, h))

    def Refresh(self, text):
        self.text = text
        self.panel.Refresh()

    def SetDecorator(self, sd):
        self.renderer.SetDecorator(sd)
Exemplo n.º 5
0
# Create a png fractal

import Arguer
import Renderer

Renderer.Render(Arguer.Argue("command_line")).draw()