librelist archives

« back to archive

Clearing the entire screen

Clearing the entire screen

From:
RoaldD
Date:
2013-07-10 @ 16:13
Hey guys I've been very busy this Summer. Traveled around. Now want to 
get back to Ruby from where I left a month ago.

My background:
I use computers and did coding (python) but it was mostly ugly hacks I 
created for simple tasks like downloading stuff. I was like a JavaScript 
programmer who just copy pastes stuff to make his buttons work. I never 
learned programming properly. I soon grew bored with programming only to 
become interested years later after seeing Shoes was so simple to use. 
 From a non-programmer perspective programming a GUI seems really, 
really cool, (and programming in Ruby seems so simple and intuitive) so 
I was really interested in making GUIs. So, if my questions sound really 
dumb and my code looks like horse-shit please say so.

I'm trying to write a To Do app as recommended by some friends.
I'm now trying to get it to clear everything on screen once I press a 
button. How do I do that? The code so far:

1. Shoes.app do
2.  stack(:margin) => 6 do
3.    @greeting = para "A simple ToDo app for you!"
4.    para "What's your name?"
5.    @name = edit_line
6.    button("OK").click { @greeting.replace "A simple ToDo app for 
#{@name.text.capitalize}!"  }  # I want to change this line
7. end

     # I want to clear the edit_line and the button after the @greeting 
has been updated, what do you suggest?
end

Also, is my code Shoes-like? Can I make it more readable and elegant? 
Are there any stylistic conventions I'm am violating?

Thanks,
Roald!

Re: [shoes] Clearing the entire screen

From:
J. Kaiden
Date:
2013-07-10 @ 16:32
hi Roald,

  i think the #remove method is what you're looking for...  try something
like this:

Shoes.app do
    stack margin: 6 do
       @greeting = para "A simple ToDo app for you!"
       @q = para "What's your name?"
       @name = edit_line
       btn = button("OK").click {
            @greeting.replace "A simple ToDo app for
#{@name.text.capitalize}!"
            @q.remove
            @name.remove
            btn.remove
       }  # I want to change this line
    end
end

   ...as far as readable code goes, i find that consistent indenting goes a
long way to making things clearer...


  Shoes On!

  - j


On Wed, Jul 10, 2013 at 6:13 PM, RoaldD <roalddino@gmail.com> wrote:

> Hey guys I've been very busy this Summer. Traveled around. Now want to
> get back to Ruby from where I left a month ago.
>
> My background:
> I use computers and did coding (python) but it was mostly ugly hacks I
> created for simple tasks like downloading stuff. I was like a JavaScript
> programmer who just copy pastes stuff to make his buttons work. I never
> learned programming properly. I soon grew bored with programming only to
> become interested years later after seeing Shoes was so simple to use.
>  From a non-programmer perspective programming a GUI seems really,
> really cool, (and programming in Ruby seems so simple and intuitive) so
> I was really interested in making GUIs. So, if my questions sound really
> dumb and my code looks like horse-shit please say so.
>
> I'm trying to write a To Do app as recommended by some friends.
> I'm now trying to get it to clear everything on screen once I press a
> button. How do I do that? The code so far:
>
> 1. Shoes.app do
> 2.  stack(:margin) => 6 do
> 3.    @greeting = para "A simple ToDo app for you!"
> 4.    para "What's your name?"
> 5.    @name = edit_line
> 6.    button("OK").click { @greeting.replace "A simple ToDo app for
> #{@name.text.capitalize}!"  }  # I want to change this line
> 7. end
>
>      # I want to clear the edit_line and the button after the @greeting
> has been updated, what do you suggest?
> end
>
> Also, is my code Shoes-like? Can I make it more readable and elegant?
> Are there any stylistic conventions I'm am violating?
>
> Thanks,
> Roald!
>

Re: [shoes] Clearing the entire screen

From:
J. Kaiden
Date:
2013-07-10 @ 16:37
hi again!

  just remembered (i've been away for a bit too!) the #clear method, which
might be a bit easier...  something like this:

Shoes.app do
     @greeting = para "A simple ToDo app for you!"
     @s = stack margin: 5 do
          para "What's your name?"
          @name = edit_line
          btn = button("OK").click {
               @greeting.replace "A simple ToDo app for
#{@name.text.capitalize}!"
               @s.clear
          }  # I want to change this line
     end
end

 - j


On Wed, Jul 10, 2013 at 6:32 PM, J. Kaiden <jakekaiden@gmail.com> wrote:

> hi Roald,
>
>   i think the #remove method is what you're looking for...  try something
> like this:
>
> Shoes.app do
>     stack margin: 6 do
>        @greeting = para "A simple ToDo app for you!"
>        @q = para "What's your name?"
>        @name = edit_line
>        btn = button("OK").click {
>             @greeting.replace "A simple ToDo app for
> #{@name.text.capitalize}!"
>             @q.remove
>             @name.remove
>             btn.remove
>        }  # I want to change this line
>     end
> end
>
>    ...as far as readable code goes, i find that consistent indenting goes
> a long way to making things clearer...
>
>
>   Shoes On!
>
>   - j
>
>
> On Wed, Jul 10, 2013 at 6:13 PM, RoaldD <roalddino@gmail.com> wrote:
>
>> Hey guys I've been very busy this Summer. Traveled around. Now want to
>> get back to Ruby from where I left a month ago.
>>
>> My background:
>> I use computers and did coding (python) but it was mostly ugly hacks I
>> created for simple tasks like downloading stuff. I was like a JavaScript
>> programmer who just copy pastes stuff to make his buttons work. I never
>> learned programming properly. I soon grew bored with programming only to
>> become interested years later after seeing Shoes was so simple to use.
>>  From a non-programmer perspective programming a GUI seems really,
>> really cool, (and programming in Ruby seems so simple and intuitive) so
>> I was really interested in making GUIs. So, if my questions sound really
>> dumb and my code looks like horse-shit please say so.
>>
>> I'm trying to write a To Do app as recommended by some friends.
>> I'm now trying to get it to clear everything on screen once I press a
>> button. How do I do that? The code so far:
>>
>> 1. Shoes.app do
>> 2.  stack(:margin) => 6 do
>> 3.    @greeting = para "A simple ToDo app for you!"
>> 4.    para "What's your name?"
>> 5.    @name = edit_line
>> 6.    button("OK").click { @greeting.replace "A simple ToDo app for
>> #{@name.text.capitalize}!"  }  # I want to change this line
>> 7. end
>>
>>      # I want to clear the edit_line and the button after the @greeting
>> has been updated, what do you suggest?
>> end
>>
>> Also, is my code Shoes-like? Can I make it more readable and elegant?
>> Are there any stylistic conventions I'm am violating?
>>
>> Thanks,
>> Roald!
>>
>
>

Re: [shoes] Clearing the entire screen

From:
RoaldD
Date:
2013-07-10 @ 17:57
Thanks for your super-fast reply!