# Is there neway i can edit my code...to?

**URL:** <https://www.ruby-forum.com/t/is-there-neway-i-can-edit-my-code-to/122898>\
**Category:** Ruby\
**Created:** [December 12, 2007, 8:15pm UTC](https://www.ruby-forum.com/t/is-there-neway-i-can-edit-my-code-to/122898 "2007-12-12T20:15:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 12, 2007, 8:15pm UTC](https://www.ruby-forum.com/t/is-there-neway-i-can-edit-my-code-to/122898/1 "2007-12-12T20:15:39Z")

</div>

Hallo,

-I want to save tags into an array, then go back and read each  
individual words(loosly typed) typed.  
-Then when the search button is pushed…search over the ablums name  
and the tags that were typed in, then printout(show) the corresponding  
ablum to that search.

Thanks again…

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 12, 2007, 10:10pm UTC](https://www.ruby-forum.com/t/is-there-neway-i-can-edit-my-code-to/122898/2 "2007-12-12T22:10:25Z")

</div>

On Dec 10, 11:50 am, removed\_email\_address@domain.invalid wrote:

> Hallo,
> 
> -I want to save tags into an array, then go back and read each  
> individual words(loosly typed) typed.  
> -Then when the search button is pushed…search over the ablums name  
> and the tags that were typed in, then printout(show) the corresponding  
> ablum to that search.
> 
> Thanks again…

oppps…here is the code…i got so far…

\<code(window.rb)\>  
#Example songs  
songs = [“Purple Haze” ,“Manic Depression” ,“Hey Joe”,“Love or  
Confusion”, “May This Be Love”, “I Don’t Live Today”, “The Wind Cries  
Mary” , “Fire” , “Third Stone From the Sun”, “Foxy Lady”,“Are You  
Experienced?”,“Stone Free” , “51st Anniversary” ,“Highway Chile”, “Can  
You See Me”, “Remember”,“Red House” ]

#ratings for rating list box  
rating = [“1”, “2”, “3”, “4”, “5”,]

#getting tk information  
require ‘tk’  
require ‘index’

#importing image for album picture  
img = TkPhotoImage.new {  
file “test.gif”  
}

#creates the initial tk window and creates a permenant size so  
reasizing is unavailable  
window = TkRoot.new{title “Album Information”}  
window.maxsize(550, 500)  
window.minsize(550, 500)

#creates the Bottom Frame  
bottom\_frame=TkFrame.new(window){  
background “CadetBlue”  
}.pack(“side”=\>“bottom”, ‘expand’=\>true, ‘fill’=\>‘both’,‘anchor’=\>‘w’)

#creates the Bottom Left Frame  
bottom\_left\_frame=TkFrame.new(bottom\_frame){  
background “CadetBlue”  
}.pack(“side”=\>“left”, ‘expand’=\>true, ‘fill’=\>‘both’,‘anchor’=\>‘w’)

#creates the Left Frame  
left\_frame=TkFrame.new(window){  
background “CadetBlue”  
}.pack(“side”=\>“left”, ‘expand’=\>true, ‘fill’=\>‘both’,‘anchor’=\>‘nw’)

#creates the Right Frame  
right\_frame=TkFrame.new (window){  
background “CadetBlue”  
}.pack(“side”=\>“right”, ‘expand’=\>true, ‘fill’=\>‘both’,‘anchor’=\>‘ne’)

#creates a Song List Label  
song\_List\_Label = TkLabel.new(left\_frame) {  
text “Song List”  
background “CadetBlue”  
foreground “lawn green”  
}.pack(‘side’=\>‘top’)

#Creates scroll bar for song list  
song\_bar = TkScrollbar.new(left\_frame){  
background “Deep sky blue”  
troughcolor “lawn green”  
}.pack(‘side’=\>‘right’,  
‘fill’=\>‘y’)

#List box for Albums + Artists  
song\_list = TkListbox.new(left\_frame) {  
insert(“end”, \*songs)  
background “white”  
selectbackground “Deep sky blue”  
}.pack(“side” =\> “left”, “fill” =\> “both”, “expand” =\> true)

#Adds scroll bar to song list  
song\_bar.command{|\*args| song\_list.yview(\*args)}  
song\_list.yscrollcommand{|first , last|  
song\_bar.set(first, last)  
}

#Displays image  
displayed\_Iamge = TkLabel.new(right\_frame) {  
background “CadetBlue”  
image img  
}.pack(“pady”=\>25, “padx”=\>5)

#creates a numbered list box for rating  
rate\_list = TkListbox.new(bottom\_frame){  
height 5  
width 2  
background “white”  
selectbackground “Deep sky blue”  
insert(‘end’, \*rating)  
}.pack(‘side’=\>‘top’)

#creates a Rating Label  
rating\_Label = TkLabel.new(bottom\_frame){  
background “CadetBlue”  
foreground “lawn green”  
text “Rating:”  
}.pack(‘side’=\>‘top’)

#creates a Current Rating indicator  
current\_Rating\_label = TkLabel.new(bottom\_frame){  
background “CadetBlue”  
foreground “lawn green”  
text “0”  
}.pack(‘side’=\>‘top’)

#creates the “RATE IT” button  
rate\_It\_Button = TkButton.new(bottom\_frame){  
background “Deep sky blue”  
command{ }  
text “RATE IT!!!”  
}.pack(“side”=\>“top”, “pady”=\>“5”)

#creates the notes label above text  
notes\_Label = TkLabel.new(bottom\_left\_frame) {  
background “CadetBlue”  
foreground “lawn green”  
text “Notes”  
}.grid(“column”=\>0,“row”=\>0)

#creates a text notes area for user input  
notes = TkText.new(bottom\_left\_frame){  
borderwidth 4  
width 30  
height 15  
background ‘white’  
selectbackground “Deep sky blue”  
selectforeground “black”  
}.grid(“column”=\>0,“row”=\>1)

#creates the Entry Box for tags  
tag\_Entry\_Box = TkEntry.new(bottom\_frame){  
width 30  
background ‘white’  
selectbackground “Deep sky blue”  
selectforeground “black”  
}.pack(“side”=\>“right”)

#creates label “Tag”  
tag\_Label = TkLabel.new(bottom\_frame){  
foreground “lawn green”  
background “CadetBlue”  
text "Tags : "  
}.pack(“side”=\>“right”)

#creates the TAG button  
tag\_Button = TkButton.new(bottom\_frame){  
background “Deep sky blue”  
command{ Array.new(tag\_Entry\_Box) }  
text “Save Tags”  
}.pack(“side”=\>“right”, “pady”=\>“10”, “padx” =\> 3)

Tk.mainloop  
  
\<code(index.rb)\>  
#testing scroll bar  
test = [“Album One”,“testing this”,“testing this”,“testing  
this”,“testing this”,“testing this”,“testing this”,“testing  
this”,“testing this”,“testing this”,“testing this”,“testing  
this”,“testing this”,“testing this”,“testing this”,“testing  
this”,“testing this”,“testing this”]

#inputs the GUI class tk  
require ‘tk’  
require ‘window’

#Class searches for a song or album, using its tags.  
class Search

#initialize

end

#imports an album picture  
img = TkPhotoImage.new {  
file “Experienced.gif”  
}

#create a variable root as the container tree  
#Creates a window with a the title "to be determined  
root = TkRoot.new {title ‘index’}  
root.minsize(620,250)

#Frames {  
#top frame  
top\_frame = TkFrame.new(root){  
background “Cadetblue”  
}.pack(“side” =\> “top”, “fill” =\> “both”)

#middle frame  
middle\_frame = TkFrame.new(root){  
background “Cadetblue”  
}.pack(“side” =\> “top”, “anchor” =\> “w”, “fill” =\> “x”)

#bottom left frame  
bottom\_left\_frame = TkFrame.new(root){  
background “Cadetblue”  
}.pack(“side” =\> “left”, “fill” =\> “both”, “expand” =\> true)

#bottom right frame  
bottom\_right\_frame = TkFrame.new(root){  
background “Cadetblue”  
}.pack(“side” =\> “right”, “fill” =\> “both”, “expand” =\> true)  
#end of frames }

#Search Block {  
#Search by album or artist from input  
search\_input = TkEntry.new(top\_frame) {  
width 50  
selectbackground “Deep sky blue”  
selectforeground “black”  
}.pack(“side” =\> “left”, “fill” =\> “x”, “padx” =\> 5, “pady” =\> 5)

#Search button  
search = TkButton.new(top\_frame) {  
text “Search”  
background “Deep sky blue”  
}.pack(“side” =\> “left”, “padx” =\> 5, “pady” =\> 5)  
#end of search block }

#Album label for list box  
album\_label = TkLabel.new(middle\_frame) {  
text “Album”  
background “Cadetblue”  
foreground “lawn green”  
}.pack(“side” =\> “left”, “padx” =\> 5, “pady” =\> 5)

#Artist label for list box  
artist\_label = TkLabel.new(middle\_frame) {  
text “Artist”  
background “Cadetblue”  
foreground “lawn green”  
}.pack(“side” =\> “left”, “padx” =\> 125, “pady” =\> 5)

#Creates scroll bar for a list  
list\_bar = TkScrollbar.new(bottom\_left\_frame){  
background “Deep sky blue”  
troughcolor “lawn green”  
}.pack(‘side’=\>‘right’,  
‘fill’=\>‘y’)

#List box for Albums + Artists  
album\_artist\_list = TkListbox.new(bottom\_left\_frame) {  
insert(“end”, \*test)  
background “white”  
selectbackground “Deep sky blue”  
}.pack(“side” =\> “bottom”, “fill” =\> “both”, “expand” =\> true)

#Adds scroll bar to list  
list\_bar.command{|\*args| album\_artist\_list.yview(\*args)}  
album\_artist\_list.yscrollcommand{|first , last|  
list\_bar.set(first, last)  
}

#Buttons {  
#Add Album button  
add\_album = TkButton.new(top\_frame) {  
text “Add Album”  
background “Deep sky blue”  
}.pack(“side” =\> “right”, “padx” =\> 50, “pady” =\> 5)

#List view button  
list\_view = TkButton.new(top\_frame) {  
text “List View”  
background “Deep sky blue”  
command { album\_artist\_list.delete(0,“end”) }  
#command { album\_artist\_list.insert(\*test) }  
}.pack(“side” =\> “top”, “padx” =\> 50, “pady” =\> 5)

#Thumbnail view button  
thumb\_view = TkButton.new(top\_frame) {  
text “Thumbnail View”  
background “Deep sky blue”  
command { album\_artist\_list.delete(0,“end”) }  
#command { album\_artist\_list.insert(img) }  
}.pack(“side” =\> “top”, “padx” =\> 50, “pady” =\> 5)  
#end of buttons }

#Example thumbnail  
TkButton.new(bottom\_right\_frame){  
image img  
command {system(“ruby -w window.rb”)}  
background “Cadetblue”  
}.pack

Tk.mainloop
