[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

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

wiz_pendases

12/10/2007 5:50:00 PM

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...
1 Answer

wiz_pendases

12/10/2007 5:53:00 PM

0

On Dec 10, 11:50 am, wiz_penda...@yahoo.com 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>
<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
</code>