~redache/jokosher/MusicXMLEditor

« back to all changes in this revision

Viewing changes to Jokosher/ScoreControlBox.py

  • Committer: David Williams
  • Date: 2010-07-19 14:44:41 UTC
  • Revision ID: redache@gmail.com-20100719144441-tscal13efcgeq5nc
Widget size overriden in ScoreEventViewer, It is now based on measure duration compared ot the BPM/Time Signature. ScoreControlBox added to Score instrument shelf

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
#
 
3
#       THIS FILE IS PART OF THE JOKOSHER PROJECT AND LICENSED UNDER THE GPL. SEE
 
4
#       THE 'COPYING' FILE FOR DETAILS
 
5
#
 
6
#       ScoreControlBox.py
 
7
#       
 
8
#       This is the GUI class for the Note Selector Panel for Score Instruments. It will
 
9
#       take a selection and return the notes duration.
 
10
#
 
11
#-------------------------------------------------------------------------------
 
12
import pygtk
 
13
pygtk.require("2.0")
 
14
import gtk
 
15
import pango
 
16
 
 
17
 
 
18
class ScoreControlBox(gtk.HBox):
 
19
        
 
20
        # Had to use the unicode code points as \U000note doesn't work correctly.
 
21
 
 
22
        noteUTF8 = {"whole":"𝅝", "half":"𝅗𝅥", "quarter":"𝅘𝅥", "8th":"𝅘𝅥𝅮", "16th":"𝅘𝅥𝅯", "32nd":"𝅘𝅥𝅰", "64th":"𝅘𝅥𝅱", "128th":"𝅘𝅥𝅲", "whole-rest": "𝄻", "half-rest": "𝄼", "quarter-rest": "𝄽", "8th-rest": "𝄾", "16th-rest": "𝄿", "32nd-rest": "𝅀", "64th-rest": "𝅁", "128th-rest": "𝅂"}
 
23
 
 
24
        #_____________________________________________________________________
 
25
 
 
26
        def __init__(self):
 
27
                gtk.Container.__init__(self)
 
28
                
 
29
        
 
30
                attr = pango.AttrList()
 
31
                size = pango.AttrSize(20000,0,-1)
 
32
                attr.insert(size)
 
33
                pos = 0
 
34
 
 
35
                dictValues = self.noteUTF8.values()
 
36
                dictValues.sort()
 
37
 
 
38
                for i in range(16):
 
39
                        temp = dictValues[pos]
 
40
                        button = gtk.Button(temp)
 
41
                        label = button.child
 
42
                        label.set_attributes(attr)
 
43
                        self.add(button)
 
44
                        pos += 1
 
45
                        button.connect("clicked", self.OnClick)
 
46
        #_____________________________________________________________________
 
47
        def OnClick(self,widget):
 
48
                selDuration = widget.get_label()
 
49
                
 
50
                for key, value in self.noteUTF8.iteritems():
 
51
                        if selDuration == value:
 
52
                                print key
 
53