1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#!/usr/bin/env python
import os
os.environ['SUGAR_BUNDLE_PATH'] = os.path.join(os.path.split(__file__)[:-1])[0]
from gi.repository import Gtk
from stafflib import StaffArea
w = Gtk.Window()
w.maximize()
w.connect('destroy', lambda w: Gtk.main_quit())
vbox = Gtk.Box()
vbox.set_orientation(Gtk.Orientation.VERTICAL)
staff = StaffArea()
vbox.pack_start(staff, True, True, 0)
notes = ['C', 'D', 'E', 'F', 'G', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'A', 'B', 'C']
notesbox = Gtk.Box()
def button_toggled_cb(widget, note):
active = widget.get_active()
if active:
staff.select_note(note)
else:
staff.unselect_note(note)
count = 1
for i in notes:
button = Gtk.ToggleButton(i)
button.connect('toggled', button_toggled_cb, count)
button.show()
notesbox.pack_start(button, True, True, 0)
count += 1
notesbox.show()
vbox.pack_start(notesbox, False, True, 0)
vbox.show()
w.add(vbox)
staff.show()
w.show()
Gtk.main()
|