Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Find notes in scales and chords simply by giving the name of the scale
- import Tkinter
- from Tkinter import LEFT
- import scale_arp_chords_data as data
- import give_scales_chord_names as helper
- import getinim
- class userinterface_tk(Tkinter.Tk):
- def __init__(self,parent):
- Tkinter.Tk.__init__(self,parent)
- self.parent = parent
- self.initialize()
- def initialize(self):
- self.grid()
- self.mode = "Scale Mode"
- ## print the user guide top level
- self.WhichUserGuide = Tkinter.StringVar() # variable text
- self.temp = self.WhichUserGuide
- self.guide_label = Tkinter.Label(self, justify=LEFT, textvar = self.WhichUserGuide, anchor = "w", fg = "black", bg = "lightblue", font = "Calibri 14", border = 20)
- self.guide_label.grid(row = 0, column = 0, columnspan = 4, sticky = 'NW')
- self.WhichUserGuide.set(data.scaleguide)
- ## make toggle button to select scales or chords
- self.ScaleChordVar = Tkinter.StringVar()
- self.Togglebutton = Tkinter.Button(self, textvar = self.ScaleChordVar, height = 1, width = 11, font = "Calibri 12 bold", fg = "blue", bg = "lightgrey", border = 4, command = self.toggle)
- self.Togglebutton.grid(row= 3, sticky = 'W')
- self.ScaleChordVar.set('Scale Mode')
- ## make the user scale/chord request box
- self.entryVariable = Tkinter.StringVar()
- self.entry = Tkinter.Entry(self,textvariable = self.entryVariable, font = "Calibri 12")
- self.entry.grid(column = 0, row = 1, sticky = 'EW')
- self.entry.bind("<Return>", self.OnPressEnter)
- self.entryVariable.set(u"Scale or chord..")
- ## make the answer box which starts with Your answer will be..... but will hold last answer
- self.labelVariable = Tkinter.StringVar()
- label = Tkinter.Label(self,textvariable = self.labelVariable,
- anchor = "w", fg = "white", bg = "blue", font = "Calibri 12")
- label.grid(column = 0, row = 2, columnspan = 2, sticky = 'EW')
- self.labelVariable.set(u"Your answer will be displayed here..")
- self.grid_columnconfigure(0,weight = 1)
- self.resizable(False, False)
- self.update()
- self.geometry(self.geometry())
- self.entry.focus_set()
- self.entry.selection_range(0, Tkinter.END)
- def toggle(self):
- if self.ScaleChordVar .get().title() == ("Scale Mode"):
- self.mode = "Chord Mode"
- self.WhichUserGuide.set(data.chordguide)
- else:
- self.mode = "Scale Mode"
- self.WhichUserGuide.set(data.scaleguide)
- self.ScaleChordVar.set(self.mode)
- def OnPressEnter(self,event):
- scale_or_chord = self.entryVariable.get()
- mode = self.mode
- ## if Quit or q or Q then exit program.
- if scale_or_chord in ["quit", "q", "Q", "end", "End", "END", "exit", "Exit", "EXIT"]:
- self.quit()
- ## if NOT Quit then call the main Python routine and get scale or chord notes
- totalanswer = helper.main(scale_or_chord, mode) # returns a string
- self.labelVariable.set(totalanswer)
- self.entry.focus_set()
- self.entry.selection_range(0, Tkinter.END)
- if __name__ == "__main__":
- app = userinterface_tk(None)
- app.title('Scale or Chord Notes ( design, concept and coding by Diliup Gabadamudalige 2015. diliupg@gmail.com )')
- app.iconbitmap(default = getinim.main("dg.ico"))
- app.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement