librelist archives

« back to archive

Guest Post

Guest Post

From:
Steve Klabnik
Date:
2010-12-19 @ 02:00
Hey guys. Another list glitch is happening... this was supposed to be
posted, but never made it:

I've CC-d the author, so reply-all should work.


=========

Hey guys,

I hope all is well...

I am trying to get a clear understanding as to why my application is placing
my output on top of my UI.  Everything I have tried has not gotten it so
that my output is displayed at the bottom of my UI and it has to be that I
am clearly not understanding something about slots (stacks, flows)

In this message I have included my code and a screenshot of what happens
when I click submit to get an output.

Shoes.app :title => "Which App" do
# => Build the GUI
stack :width => "%100", :margin => 10 do
 para "Version #{version}"
 para "Enter server or application name:"
 name = edit_line
 flow :width => "100%" do
   name =~ /opnet.com/ ? server = name : application = name
   button "Submit" do
     if submission_prompt
       if server
         display_applications(server.text)
       elsif application
         display_servers(application.text)
       else
         alert("#{name} is an Invalid Submission!!")
       end # => name if name check
     end # => End if prompt
   end # => End submit button

   button "exit" do
     if exit_prompt
       exit
     end # => end if button
   end # => end exit button
 end # => end flow
end # => end stack

# => Systems Messages
def name_prompt
 "Please, enter the server or appliation name:"
end

def exit_prompt
 confirm("Are You Sure?!?!")
end

def submission_prompt
 confirm("Are you sure you want to submit?!?!")
end

def display_applications(server)
 para "display server text"
end

def display_servers(application)
 para "display application text"
end

Class Blah
 ...
end
end

Re: [shoes] Guest Post

From:
Jay Gabin
Date:
2010-12-19 @ 04:21
Is "%100" allowed? Should that be "100%"? (The stack width.)

In this: "name =~ /opnet.com/ ?" should that be name.text instead of just name?

 Jay Gabin
cs9000@yahoo.com




________________________________
From: Steve Klabnik <steve@steveklabnik.com>
To: shoes@librelist.com
Sent: Sat, December 18, 2010 9:00:45 PM
Subject: [shoes] Guest Post

Hey guys. Another list glitch is happening... this was supposed to be posted, 
but never made it:

I've CC-d the author, so reply-all should work.


=========
Hey guys,

I hope all is well...

I am trying to get a clear understanding as to why my application is placing my 
output on top of my UI.  Everything I have tried has not gotten it so that my 
output is displayed at the bottom of my UI and it has to be that I am clearly 
not understanding something about slots (stacks, flows)

In this message I have included my code and a screenshot of what happens when I 
click submit to get an output.

Shoes.app :title => "Which App" do
# => Build the GUI
stack :width => "%100", :margin => 10 do
 para "Version #{version}"
 para "Enter server or application name:"
 name = edit_line
 flow :width => "100%" do
   name =~ /opnet.com/ ? server = name : application = name
   button "Submit" do
     if submission_prompt
       if server
         display_applications(server.text)
       elsif application
         display_servers(application.text)
       else
         alert("#{name} is an Invalid Submission!!")
       end # => name if name check
     end # => End if prompt
   end # => End submit button

   button "exit" do
     if exit_prompt
       exit
     end # => end if button
   end # => end exit button
 end # => end flow
end # => end stack

# => Systems Messages
def name_prompt
 "Please, enter the server or appliation name:"
end

def exit_prompt
 confirm("Are You Sure?!?!")
end

def submission_prompt
 confirm("Are you sure you want to submit?!?!")
end

def display_applications(server)
 para "display server text"
end

def display_servers(application)
 para "display application text"
end

Class Blah
 ...
end
end 

Re: [shoes] Guest Post

From:
ashbb
Date:
2010-12-19 @ 04:30
Hi Jay,

You are right. I just posted the same comment. ;-)

ashbb

Re: [shoes] Guest Post

From:
Jay Gabin
Date:
2010-12-19 @ 19:51
Thanks! 

I'm new to Shoes. I've enjoyed the tutorials you have on the web - very helpful. 
I've written a few little things and I'm glad to see it has an active community.

Jay


 Jay Gabin
cs9000@yahoo.com




________________________________
From: ashbb <ashbbb@gmail.com>
To: shoes@librelist.com
Sent: Sat, December 18, 2010 11:30:42 PM
Subject: Re: [shoes] Guest Post

Hi Jay,

You are right. I just posted the same comment. ;-)

ashbb

Re: [shoes] Guest Post

From:
Cecil Coupe
Date:
2010-12-19 @ 04:55
I decided to rewrite his script my way, for educational purposes, of
course. Tested. It also includes an example of how/why to use @var in
user methods.

> Shoes.app :title => "Which App" do
>   stack  :margin => 10 do
>     para "Enter server or application name:"
>     @name = edit_line
>     flow :width => "100%" do
>       button "Submit" do
>         srv = @name.text =~ /opnet.com/ 
>         if srv
>           display_servers(@name.text)
>         else 
>           txt = display_applications(@name.text)
>           @result.append do
>             para txt
>           end
>         end # => End if prompt
>       end # => End submit button
> 
>       button "exit" do
>         if confirm("Are You Sure?!?!") 
>           exit
>         end # => end if button
>       end # => end exit button
>     end # => end flow
> 
>     @result = stack do 
>       para "Entries Made"
>     end
>   end # stack
> 
>   def display_applications(parm)
>     return "Application: #{parm}"
>   end
> 
>   def display_servers(parm)
>     @result.append do
>       para "Server #{parm}"
>     end
>   end
>   
> end # Shoes.app

On Sat, 2010-12-18 at 20:21 -0800, Jay Gabin wrote:
> 
> Is "%100" allowed? Should that be "100%"? (The stack width.)
> 
> In this: "name =~ /opnet.com/ ?" should that be name.text instead of
> just name?
>  
> Jay Gabin
> cs9000@yahoo.com
> 
> 
> 
> 
> ______________________________________________________________________



Re: [shoes] Guest Post

From:
Steve Klabnik
Date:
2010-12-19 @ 05:09
Thanks guys! I've forwarded this stuff, since ash said it got lost.

Re: [shoes] Guest Post

From:
Devyn Cairns
Date:
2010-12-19 @ 20:00
On Sat, Dec 18, 2010 at 8:55 PM, Cecil Coupe <ccoupe@cableone.net> wrote:

> I decided to rewrite his script my way, for educational purposes, of
> course. Tested. It also includes an example of how/why to use @var in
> user methods.
>
> > Shoes.app :title => "Which App" do
> >   stack  :margin => 10 do
> >     para "Enter server or application name:"
> >     @name = edit_line
> >     flow :width => "100%" do
> >       button "Submit" do
> >         srv = @name.text =~ /opnet.com/
> >         if srv
> >           display_servers(@name.text)
> >         else
> >           txt = display_applications(@name.text)
> >           @result.append do
> >             para txt
> >           end
> >         end # => End if prompt
> >       end # => End submit button
> >
> >       button "exit" do
> >         if confirm("Are You Sure?!?!")
> >           exit
> >         end # => end if button
> >       end # => end exit button
> >     end # => end flow
> >
> >     @result = stack do
> >       para "Entries Made"
> >     end
> >   end # stack
> >
> >   def display_applications(parm)
> >     return "Application: #{parm}"
> >   end
> >
> >   def display_servers(parm)
> >     @result.append do
> >       para "Server #{parm}"
> >     end
> >   end
> >
> > end # Shoes.app
>

That regexp should be /opnet\.com/, shouldn't it? Otherwise it'd match
something like "opnetxcom" or whatever.



-- 
    ~devyn

Re: [shoes] Guest Post

From:
ashbb
Date:
2010-12-19 @ 05:13
Hi Cecil,

Nice!

Green Shoes doesn't support append method so far.
But it's useful! I need to consider.. :)

ashbb

Re: [shoes] Guest Post

From:
Cecil Coupe
Date:
2010-12-19 @ 05:50
Truth be told, I didn't remember slot.append until I looked in the
manual. I think it might be a Policeman addition and it is seriously
useful to some people,

On Sun, 2010-12-19 at 14:13 +0900, ashbb wrote:
> Hi Cecil,
> 
> Nice!
> 
> Green Shoes doesn't support append method so far.
> But it's useful! I need to consider.. :)
> 
> ashbb

Re: [shoes] Guest Post

From:
ashbb
Date:
2010-12-19 @ 04:27
Hi Steve et al,

Have to revise a little. Confirm the following code with your Shoes. ;-)

I edited just 3 points:
- replace "%100" to "100%" in line 3
- add line 4: "version = 1.0"
- move line 9 into the block of button and replace from 'name' to
'name.text'
  (add line 11)

Cheers,
ashbb

ps.

> I've CC-d the author, so reply-all should work.
Umm,... ML mail server removed?
I didn't get author's address.


---------------------------------------------------------------------------
Shoes.app :title => "Which App" do
# => Build the GUI
  stack :width => "100%", :margin => 10 do
    version = 1.0
    para "Version #{version}"
    para "Enter server or application name:"
    name = edit_line
    flow :width => "100%" do
      #name =~ /opnet.com/ ? server = name : application = name
      button "Submit" do
        name.text =~ /opnet.com/ ? server = name : application = name
        if submission_prompt
          if server
            display_applications(server.text)
          elsif application
            display_servers(application.text)
          else
            alert("#{name} is an Invalid Submission!!")
          end # => name if name check
    end # => End if prompt
      end # => End submit button

      button "exit" do
        if exit_prompt
          exit
        end # => end if button
      end # => end exit button
    end # => end flow
  end # => end stack

  # => Systems Messages
  def name_prompt
    "Please, enter the server or appliation name:"
  end

  def exit_prompt
    confirm("Are You Sure?!?!")
  end

  def submission_prompt
    confirm("Are you sure you want to submit?!?!")
  end

  def display_applications(server)
    para "display server text"
  end

  def display_servers(application)
    para "display application text"
  end

  #Class Blah
  #...
  #end
end

Re: [shoes] Guest Post

From:
Devyn Cairns
Date:
2010-12-19 @ 04:35
Is "100%" even allowed? I've always used floats, that is, 1.0 = 100%

On Sat, Dec 18, 2010 at 8:27 PM, ashbb <ashbbb@gmail.com> wrote:

> Hi Steve et al,
>
> Have to revise a little. Confirm the following code with your Shoes. ;-)
>
> I edited just 3 points:
> - replace "%100" to "100%" in line 3
> - add line 4: "version = 1.0"
> - move line 9 into the block of button and replace from 'name' to
> 'name.text'
>   (add line 11)
>
> Cheers,
> ashbb
>
> ps.
>
> > I've CC-d the author, so reply-all should work.
> Umm,... ML mail server removed?
> I didn't get author's address.
>
>
> ---------------------------------------------------------------------------
>
> Shoes.app :title => "Which App" do
> # => Build the GUI
>   stack :width => "100%", :margin => 10 do
>     version = 1.0
>
>     para "Version #{version}"
>     para "Enter server or application name:"
>     name = edit_line
>     flow :width => "100%" do
>       #name =~ /opnet.com/ ? server = name : application = name
>       button "Submit" do
>         name.text =~ /opnet.com/ ? server = name : application = name
>
>         if submission_prompt
>           if server
>             display_applications(server.text)
>           elsif application
>             display_servers(application.text)
>           else
>             alert("#{name} is an Invalid Submission!!")
>           end # => name if name check
>     end # => End if prompt
>       end # => End submit button
>
>       button "exit" do
>         if exit_prompt
>           exit
>         end # => end if button
>       end # => end exit button
>     end # => end flow
>   end # => end stack
>
>   # => Systems Messages
>   def name_prompt
>     "Please, enter the server or appliation name:"
>   end
>
>   def exit_prompt
>     confirm("Are You Sure?!?!")
>   end
>
>   def submission_prompt
>     confirm("Are you sure you want to submit?!?!")
>   end
>
>   def display_applications(server)
>     para "display server text"
>   end
>
>   def display_servers(application)
>     para "display application text"
>   end
>
>   #Class Blah
>   #...
>   #end
> end
>
>


-- 
    ~devyn

Re: [shoes] Guest Post

From:
ashbb
Date:
2010-12-19 @ 05:03
Hi Devyn,

Yes, "100%" works in Red Shoes.
Although it doesn't work in Green Shoes so far. :-P

ashbb

Re: [shoes] Guest Post

From:
Cecil Coupe
Date:
2010-12-19 @ 03:22
The rule of thumb is to use @instance_var_name to hold the GUI objects
that you need to refer to. It's just life with Shoes. If you look in the
examples all the good scripts do it, for a good reason.

  @name = edit_line

There are other errors(?) in the code snippet. The name =~ line should
be in the button block not ahead of it since the edit_line at that point
has nothing in it since the GUI isn't up on the screen at this point.
Rather than choosing between creating references to the name (or @name)
edit_line, just set a boolean var and use that for the if test. 

Generally speaking, you do not want to create new paras in another
methods like you have in display_applications(server). It confused me,
and it could easily confuse Shoes.

 

> I am trying to get a clear understanding as to why my application is
> placing my output on top of my UI.  Everything I have tried has not
> gotten it so that my output is displayed at the bottom of my UI and it
> has to be that I am clearly not understanding something about slots
> (stacks, flows)
> 
> In this message I have included my code and a screenshot of what
> happens when I click submit to get an output.
> 
> Shoes.app :title => "Which App" do
> # => Build the GUI
> stack :width => "%100", :margin => 10 do
>  para "Version #{version}"
>  para "Enter server or application name:"
>  name = edit_line
>  flow :width => "100%" do
>    name =~ /opnet.com/ ? server = name : application = name
>    button "Submit" do
>      if submission_prompt
>        if server
>          display_applications(server.text)
>        elsif application
>          display_servers(application.text)
>        else
>          alert("#{name} is an Invalid Submission!!")
>        end # => name if name check
>      end # => End if prompt
>    end # => End submit button
> 
>    button "exit" do
>      if exit_prompt
>        exit
>      end # => end if button
>    end # => end exit button
>  end # => end flow
> end # => end stack
> 
> # => Systems Messages
> def name_prompt
>  "Please, enter the server or appliation name:"
> end
> 
> def exit_prompt
>  confirm("Are You Sure?!?!")
> end
> 
> def submission_prompt
>  confirm("Are you sure you want to submit?!?!")
> end
> 
> def display_applications(server)
>  para "display server text"
> end
> 
> def display_servers(application)
>  para "display application text"
> end
> 
> Class Blah
>  ...
> end
> end