Button problems 
Author Message
 Button problems

Two questions:

1. How to reduce the standard height of a button widget containing text?
Its default size is too big for my needs.

   $b = $MW->Button(-text => "Files")->pack();
   $b->GeometryRequest(100, 20);

does only approximately what I want (the text is not centered on the
button, and when the mouse is moved onto the button, it jumps back to
the standard size).

2. How to underline the letter corresponding to a keyboard shortcut? The
often used prefixes "&" or "~" don't work.

Thanks for any ideas!

Martin



Sat, 28 Jun 2003 19:07:59 GMT  
 Button problems

Quote:
> 2. How to underline the letter corresponding to a keyboard shortcut? The
> often used prefixes "&" or "~" don't work.

I found the solution for no. 2:

  $b = $MW->Button(-text => "Files", -underline => 0)->pack();
  $MW->bind('<Alt-f>',[$b,'invoke']);

Martin



Sat, 28 Jun 2003 19:45:13 GMT  
 Button problems

Quote:
>   $b = $MW->Button(-text => "Files")->pack();
>   $b->GeometryRequest(100, 20);

a few random ideas:

-  Reduce the -padx and -pady
   values. I think they are default
   to two

- Use a smaller font size

- make your own button widget
  using a frame. A bit more work
  but then you will have more
  precise control over the size
  using pixels units.

Quote:
>2. How to underline the letter corresponding to a keyboard shortcut?

use the -underline option and specify
the index of the letter you wish to
underline. To underline the first letter,
include the option: -underline => 0

Rob



Sat, 28 Jun 2003 19:51:24 GMT  
 Button problems

Quote:
> Two questions:

> 1. How to reduce the standard height of a button widget containing text?
> Its default size is too big for my needs.

Back in September, I answered a similar question as follows:

| Use bitmaps rather than text.  While this is probably impractical
| for you, the two buttons in the program below display the same
| bits (on my system, at least) on buttons of vastly different size.
|
| use Tk;
| my $Top = tkinit;
| my $a = "#define a_width 9
|       #define a_height 10
|       static char a_bits[] = {
|               0x10, 0x00, 0x10, 0x00, 0x28, 0x00, 0x28, 0x00, 0x44, 0x00,
|               0x44, 0x00, 0xfe, 0x00, 0x82, 0x00, 0x01, 0x01, 0x01, 0x01,
|       };";
| $Top->Button(-image => $Top->Bitmap(-data => $a))->pack;
| $Top->Button(-text  => 'A')->pack;
| MainLoop

--
Marc Dashevsky  (remove "_" from address to reply by e-mail)



Sat, 28 Jun 2003 20:57:57 GMT  
 Button problems
Marc Dashevsky schrieb:

Quote:
> | Use bitmaps rather than text.  While this is probably impractical
> | for you, the two buttons in the program below display the same
> | bits (on my system, at least) on buttons of vastly different size.

Thank you! I had already thought about a similar procedure ...
Sorry, I realize now I could have found your first answer on deja.com!
Another thing I found there was Slaven Rezic's hint to Tk::Compound.

Regards,
Martin



Sat, 28 Jun 2003 21:37:08 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Form button problems.

2. Button problem with NT 4 sp3, ActivePerl APi506e , Tk800.011

3. simulating button press and button release in menu

4. binding right mouse button click to all buttons

5. Radio button panel with CGI.pm problem

6. CGI.pm Button and Input text problems

7. Problem accessing array values with button after loop has concluded

8. The problem of two Submit buttons

9. CGI.pm Button and Input text problems

10. (fwd) Problem with configure and inherited Button

11. Problem with configure and inherited Button

12. Another ActiveState Perl/Tk Button/Entry Problem....

 

 
Powered by phpBB® Forum Software