Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Making buttons with no borders or spaces between them
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


Report this thread to moderator Post Follow-up to this message
Old Post
Langdon Algar
01-13-05 08:57 AM


Re: Making buttons with no borders or spaces between them
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.

Report this thread to moderator Post Follow-up to this message
Old Post
Marc Dashevsky
01-13-05 08:57 AM


Re: Making buttons with no borders or spaces between them
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


Report this thread to moderator Post Follow-up to this message
Old Post
Langdon Algar
01-16-05 01:56 PM


Re: Making buttons with no borders or spaces between them
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

Report this thread to moderator Post Follow-up to this message
Old Post
zentara
01-16-05 08:57 PM


Re: Making buttons with no borders or spaces between them
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.

Report this thread to moderator Post Follow-up to this message
Old Post
Marc Dashevsky
01-16-05 08:57 PM


Re: Making buttons with no borders or spaces between them
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
>



Report this thread to moderator Post Follow-up to this message
Old Post
Chris Whiting
01-21-05 09:00 AM


Re: Making buttons with no borders or spaces between them
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

Report this thread to moderator Post Follow-up to this message
Old Post
Rob Seegel
01-21-05 09:00 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PerlTk archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 01:14 PM.

 

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.