Abraham,

thank you very much! Somehow I missed that functionality of Frescobaldi.
Well, at least I learned something ;)

Thanks again and best regards,

Leszek.



>
> Message: 2
> Date: Thu, 10 Dec 2015 12:16:40 -0700 (MST)
> From: tisimst <tisimst.lilyp...@gmail.com>
> To: lilypond-user@gnu.org
> Subject: Re: trying to write a simple python beaming snippet for
>         Frescobaldi
> Message-ID:
>         <
> caczy+cbaz2d0vymc9ssdp5+jdo+owbhcolopz5snq7z_kzh...@mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Leszek,
>
> Just thought I'd bring this up (though I know you've already put in a bunch
> of work. You can add a keyboard shortcut to the "Quick Insert" > "Beam"
> option. Following the attached image, here's the steps (since it doesn't
> show up in the default set of keyboard shortcuts in the preferences
> window):
>
> 1. Right-click on the "Beam" option in the Quick Insert tool (if you can't
> see the Quick Insert tool, you'll need to open it via the "Tools" > "Quick
> Insert" menu option).
> 2. Click on "Configure Keyboard Shortcut (None)"
> 3. Click on the "Use a custom shortcut" radio button
> 4. Click on the input box next to "Primary shortcut"
> 5. Now, hit the "Ctrl" and "[" buttons at the same time on your keyboard to
> save the key combination and click on "OK" to save the shortcut
> 6. Select the group of notes you want to apply the beam to and hit "Ctrl +
> [" to have Frescobaldi insert the beam group (just like your code does).
>
> Best,
> Abraham
>
> On Thu, Dec 10, 2015 at 8:14 AM, Leszek Wro?ski [via Lilypond] <
> ml-node+s1069038n184633...@n5.nabble.com> wrote:
>
> > You're right, thanks! This showed I was actually doing the correct thing
> > when checking whether a string element was a space. Now I see that
> actually
> > Frescobaldi starts calculating the lines from the 2nd one (that is, after
> > the line with the initial -*- expression). And so the error was when I
> was
> > assigning
> >
> > mysequence[x] = '['
> >
> > because, as I have just learned, strings in Python are immutable. Gosh.
> This
> > does not explain everything what was going on, most probably due to my
> > incompetence. But now I have something that's working:
> >
> > x = 0
> > y = 0
> > mysequence = text
> > while x < len(text):
> >   if text[x] == ' ' and y = 0:
> >     mysequence = mysequence + '[ '
> >     y = y + 1
> >   else:
> >     mysequence = mysequence + text[x]
> >   x = x + 1
> > text = mysequence + ']'
> >
> > So when I select "d16 e8 f8" it returns "d16[ e8 f8]" as I intended. Now
> I
> > will make it nicer :-)
> >
> > Thanks you very much, Jacques!
> >
> > On 10 December 2015 at 12:09, Jacques Menu <[hidden email]
> > <http:///user/SendEmail.jtp?type=node&node=184633&i=0>> wrote:
> >
> >> Hello Leszek,
> >>
> >> How about:
> >>
> >>
> >> >>> var = "fo a"
> >> >>> var[2]
> >> ' '
> >> >>> var[2] == ' '
> >> True
> >>
> >>
> >> JM
> >>
> >> Le 10 d?c. 2015 ? 11:33, Leszek Wro?ski <[hidden email]
> >> <http:///user/SendEmail.jtp?type=node&node=184633&i=1>> a ?crit :
> >>
> >> Guys,
> >>
> >> Frescobaldi has the useful 'slur for the selected notes' snippet under
> >> C-(. I want to have the same functionality for beams. That is, I want
> to be
> >> able to select some notes, and then via the snippet insert a '[' in the
> >> first space (that is, after the first note), and then a ']' at the end.
> >>
> >> Unfortunately, I have never in my life written a line of python... till
> >> this day, that is. So, I'm trying the following ('W' is for whitespace):
> >>
> >> 1 -*- name: mybeam; python; selection: strip;
> >> 2 x = 0
> >> 3 mysequence = text
> >> 4 while x < len(text):
> >> 5 WW if text[x] == ' ':
> >> 6 WWWW mysequence[x] = '['
> >> 7 WWWW break
> >> 8 WW x = x + 1
> >> 9 text = mysequence + ']'
> >>
> >> Notice that line 5 contains a space between the quotes. Of course I need
> >> to add conditions regarding what to do if there's no space in the
> selection
> >> etc. But that's for later, once this basic script actually works. As you
> >> can see, I thought I'd copy the selection to 'mysequence' string to
> >> manipulate on it; this is probably unneeded. But after writing the
> above I
> >> got, at line 5, an error "TypeError: 'unicode' object does not support
> item
> >> assignment".
> >>
> >> What I found weird is that to my untrained eyes line 5 does no
> assigning,
> >> but rather checks whether the xth element of the string text is a space.
> >> Anyway, after some googling I decided to substitute "is" for "==" in
> line
> >> 5. Right now the script does not give any errors, but it only adds a
> ']' at
> >> the end of the selection. I'm apparently unable to check whether the xth
> >> element of the string text is a space. I tried
> >>
> >> if text[x] == ' %d':
> >>
> >> and
> >>
> >> if text[x] ==  u"\u0020":
> >>
> >> and
> >>
> >> if text[x].isspace():
> >>
> >> to no avail (the last one gave the "unicode object does not support item
> >> assignment" error again, which I don't understand at all, having copied
> the
> >> command from
> >>
> http://www.ehow.com/how_12112665_determine-character-whitespace-python.html
> ).
> >> Could anyone give me a hint on this?
> >>
> >> Best regards,
> >>
> >> Leszek.
> >>
> >> _______________________________________________
> >> lilypond-user mailing list
> >> [hidden email] <http:///user/SendEmail.jtp?type=node&node=184633&i=2>
> >> https://lists.gnu.org/mailman/listinfo/lilypond-user
> >>
> >>
> >>
> >
> > _______________________________________________
> > lilypond-user mailing list
> > [hidden email] <http:///user/SendEmail.jtp?type=node&node=184633&i=3>
> > https://lists.gnu.org/mailman/listinfo/lilypond-user
> >
> >
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> >
> http://lilypond.1069038.n5.nabble.com/trying-to-write-a-simple-python-beaming-snippet-for-Frescobaldi-tp184624p184633.html
> > To start a new topic under User, email
> ml-node+s1069038n...@n5.nabble.com
> > To unsubscribe from Lilypond, click here
> > <
> http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=2&code=dGlzaW1zdC5saWx5cG9uZEBnbWFpbC5jb218Mnw4MzU3Njg3MDU=
> >
> > .
> > NAML
> > <
> http://lilypond.1069038.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
> adding-custom-keyboard-shortcut-to-frescobaldi.png (161K) <
> http://lilypond.1069038.n5.nabble.com/attachment/184636/0/adding-custom-keyboard-shortcut-to-frescobaldi.png
> >
>
>
>
>
> --
> View this message in context:
> http://lilypond.1069038.n5.nabble.com/trying-to-write-a-simple-python-beaming-snippet-for-Frescobaldi-tp184624p184636.html
> Sent from the User mailing list archive at Nabble.com.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://lists.gnu.org/archive/html/lilypond-user/attachments/20151210/574c99f3/attachment.html
> >
>
>
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to