Bill | 10 Aug 2006 15:26
Picon

Grid question

Hi,

I'm new to Ltk.   I seem to get it to work fine and have seen enough to 
want to really get familiar with it.  However, I have a few questions 
about the layout managers.   Basically, I want to be able to place 
things anywhere on the screen and have them stay relative to one another 
when the screen  is resized.

When creating a grid, who owns it?    If I want a frame to be a grid of 
four by four and to place buttons at 1,0  and 2,3, how is that done?    
It seems that when I try this the first button goes to 0,0 and the 
second button to 1,1.

Also, how do you create an empty frame of a specific size?    Or a nil 
(*tk*) window of a specific size?

And, lastly, are there any more complex examples I can look at?

Thanks,

Bill
Peter Herth | 15 Aug 2006 10:24
Picon
Favicon

Re: Grid question

Hi Bill,

sorry for a late (and a bit short) answer, but your mail caught me
during travel, but I will try what is possible in a short.

> I'm new to Ltk.   I seem to get it to work fine and have seen enough to
> want to really get familiar with it.  However, I have a few questions
> about the layout managers.   Basically, I want to be able to place
> things anywhere on the screen and have them stay relative to one another
> when the screen  is resized.
>
> When creating a grid, who owns it?    If I want a frame to be a grid of
> four by four and to place buttons at 1,0  and 2,3, how is that done?
> It seems that when I try this the first button goes to 0,0 and the
> second button to 1,1.
>
> Also, how do you create an empty frame of a specific size?    Or a nil
> (*tk*) window of a specific size?
>

In general, try to avoid grid rows/columns which are completely empty,
as they get shrunken to zero size. The grid layout is owned by the
container which owns it, that is either the toplevel window or the
frame whichin the grid is. (the master of the widgets you grid). The
sizing of the grid rows/columns is determined by the minimum size of
the widgets contained in the cells and by the weight  of the
row/column. You can adjust the weight by using grid-rowconfigure (or
grid-columnconfigure respectively) with the keyword :weight and a
parameter between 0 and 1, the heigher ones take more space when
resizing than the smaller ones.
(Continue reading)

Bill Ramsay | 15 Aug 2006 15:09
Picon

Re: Grid question

Peter Herth wrote:
> Hi Bill,
>
> sorry for a late (and a bit short) answer, but your mail caught me
> during travel, but I will try what is possible in a short.
>
>> I'm new to Ltk.   I seem to get it to work fine and have seen enough to
>> want to really get familiar with it.  However, I have a few questions
>> about the layout managers.   Basically, I want to be able to place
>> things anywhere on the screen and have them stay relative to one another
>> when the screen  is resized.
>>
>> When creating a grid, who owns it?    If I want a frame to be a grid of
>> four by four and to place buttons at 1,0  and 2,3, how is that done?
>> It seems that when I try this the first button goes to 0,0 and the
>> second button to 1,1.
>>
>> Also, how do you create an empty frame of a specific size?    Or a nil
>> (*tk*) window of a specific size?
>>
>
> In general, try to avoid grid rows/columns which are completely empty,
> as they get shrunken to zero size. The grid layout is owned by the
> container which owns it, that is either the toplevel window or the
> frame whichin the grid is. (the master of the widgets you grid). The
> sizing of the grid rows/columns is determined by the minimum size of
> the widgets contained in the cells and by the weight  of the
> row/column. You can adjust the weight by using grid-rowconfigure (or
> grid-columnconfigure respectively) with the keyword :weight and a
> parameter between 0 and 1, the heigher ones take more space when
(Continue reading)

Bill Ramsay | 16 Aug 2006 16:43
Picon

Icons

I'm trying to add an image or icon to a menubutton (or regular button) 
and I don't quite get how it works.

What does the first parameter of image-load represent  (i.e. photo as in 
(image-load photo "x.ppm"))?
Should I be working with bitmaps instead of images?
How does the result of the load get assigned to the widget?
And how does the :anchor or :justify get placed on the icon as opposed 
to the button text or the button itself?

Is there an example of this anywhere?

Thanks,

Bill
Bill Ramsay | 17 Aug 2006 16:55
Picon

Apparent Bug

I seem to have found a bug in Ltk.   If you set the genomety of the main 
window to x/y values of 0/0, the menus no longer work correctly.    
Firing the menu command button causes the menu to appear in a flash and 
fire the first menu item.   You do not get to view the menu at all, let 
alone traverse it.    Setting the geometry to 1/1 (or anything else) 
solves the problem.

I seem to have a lot of questions getting started with Ltk.   Sorry, but...

How do you create a modal dialog box?    I can do it by creating a 
toplevel window and positioning it where the dialog should go, but this 
solution is not modal.    Do you have to use tk itself to do this, or is 
there something I'm missing in ltk.lisp.

Thanks,

Bill
Felip Alàez Nadal | 18 Aug 2006 12:16
Picon

Re: Icons

The first paramether is a photo object. You can see an example of how to load an image at the source code for cl-cbr: http://common-lisp.net/project/nixies/download/clcbr_latest.tar.gz
 
But to add an image to a button you only have to pass Its name as a paramether when creating It. If the image isn't in a valid format, Ltk don't loads It. You can use convert, which is part of ImageMagick, to convert images to ppm.

 
2006/8/16, Bill Ramsay <ramsayw1 <at> verizon.net>:
I'm trying to add an image or icon to a menubutton (or regular button)
and I don't quite get how it works.

What does the first parameter of image-load represent  (i.e. photo as in
(image-load photo "x.ppm"))?
Should I be working with bitmaps instead of images?
How does the result of the load get assigned to the widget?
And how does the :anchor or :justify get placed on the icon as opposed
to the button text or the button itself?

Is there an example of this anywhere?

Thanks,

Bill
_______________________________________________
ltk-user site list
ltk-user <at> common-lisp.net
http://common-lisp.net/mailman/listinfo/ltk-user



--
Felip Alàez Nadal
<div>
<div>The first paramether is a photo object. You can see an example of how to load an image at the source code for cl-cbr: <a href="http://common-lisp.net/project/nixies/download/clcbr_latest.tar.gz">http://common-lisp.net/project/nixies/download/clcbr_latest.tar.gz
</a>
</div>
<div>&nbsp;</div>
<div>But to add an image to a button you only have to pass Its name as a paramether when creating It. If the image isn't in a valid format, Ltk don't loads It. You can use convert, which is part of ImageMagick, to convert images to ppm.
<br><br>&nbsp;</div>
<div>
<span class="gmail_quote">2006/8/16, Bill Ramsay &lt;<a href="mailto:ramsayw1 <at> verizon.net">ramsayw1 <at> verizon.net</a>&gt;:</span>
<blockquote class="gmail_quote">I'm trying to add an image or icon to a menubutton (or regular button)<br>and I don't quite get how it works.
<br><br>What does the first parameter of image-load represent&nbsp;&nbsp;(i.e. photo as in<br>(image-load photo "x.ppm"))?<br>Should I be working with bitmaps instead of images?<br>How does the result of the load get assigned to the widget?
<br>And how does the :anchor or :justify get placed on the icon as opposed<br>to the button text or the button itself?<br><br>Is there an example of this anywhere?<br><br>Thanks,<br><br>Bill<br>_______________________________________________
<br>ltk-user site list<br><a href="mailto:ltk-user <at> common-lisp.net">ltk-user <at> common-lisp.net</a><br><a href="http://common-lisp.net/mailman/listinfo/ltk-user">http://common-lisp.net/mailman/listinfo/ltk-user</a><br>
</blockquote>
</div>
<br><br clear="all"><br>-- <br>Felip Al&agrave;ez Nadal 
</div>
Bill Ramsay | 18 Aug 2006 17:17
Picon

Re: Icons

Felip Alàez Nadal wrote:
> The first paramether is a photo object. You can see an example of how 
> to load an image at the source code for cl-cbr: 
> http://common-lisp.net/project/nixies/download/clcbr_latest.tar.gz 
> <http://common-lisp.net/project/nixies/download/clcbr_latest.tar.gz>
>  
> But to add an image to a button you only have to pass Its name as a 
> paramether when creating It. If the image isn't in a valid format, Ltk 
> don't loads It. You can use convert, which is part of ImageMagick, to 
> convert images to ppm.
>
>  
> 2006/8/16, Bill Ramsay <ramsayw1 <at> verizon.net 
> <mailto:ramsayw1 <at> verizon.net>>:
>
>     I'm trying to add an image or icon to a menubutton (or regular button)
>     and I don't quite get how it works.
>
>     What does the first parameter of image-load represent  (i.e. photo
>     as in
>     (image-load photo "x.ppm"))?
>     Should I be working with bitmaps instead of images?
>     How does the result of the load get assigned to the widget?
>     And how does the :anchor or :justify get placed on the icon as opposed
>     to the button text or the button itself?
>
>     Is there an example of this anywhere?
>
>     Thanks,
>
>     Bill
>     _______________________________________________
>     ltk-user site list
>     ltk-user <at> common-lisp.net <mailto:ltk-user <at> common-lisp.net>
>     http://common-lisp.net/mailman/listinfo/ltk-user
>
>
>
>
> -- 
> Felip Alàez Nadal
> ------------------------------------------------------------------------
>
> _______________________________________________
> ltk-user site list
> ltk-user <at> common-lisp.net
> http://common-lisp.net/mailman/listinfo/ltk-user
I'm sorry, but I'm missing something here.....

What I'm trying to do is create a square tool button with a graphic in 
the middle of it.   Nothing special.

I seem to have a number of ways of doing this:

1)   Ideally, I would just add the filepath to the graphic to the :image 
parameter when I create the button (i.e :image (directory "x.ppm")   
This compiles, but gives me a LTK::NAME error when I run it.   

2)  I can try MAKE-IMAGE to create a photo-image and then use IMAGE-LOAD 
(i.e. :image (image-load photo (directory "x.ppm")) this will compile 
but not run.   I get a TWO-WAY-STREAM error for descriptors 7 and 6.

3)  If I do the same as 2, but not use "directory" it compiles and runs, 
but there's no image

4) If I do the same as 2, but use MAKE-INSTANCE to create a photo-image, 
it compiles and runs, but there is no image

I know that in X you have to create a window as the place to draw the 
loading image and then move or copy the image to the place you want to 
put it.    Isn't that what's happening when you MAKE-IMAGE and then use 
IMAGE-LOAD.   (I don't quite see how this affects the :image assignment 
for the button).

I'm sure this is not difficult to do, but everything I try fails.    
What I would like to see is the code for toolbutton with an image in the 
middle that works.     The example you refered me to wasn't quite the 
same thing.

Sorry for the long reply...

Bill
Felip Alàez Nadal | 19 Aug 2006 22:53
Picon

Re: Icons

Hello:
The code I send just creates a button with an image on It. Be sure to run It from within the directory It creates.

--
Felip Alàez Nadal
Attachment (image.tar.gz): application/x-gzip, 2540 bytes
<div>
<div>Hello:</div>
<div>The code I send just creates a button with an image on It. Be sure to run It from within the directory It creates. <br><br>-- <br>Felip Al&agrave;ez Nadal </div>
</div>
Bill Ramsay | 20 Aug 2006 15:34
Picon

Re: Icons

Felip Alàez Nadal wrote:
Hello:
The code I send just creates a button with an image on It. Be sure to run It from within the directory It creates.

--
Felip Alàez Nadal
_______________________________________________ ltk-user site list ltk-user <at> common-lisp.net http://common-lisp.net/mailman/listinfo/ltk-user
When I try to run it I get the following error:

debugger invoked on a SB-INT:STREAM-ENCODING-ERROR:
  encoding error on stream #<SB-SYS:FD-STREAM for "descriptor 6" {9E04D39}>
  (:EXTERNAL-FORMAT :ASCII):
    the character with code 242 cannot be encoded.

However, I pretty much do the same thing you are doing:

     (let*
       ((img
        
         (xbut (make-instance 'button :master nil
                                                        :image (image-load img "x.ppm")))...

In this case I get an error because img is nil.     In your code, you do basically the same thing with the variable imatge.
I have tried making img a photo-image with (img (make-image)), and in that case the error goes away but the button appears with no image in it (and no other errors).   (I've used the ppm image before, so I know it's a good image).

I should note that I'm running this in SBCL on an AMD64 laptop running linux.

I'm sure this works.    I just can't figure out what I'm doing wrong.

Bill
<div>
Felip Al&agrave;ez Nadal wrote:
<blockquote cite="mid212b76500608191353p2cf5a2eake169576172e1a2ae <at> mail.gmail.com" type="cite">
  <div>Hello:</div>
  <div>The code I send just creates a button with an image on It. Be
sure to run It from within the directory It creates. <br><br>
-- <br>
Felip Al&agrave;ez Nadal </div>

_______________________________________________
ltk-user site list
<a class="moz-txt-link-abbreviated" href="mailto:ltk-user <at> common-lisp.net">ltk-user <at> common-lisp.net</a>
<a class="moz-txt-link-freetext" href="http://common-lisp.net/mailman/listinfo/ltk-user">http://common-lisp.net/mailman/listinfo/ltk-user</a>
</blockquote>
When I try to run it I get the following error:<br><br>
debugger invoked on a SB-INT:STREAM-ENCODING-ERROR:<br>
&nbsp; encoding error on stream #&lt;SB-SYS:FD-STREAM for "descriptor 6"
{9E04D39}&gt;<br>
&nbsp; (:EXTERNAL-FORMAT :ASCII):<br>
&nbsp;&nbsp;&nbsp; the character with code 242 cannot be encoded.<br><br>
However, I pretty much do the same thing you are doing:<br><br>
&nbsp;&nbsp;&nbsp;&nbsp; (let*<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ((img<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (xbut (make-instance 'button :master nil<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :image
(image-load img "x.ppm")))...<br><br>
In this case I get an error because img is nil.&nbsp;&nbsp;&nbsp;&nbsp; In your code, you
do basically the same thing with the variable imatge.<br>
I have tried making img a photo-image with (img (make-image)), and in
that case the error goes away but the button appears with no image in
it (and no other errors).&nbsp;&nbsp; (I've used the ppm image before, so I know
it's a good image).<br><br>
I should note that I'm running this in SBCL on an AMD64 laptop running
linux.<br><br>
I'm sure this works.&nbsp;&nbsp;&nbsp; I just can't figure out what I'm doing wrong.<br><br>
Bill<br>
</div>
Peter Herth | 20 Aug 2006 15:11
Picon
Favicon

Re: Icons

On 8/20/06, Bill Ramsay <ramsayw1 <at> verizon.net> wrote:
>
>  Felip Alàez Nadal wrote:
>
> Hello:
> The code I send just creates a button with an image on It. Be sure to run It
> from within the directory It creates.
>
>  --
>  Felip Alàez Nadal
> ________________________________
>
>  _______________________________________________ ltk-user
> site list ltk-user <at> common-lisp.net
> http://common-lisp.net/mailman/listinfo/ltk-user
>  When I try to run it I get the following error:
>
>  debugger invoked on a SB-INT:STREAM-ENCODING-ERROR:
>    encoding error on stream #<SB-SYS:FD-STREAM for "descriptor 6" {9E04D39}>
>    (:EXTERNAL-FORMAT :ASCII):
>      the character with code 242 cannot be encoded.
>
>  However, I pretty much do the same thing you are doing:
>
>       (let*
>         ((img
>
>           (xbut (make-instance 'button :master nil
>
> :image (image-load img "x.ppm")))...
>
image-load returns nil, it is called only for side-effect (will change
it so that it returns the image in the next ltk release)

Peter

Gmane