For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > January 2005 > Making buttons with no borders or spaces between them









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Making buttons with no borders or spaces between them
Langdon Algar

2005-01-13, 3:57 am

Hello All,

Hi there, is it possible to create buttons that contain images
(using Tk::JPEG), that will appear to be flush against each other
with no borders in between? I basically have a large image that
is divided into 5 smaller images, each of these images is on its
own button, and I cannot seem to be able to make them appear
seamless. I would like the finished 5 images to appear to be one
large image.

I have tried setting "borderwidth" to 0 on the buttons, I have
set the "relief" to 'flat' and still I have lines in between the
buttons. Is there any way to do this?

Thanks,
Langdon Algar

Marc Dashevsky

2005-01-13, 3:57 am

In article <1105584608.677661.133310@c13g2000cwb.googlegroups.com>,
evilcommandcenter@yahoo.com says...
> Hi there, is it possible to create buttons that contain images
> (using Tk::JPEG), that will appear to be flush against each other
> with no borders in between? I basically have a large image that
> is divided into 5 smaller images, each of these images is on its
> own button, and I cannot seem to be able to make them appear
> seamless. I would like the finished 5 images to appear to be one
> large image.
>
> I have tried setting "borderwidth" to 0 on the buttons, I have
> set the "relief" to 'flat' and still I have lines in between the
> buttons. Is there any way to do this?


-highlightthickness => 0

use strict;
use Tk;

my $mw = tkinit;
my %image;
map {$image{$_} = $mw->Photo(-file => "Z:/img-$_.bmp")} qw/nw ne sw se/;
my %options = (-bd => 0, -highlightthickness => 0);
$mw->Button(-image => $image{nw}, %options)->grid(-row => 0, -column => 0);
$mw->Button(-image => $image{ne}, %options)->grid(-row => 0, -column => 1);
$mw->Button(-image => $image{sw}, %options)->grid(-row => 1, -column => 0);
$mw->Button(-image => $image{se}, %options)->grid(-row => 1, -column => 1);
MainLoop;

--
Go to http://MarcDashevsky.com to send me e-mail.
Langdon Algar

2005-01-16, 8:56 am

Marc,

Thanks for your help, unfortunately this doesn't seem to be
working on my system.Setting the highlight thickness to zero did
make the button borders thinner, but there was still a visible
line between the buttons. I thought the problem might have been
with the fact that the buttons were using jpeg images, or that
they were different sizes, so I tried running your exact code
using the same square .bmp for each button and using "grid"
instead of "pack"... but there are still visible borders. Not
sure what the problem could be.
-Langdon

zentara

2005-01-16, 3:57 pm

On 15 Jan 2005 23:43:22 -0800, "Langdon Algar"
<evilcommandcenter@yahoo.com> wrote:

>Marc,
>
>Thanks for your help, unfortunately this doesn't seem to be
>working on my system.Setting the highlight thickness to zero did
>make the button borders thinner, but there was still a visible
>line between the buttons. I thought the problem might have been
>with the fact that the buttons were using jpeg images, or that
>they were different sizes, so I tried running your exact code
>using the same square .bmp for each button and using "grid"
>instead of "pack"... but there are still visible borders. Not
>sure what the problem could be.
>-Langdon


Yeah, I have found the same thing. I tried the -padx and -ipadx settings
to no avail.

I have found 2 "workarounds.

1. Specify a black background and black activebackground in the buttons,
which make it appear seamless.

2. Put your photo's on a canvas in rectangles, and set the rectangle
width to 0. That will make them seamless. (But you lose the button
action unless you make it yourself manually.)



--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Marc Dashevsky

2005-01-16, 3:57 pm

In article <1105861402.119226.214030@f14g2000cwb.googlegroups.com>,
evilcommandcenter@yahoo.com says...
> Marc,
>
> Thanks for your help, unfortunately this doesn't seem to be
> working on my system.Setting the highlight thickness to zero did
> make the button borders thinner, but there was still a visible
> line between the buttons. I thought the problem might have been
> with the fact that the buttons were using jpeg images, or that
> they were different sizes, so I tried running your exact code
> using the same square .bmp for each button and using "grid"
> instead of "pack"... but there are still visible borders. Not
> sure what the problem could be.


Isn't that odd. I'm running Windows on a 1600x1200 display
and the images are seamless.

--
Go to http://MarcDashevsky.com to send me e-mail.
Chris Whiting

2005-01-21, 4:00 am

won't
-relief => 'flat'
do what you are looking for?

"Langdon Algar" <evilcommandcenter@yahoo.com> wrote in message
news:1105861402.119226.214030@f14g2000cwb.googlegroups.com...
> Marc,
>
> Thanks for your help, unfortunately this doesn't seem to be
> working on my system.Setting the highlight thickness to zero did
> make the button borders thinner, but there was still a visible
> line between the buttons. I thought the problem might have been
> with the fact that the buttons were using jpeg images, or that
> they were different sizes, so I tried running your exact code
> using the same square .bmp for each button and using "grid"
> instead of "pack"... but there are still visible borders. Not
> sure what the problem could be.
> -Langdon
>



Rob Seegel

2005-01-21, 4:00 am

Langdon Algar wrote:
> Hello All,
>
> Hi there, is it possible to create buttons that contain images
> (using Tk::JPEG), that will appear to be flush against each other
> with no borders in between? I basically have a large image that
> is divided into 5 smaller images, each of these images is on its
> own button, and I cannot seem to be able to make them appear
> seamless. I would like the finished 5 images to appear to be one
> large image.
>


Do you see the same behavior when using the Label widget? I've seen this
in the past on Windows, and in a few occasions opted for my own
"Button" using Label and a few judicious bindings. It allowed me to
achieve a bit more consistency between platforms.

Rob
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com