Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Make decoration-less windows in TK, and not lose functionality.

by wombat (Curate)
on Aug 24, 2003 at 16:39 UTC ( #286213=sourcecode: print w/replies, xml ) Need Help??
Category: GUI Programming
Author/Contact Info Wombat; the man, the legend, the chosen one.
Description: Some discussion went on recently about how to make decorationless windows in TK. The answer of course is to use the popular $mw->overrideredirect(1); function. However this was determined unsatisfactory because it prevented the window from being moved about the screen.

Well, I solved that.

All it is is that you make a border of widgets around the screen of whatever you want, and use the geometry function on the main window to move it about. Use the pointerxy construct to find out where the cursor is. Have fun!
#!/usr/bin/perl -w
use Tk;
use strict;

my @Custom_Border = ();
my @frames = ();
my ($x, $y) = 0;
my $flag = 0;

my $mw = MainWindow->new(-background=>'#000000',
             -title=>"You Should Never See This.");


$frames[0] = $mw->Frame()->pack(-fill=>'both');
$frames[1] = $mw->Frame()->pack(-fill=>'both');
$frames[2] = $mw->Frame()->pack(-fill=>'both');

$Custom_Border[0] = $frames[0]->Label(-background=>'#FFFFFF',
$Custom_Border[1] = $frames[1]->Label(-background=>'#FFFFFF',

$frames[3] = $frames[1]->Frame()->pack(-side=>'left',-fill=>'both');

$Custom_Border[2] = $frames[1]->Label(-background=>'#FFFFFF',
$Custom_Border[3] = $frames[2]->Label(-background=>'#FFFFFF',
my $Q_Button = $frames[3]->Button(-text=>"Quit",-command=>sub {$mw->de

$Custom_Border[0]->bind('<Button-1>',sub {$flag = 1;});
$Custom_Border[0]->bind('<ButtonRelease-1>',sub {$flag = 0;});

$Custom_Border[0]->bind('<Motion>',sub {
        if ($flag) {
          ($x,$y) = $Custom_Border[0]->pointerxy;
          printf "Moving to %d,%d\n",$Custom_Border[0]->pointerxy;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://286213]
[LanX]: he ... we have a movement here called Anti-Germans based on this
[Corion]: Your Mother: I think that's because (in the west) the Nazi-Germans are recognized as universally evil. Of course, you could do some number games to calculate other measures of evil than "historic losers of second world war" to come up with other evils:)
[Corion]: I've heard "Troll" described as the new Punk, and in a way, it can be as destructive as living the Punk lifestyle, and you don't have to sit out in the cold...
[LanX]: Anti-Germans
[LanX]: Socrates was a Troll
[Your Mother]: It's very, very dangerous... Thinking that a group is intrinsically evil... buries the fact that all humans can be so deep that it starts to become likely they will be.
[Your Mother]: LanX++
[Corion]: (also the "troll for trolls sake" could seen be much like the "punk for punks beer")
[Your Mother]: I'm completely (historically anyway) a troll in real life. It's not fun online, you can't really win. :P
Happy-the-monk orders a Punk IPA.

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (17)
As of 2018-03-19 13:43 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.