Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import kivy
- kivy.require('1.0.8')
- from sys import exit
- from kivy.app import App
- from kivy.core.window import Window
- from kivy.uix.button import Button
- from kivy.uix.label import Label
- from kivy.uix.anchorlayout import AnchorLayout
- from kivy.uix.scrollview import ScrollView
- from kivy.uix.gridlayout import GridLayout
- from kivy.uix.popup import Popup
- class BoundedLabel(Label):
- pass
- class Transpose(App):
- def exit(instance):
- sys.exit()
- def build(self):
- def LoadLabels(w):
- if w == 0:
- tex0 = self.text1
- tex1 = self.text2
- else:
- tex0 = self.text3
- tex1 = self.text4
- for i in range(0,22):
- if i <= 12:
- if i < 10:
- t1 = " " + str(i) + "| "
- else:
- t1 = str(i) + "| "
- t = tex1
- else:
- t1 = ''
- t = ''
- l = BoundedLabel(text=t1+t[(i*6):(i*6)+78], size=(780, 35),
- size_hint=(None, None),halign='left',font_name='data/fonts/DroidSansMono.ttf')
- s.add_widget(l)
- def Swap(instance):
- if self.whichway == 0:
- self.whichway = 1
- btnWhich.text = "Guitar --> Piano"
- btn1.text = " " + self.text3
- s.clear_widgets()
- LoadLabels(1)
- else:
- self.whichway = 0
- btnWhich.text = "Piano --> Guitar"
- btn1.text = " " + self.text1
- s.clear_widgets()
- LoadLabels(0)
- def ShowAbout(instance):
- print "About to Popup"
- popup.open()
- self.whichway=0
- self.text1 = " C | B |A#/Bb| A |G#/Ab| G |F#/Gb| F | E |D#/Eb| D |C#/Db| C |"
- self.text2 = " C | B |A#/Bb| A |G#/Ab| G |F#/Gb| F | E |D#/Eb| D |C#/Db| C | B |A#/Bb| A |G#/Ab| G |F#/Gb| F | E |D#/Ab| D |C#/Db| C |"
- self.text3 = " C |C#/Db| D |D#/Eb| E | F |F#/Gb| G |G#/Ab| A |A#/Bb| B | C |"
- self.text4 = " C |C#/Db| D |D#/Eb| E | F |F#/Gb| G |G#/Ab| A |A#/Bb| B | C |C#/Db| D |D#/Eb| E | F |F#/Gb| G |G#/Ab| A |A#/Bb| B | C |C#/Db|"
- root = GridLayout(orientation='vertical', spacing=6, cols=1,rows=4,row_default_height=40)
- lbl = Label(text='Transposer Ver 0.8.0',font_size=20,size_hint=(None,None),size=(480,20),padding=(10,10))
- btn1 = Button(text = " " + self.text1,size=(780,20),
- size_hint=(None, None),
- halign='left',
- font_name='data/fonts/DroidSansMono.ttf',
- padding=(20,2),
- background_color=[0.39,0.07,.92,1])
- al0 = AnchorLayout()
- al1 = AnchorLayout()
- al2 = AnchorLayout()
- popup = Popup(title='About Transposer',
- content=Label(text='Written by G.D. Walters'),
- size_hint=(None,None),size=(400,400))
- btnWhich = Button(text = "Piano --> Guitar",size=(180,40),size_hint=(None,None))
- btnWhich.bind(on_release=Swap)
- btnAbout=Button(text="About",size=(180,40),size_hint=(None,None))
- btnAbout.bind(on_release=ShowAbout)
- btnExit =Button(text="Exit", size=(180,40),size_hint=(None,None))
- btnExit.bind(on_release=exit)
- #--------------------------------------------------------------
- root.add_widget(lbl)
- root.add_widget(btn1)
- #--------------------------------------------------------------
- s = GridLayout(cols=1, spacing = 4, size_hint_y = None)
- s.bind(minimum_height=s.setter('height'))
- LoadLabels(0)
- #--------------------------------------------------------------
- sv = ScrollView(size_hint=(None, None), size=(600,400))
- sv.center = Window.center
- root.add_widget(sv)
- sv.add_widget(s)
- al0.add_widget(btnWhich)
- al1.add_widget(btnExit)
- al2.add_widget(btnAbout)
- bgl = GridLayout(orientation='vertical', spacing=6, cols=3,rows=1,row_default_height=40)
- bgl.add_widget(al0)
- bgl.add_widget(al1)
- bgl.add_widget(al2)
- root.add_widget(bgl)
- return root
- if __name__ in ('__main__','__android__'):
- Transpose().run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement