[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Tk scrolled canvas

R. Mark Volkmann

12/5/2004 3:17:00 AM

I can create a canvas like this.

root = TkRoot.new {title 'Diagram'}
canvas = TkCanvas.new(root)

I think I should be able to create a scrolled canvas like this, but it
doesn't work.

scrolled = TkScrolledcanvas.new(root)

I've search the mailing list for the answer and can't find it.
What's the correct syntax?




4 Answers

Hidetoshi NAGAI

12/5/2004 8:09:00 AM

0

R. Mark Volkmann

12/5/2004 3:45:00 PM

0

----- Original Message -----
From: "Hidetoshi NAGAI" <nagai@ai.kyutech.ac.jp>
To: "ruby-talk ML" <ruby-talk@ruby-lang.org>
Sent: Sunday, December 05, 2004 2:09 AM
Subject: Re: Tk scrolled canvas


> Hi,
>
> From: "R. Mark Volkmann" <mark@ociweb.com>
> Subject: Tk scrolled canvas
> Date: Sun, 5 Dec 2004 12:17:01 +0900
> Message-ID: <05b101c4da78$e39092d0$0200a8c0@MarkDesktop>
>> I think I should be able to create a scrolled canvas like this, but it
>> doesn't work.
>
> Please define the widget class which you want. ;-)

I don't understand why I have to write my own TkScrolledCanvas class.
Why doesn't a scrolled canvas already exist?
It is discussed in the book "Learning Perl/Tk" on the first page of chapter
9.
The author says you can either create a plain "Canvas" or a "Scrolled" which
is a scrollable Canvas.

> See sample scripts at ext/tk/samples directory of Ruby source archive.
>
> If refer to ext/tk/samples/tktextframe.rb,
> TkScrolledCanvas can be defined as such as the following.
> ---------------------------------------------------------------------
> #!/usr/bin/env ruby
> require 'tk'
>
> class TkScrolledCanvas < TkCanvas
> include TkComposite
>
> def initialize_composite(keys={})
> @h_scr = TkScrollbar.new(@frame)
> @v_scr = TkScrollbar.new(@frame)
>
> @canvas = TkCanvas.new(@frame)
> @path = @canvas.path
>
> @canvas.xscrollbar(@h_scr)
> @canvas.yscrollbar(@v_scr)
>
> TkGrid.rowconfigure(@frame, 0, :weight=>1, :minsize=>0)
> TkGrid.columnconfigure(@frame, 0, :weight=>1, :minsize=>0)
>
> @canvas.grid(:row=>0, :column=>0, :sticky=>'news')
> @h_scr.grid(:row=>1, :column=>0, :sticky=>'ew')
> @v_scr.grid(:row=>0, :column=>1, :sticky=>'ns')
>
> delegate('DEFAULT', @canvas)
> delegate('background', @text, @h_scr, @v_scr)
> delegate('activeforeground', @h_scr, @v_scr)
> delegate('troughcolor', @h_scr, @v_scr)
> delegate('repeatdelay', @h_scr, @v_scr)
> delegate('repeatinterval', @h_scr, @v_scr)
> delegate('borderwidth', @frame)
> delegate('relief', @frame)
>
> delegate_alias('canvasborderwidth', 'borderwidth', @canvas)
> delegate_alias('canvasrelief', 'relief', @canvas)
>
> delegate_alias('scrollbarborderwidth', 'borderwidth', @h_scr, @v_scr)
> delegate_alias('scrollbarrelief', 'relief', @h_scr, @v_scr)
>
> configure(keys) unless keys.empty?
> end
> end
>
> c = TkScrolledCanvas.new(:scrollregion=>[0,0,500,400]).pack
> TkcRectangle.new(c, [100,100], [300, 200])
>
> Tk.mainloop
> ---------------------------------------------------------------------
> --
> Hidetoshi NAGAI (nagai@ai.kyutech.ac.jp)
>
>




Hidetoshi NAGAI

12/6/2004 2:08:00 AM

0

Tim Bruening

10/1/2008 10:28:00 AM

0



nemo wrote:

> "Tim Bruening" <tsbrueni@pop.dcn.davis.ca.us> wrote in message
> news:433E18DA.4F26670E@pop.dcn.davis.ca.us...
> >
> > Advent: We need more ventilation.
> >
> > Advent: Insert angry rant.
> >
> > Adverse: Singing commercial.
> >
> > Attract Anorak: What an Alpine train runs on, in my a pinion!
> >
> > Aversion: One description of events.
> >
> > Convent: Against angry rants.
> >
> > Convent: A ranting criminal.
> >
> > Converse: Against singing.
> >
> > Contract: Against railroads.
> >
> > Enginuity: A locomotive driver's pension.
>
> Mine!
>
> Hard a-port . . . !
>
> BANG!!!! Glug - glug - glug . . . . .
>
> Too late!
>
> Locomotion: St. Vitas' Dance!

Why don't you ever go "hard a-starboard"?