f



TK extended text widget functions don't seem to work.

TK version 800.025

use Tk::widgets qw(TextEdit);

In my Mastering Perl TK book, there is a short section in the Text widget
chapter about extended methods for use with the mouse.  None seem to work
but they don't error out so TK isn't complaining about invalid commands.
There are no examples.

For instance, in a simple Text widget, I type a few characters and then
highlight some with the mouse then use the command...

$text->deleteSelected;

The cursor moves to the end of the selection but nothing else happens.
The selected characters in question also don't appear in the clipboard.

Same with some of the other simple commands like Insert(string) and
getSelected - no errors, but nothing happens.

The book does say that these are still experimental but I assume that they
should do something.  I am probably missing something but the book only
lists the methods, not talk about them.

Anybody got any info?

Thanks
KRF  

0
krf
8/26/2004 5:38:05 AM
comp.lang.perl.tk 4721 articles. 0 followers. pharrendorf (19) is leader. Post Follow

5 Replies
240 Views

Similar Articles

[PageSpeed] 29

krf <krf@Vega.com> writes:

> TK version 800.025
> 
> use Tk::widgets qw(TextEdit);
> 
> In my Mastering Perl TK book, there is a short section in the Text widget
> chapter about extended methods for use with the mouse.  None seem to work
> but they don't error out so TK isn't complaining about invalid commands.
> There are no examples.
> 
> For instance, in a simple Text widget, I type a few characters and then
> highlight some with the mouse then use the command...
> 
> $text->deleteSelected;
> 
> The cursor moves to the end of the selection but nothing else happens.
> The selected characters in question also don't appear in the clipboard.
> 
> Same with some of the other simple commands like Insert(string) and
> getSelected - no errors, but nothing happens.
> 
> The book does say that these are still experimental but I assume that they
> should do something.  I am probably missing something but the book only
> lists the methods, not talk about them.
> 
> Anybody got any info?
> 

This works with both Tk800.024 and Tk804.027:
use Tk;

$top = new MainWindow;
$txt = $top->Scrolled("Text")->pack;
$top->Button(-text => "del sel",
	     -command => sub {
		 $txt->deleteSelected;
	     })->pack;
MainLoop;

__END__

Regards,
        Slaven

-- 
Slaven Rezic - slaven <at> rezic <dot> de

sf-upload: make batch releases on SourceForge
	http://sf-upload.sf.net
0
Slaven
8/26/2004 7:13:46 AM
> 
> This works with both Tk800.024 and Tk804.027:
> use Tk;
> 
> $top = new MainWindow;
> $txt = $top->Scrolled("Text")->pack;
> $top->Button(-text => "del sel",
> 	     -command => sub {
> 		 $txt->deleteSelected;
> 	     })->pack;
> MainLoop;
> 


Thank you.  That does indeed work.  

This does not.

Mainloop;

sub (somesubroutine){
	$txt->deleteSelected;	
}

I am in learning mode on TK so the problem is not one of holding up
production, but rather me wanting to understand what is going on in a
compiler for which there is not a whole lot of documentation.  

Your routine as a sub hooked to a button widget works, whereas the same
code as a free floating call does not.  Actually, my example deletes all
the text in the selected text widget, despite any highlight selection.

Obviously there is some kind of callback or bind that I don't understand
in this example. But at least you have proved to me that the code works,
even if I don't know how yet.

Thanks again.

KRF   
0
krf
8/26/2004 11:37:33 PM
krf wrote:

>>This works with both Tk800.024 and Tk804.027:
>>use Tk;
>>
>>$top = new MainWindow;
>>$txt = $top->Scrolled("Text")->pack;
>>$top->Button(-text => "del sel",
>>	     -command => sub {
>>		 $txt->deleteSelected;
>>	     })->pack;
>>MainLoop;
>>
> 
> 
> 
> Thank you.  That does indeed work.  
> 
> This does not.
> 
> Mainloop;
> 
> sub (somesubroutine){
> 	$txt->deleteSelected;	
> }

It's really hard to guess what you mean by this. What is your sub name, 
and how are you attaching it to the -command option of your button?

The following works:

   use Tk;

   $top = new MainWindow;
   $txt = $top->Scrolled("Text")->pack;
   $top->Button(-text => "del sel",
	       -command => \&delSel,
	       )->pack;
   MainLoop;

   sub delSel {
       $txt->deleteSelected;
   }


> I am in learning mode on TK so the problem is not one of holding up
> production, but rather me wanting to understand what is going on in a
> compiler for which there is not a whole lot of documentation.  
> 
> Your routine as a sub hooked to a button widget works, whereas the same
> code as a free floating call does not.  Actually, my example deletes all
> the text in the selected text widget, despite any highlight selection.

You never showed us your example, so we can't really say why it's not 
doing what you expect it to. As a rule of thumb, whenever you experience 
something you can't understand, it is best to try and come up with a 
minimal program that exhibits the behaviour and post it. This makes it 
easier for every one.

> Obviously there is some kind of callback or bind that I don't understand
> in this example. But at least you have proved to me that the code works,
> even if I don't know how yet.

A glance at the Tk::callbacks docs will show you every possible form of 
callbacks. Hopefully it will clear up your confusion. If not, then 
you're welcome to post more questions.

--Ala
0
Ala
8/27/2004 12:39:00 AM
> You never showed us your example, so we can't really say why it's not 
> doing what you expect it to. As a rule of thumb, whenever you experience 
> something you can't understand, it is best to try and come up with a 
> minimal program that exhibits the behaviour and post it. This makes it 
> easier for every one.
> 

Ok, good point.  I guess my post WAS along the newbie line of "I have a
problem - whats wrong?  Help!!":-)

Here is the program boiled down to the minimum.  It doesn't error out, but
doesn't work so obviously has a bind or callback bug.  Note that I am not
saying that it should work like this, just that I don't understand why it
doesn't.  I am using the working example that Slaven gave and my code and
trying to make them meet in the middle.  So far no luck.


#!/usr/bin/perl -w
use strict;
use Tk;

my $mw = MainWindow->new;
$mw->geometry("350x400");

my	$text = $mw->Text(-height => 1, -width => 42)->pack;
my	$listbox = $mw->Scrolled("Listbox",-selectmode => "single")->pack;
        $listbox->bind('<ButtonRelease-1>' => [\&selectcommand,] );

	$listbox -> insert('end',"Click this line");
	$text -> insert('end',"Delete this line");

MainLoop;

sub selectcommand {
	$text->deleteSelected;
	print "Routine called\n";  #just to make sure that I called it.
}

Thanks again
KRF
 
0
krf
8/27/2004 2:24:07 AM
krf <krf@Vega.com> writes:

> > You never showed us your example, so we can't really say why it's not 
> > doing what you expect it to. As a rule of thumb, whenever you experience 
> > something you can't understand, it is best to try and come up with a 
> > minimal program that exhibits the behaviour and post it. This makes it 
> > easier for every one.
> > 
> 
> Ok, good point.  I guess my post WAS along the newbie line of "I have a
> problem - whats wrong?  Help!!":-)
> 
> Here is the program boiled down to the minimum.  It doesn't error out, but
> doesn't work so obviously has a bind or callback bug.  Note that I am not
> saying that it should work like this, just that I don't understand why it
> doesn't.  I am using the working example that Slaven gave and my code and
> trying to make them meet in the middle.  So far no luck.
> 

Try adding -exportselection=>0 to your Listbox definition. The problem
is: in the moment you click on the listbox, the listbox entry is
selected and the text selection is removed, so there's nothing to
delete in deleteSelected. By specifying -exportselection in any of
both widgets you make sure that both selections can coexist.

Regards,
        Slaven

-- 
Slaven Rezic - slaven <at> rezic <dot> de

    tkruler - Perl/Tk program for measuring screen distances
    http://ptktools.sourceforge.net/#tkruler
0
Slaven
8/27/2004 7:30:54 AM
Reply:

Similar Artilces:

Perl/Tk: can't get -command=> \&function to work 'on-the-fly'!!
Please Help! I am trying to define buttons 'on-the-fly' mostly because their number is determined in a config file - I don't know how many I will need. It's ROYALLY NOT WORKING. I think Tk.pm is having issues. And it's all driving me very... verrrryyy... batty. *** I WANT THIS TO WORK *** (pseudo-code) for i=1;i<100,i++ { $handle[i] = menubar->command(-label => "test_i", %somecolors, -command => Move2Folder(i)); *** IS THIS TOO MUCH TO ASK??? *** 1) If I 'unroll it' (see end of this message) AND wrap the Move2Folder function...

Can't get passed 'use tk;' in my 1st perl/tk program.
I'm trying to run my 1st perl/tk program and can't get passed the "use Tk;" command. I get error, "Can't locate Tk.pm" and if I add a "use lib" pointer to directory containing Tk.pm, I get error message "Can't locate loadable object for module Tk::Event". SEE BELOW for actual scripts and error messages. Environment: Mac OS x 10.3.8; perl version 5.8.1; Tk directory Tk-804.027. Experince level: Used to write lots of perl code, 15 years ago on Sun/unix. Just wrote my 1st perl code on MAC. This is my first try at pe...

I don't work for IBM and I don't make promises I can't deliver on
I wish I could afford an advertising campaign to compete with what they have on the Internet now. I promise to go totally ballistic at the next LLLNL contract. Robert. On 8/12/2011 11:24 PM, Robert Myers wrote: > I wish I could afford an advertising campaign to compete with what they > have on the Internet now. > > I promise to go totally ballistic at the next LLLNL contract. > > Robert. I don't work for IBM (anymore) either. If you are talking about the death of Blue Waters, I don't believe they said they couldn't deliver. They said they chose not to beca...

Databases Don't Work With OSes; OSes Don't Work With Databases -- Windos 2003 "You've Made A Mess" Say Irate Users !?!!
http://groups.google.com/groups?q=windows+2003+server+problem&hl=en&lr=&ie=UTF-8&as_drrb=b&as_mind=12&as_minm=2&as_miny=2004&as_maxd=7&as_maxm=6&as_maxy=2004&selm=ObEBOsECEHA.684%40tk2msftngp13.phx.gbl&rnum=1 Search Result 1 From: Dave Verwer (d.verwer@link-hrsystems.com) Subject: Problem with SQL Server & MSDTC on Windows 2003 (dtctester.exe related) View: Complete Thread (9 articles) Original Format Newsgroups: microsoft.public.sqlserver.server, microsoft.public.windows.server.general Date: 2004-03-12 08:02:14 PST Hi all I am not su...

Table function parameters don't seem to be working
I'm working on Oracle 10g R2. I have a query I'm trying to write using a table function. I need to put a date range in the query which is against a partitioned table - partitioned on the date. When I run a non-table function version it takes 4 minutes yet when I run the table function version it can take 15-20 minutes or more. It almost seems as if the table function doesn't see the parameters in the cursor. I would like to use the table function and take advantage of the ability to pipe rows back and being able to manipulate the data within the function when loading tables. T...

tk busy command doesn't seem to work as documented
The following script first creates and focuses on a button, and then using the suggested workaround from the docs[1] it creates a dummy widget and focuses it after it makes the button busy: ----- ttk::button .button1 -text "Button1" bind .button1 <KeyPress> { puts "Button1: Pressed the '%K' key" } pack .button1 focus .button1 tk busy hold .button1 label .dummy focus .dummy update ----- However as soon as the toplevel window is activated with the mouse, focus automatically moves to .button1 and it starts receiving keyboard events, even though t...

w2ksp4 cygwin Perl/Tk 'cpan -i Tk' fails
Hello, world! I have a W2K SP4 box with a fresh install of Cygwin, and would like to use Perl/Tk. When I attempt to install the Tk module using cpan: dpchrist@w2k30g:~$ cpan -i Tk CPAN: Storable loaded ok Going to read /home/dpchrist/.cpan/Metadata Database was generated on Sat, 13 Sep 2003 12:45:46 GMT Running install for module Tk ... Failed Test Stat Wstat Total Fail Failed List of Failed -------------------------------------------------------------------- ----------- t/cursor.t 255 65280 1 1 100.00% 1 t/entry.t ...

TK entry fields don't work in SuSE 9.3
After installing SuSE 9.3 recently, my Tcl/Tk scripts have a serious problem: it is no longer possible to enter text into "entry" fields! These scripts worked fine with SuSE 9.2. I am using ActiveTcl8.4.6.1. Anyone else experiencing this problem? Thanks- QuestionAuthority wrote: > After installing SuSE 9.3 recently, my Tcl/Tk scripts > have a serious problem: it is no longer possible to > enter text into "entry" fields! These scripts > worked fine with SuSE 9.2. I am using > ActiveTcl8.4.6.1. Anyone else experiencing this problem? The problem is being tra...

Don't get Perl/Tk compiled on HP-UX 11.00
Hello. I'm having a hell of a time getting Perl/Tk (current version at this time, ie. 804.027) to compile on my HP-UX 11.00 server with Perl 5.8.3 from the HP Porting Center (http://hpux.connect.org.uk/ -> http://hpux.asknet.de/hppd/hpux/Languages/perl-5.8.3/). Here's what I do and get: 16:34:15 vz6tml@s08nfs:~/src $ cd Tk-804.027 16:35:39 vz6tml@s08nfs:~/src/Tk-804.027 $ perl Makefile.PL X11=/usr/lib/X11R6 X11INC=/usr/include/X11R6/X11 X11LIB=/usr/lib/X11R6 perl is installed in /usr/local/lib/perl5/5.8.3/PA-RISC2.0 okay PPM for perl5.008003 Test Compiling config/sig...

newbie question: Tk::Tree 'open' setting doesn't work?
I have the following on my Tree object: $ctree->add('Baby Items', -text => 'Baby Items', -at => 0); $ctree->add('Baby Items.Bibs', -text => 'Bibs', -at => 1); $ctree->add('Baby Items.Blankets', -text => 'Blankets', -at => 2); $ctree->add('Doilies', -text => 'Doilies', -at => 3); $ctree->add('Doilies.Small Circular', -text => 'Small Circular', -at => 4); $ctree->autosetmode; $ctree->setmode('Baby Items', 'open'); $ctree->setmode('Doi...

Linux crapware victim: Mepis8 'collapsed'... webcams don't work on Ubuntu 12.04..."Don't tell me to build a kernel..."
"I need my webcam to work with flash on web pages so that I can speak to family members overseas (Kopete and suchlike). I used mepis8 for years and everything was perfect, my webcams (three different makes), printers and anything else I cared to plug in worked from the off. lovely!! Then mepis8 collapsed suddenly and nothing worked. I tried the newer mepis variants and every other linux distro that I came across to solve the problem, but nothing works. I'm now using ubuntu 12.04, because it's not windows I suppose, but it's far from what I need. ...

AOL 9.0 don't do it just don't . Don't even think of it.
I had 8.0, and it ran fine. I downloaded 9.0 and that was the end of my computer never having a problem. 3 years and no problems. 1 week with AOL 9.0 and I've had 27 error messages , sign offs and other problems. AOL was no help. They can't even admit it has a problem. So I had to REFORMAT MY HARD DRIVE AND INSTALL ALL MY PROGRAMS AND ALL MY SAVED FILES. Needless to say I no longer have AOL at all. Reformat and get rid of it. ...

log() function don't work, how can workarround this function ...?
Hi to all From Help of Vo i see : Description The Log() function returns x in the following equation: e^x = y therefore : LOCAL i AS INT LOCAL f AS FLOAT i:=2^10 // result 1024 f:=LOG(i) // result 6,93 and not 10,00 why don't work ? Regards From Naples Luigi De Palma But the answer is correct! You seem to be expecting the log function to know that you want to work to base 2 - but the log function works to base e, where e = 2.718281828...... So, e^6.9314718 = 1024 Rob Luigi De Palma wrote: > Hi to all > > From Help of Vo...

Function 'system' nasty behaviour in Cygwin Perl/Tk
Hi All, I've recently installed latest x-Cygwin on different PCs and suddenly discovered strange reaction on 'system' function inside Perl/Tk apps. Naturally, console applications running well with this function. Below you can see my snippet code and stuff it prints. FELIX-XP-~> cat test.pl #!/usr/bin/perl # Code automatically generated by VPTK_W use strict; use Tk; use Tk::Button; my $mw=MainWindow->new(-title=>'Bug demo'); my $w_Button_001 = $mw -> Button ( -background=>'green4', -foreground=>'Yellow', -text=>...

Web resources about - TK extended text widget functions don't seem to work. - comp.lang.perl.tk

Talk:Trigonometric functions - Wikipedia, the free encyclopedia
This article is within the scope of WikiProject Mathematics , a collaborative effort to improve the coverage of Mathematics on Wikipedia. If ...

Standing desks may boost students’ cognitive function as well as health
(credit: Texas A&M University ) Standing desks—most often installed in efforts to improve physical activity and health—may help get your noggin ...

A Non-Sokratic Dialogue on Social Welfare Functions: Hoisted from the Archives from 2003
**[A Non-Sokratic Dialogue on Social Welfare Functions: Hoisted from the Archives from 2003](http://www.j-bradford-delong.net/movable_type/2 ...

Drop Point Knives: Function, Fit, Timeless
Drop Point Knives: Function, Fit, Timeless

Here's how squads and iron sights will function in Rising Storm 2: Vietnam
... roles and create a squad, and the creator can name, lock, or invite others to their little group. The more an outfit fills up, the more functions ...

Learning F# – The Thunderdome Principle for Functions
... One object enters, one object leaves! What I like about F# is that the language designers took a similar approach when they implemented functions. ...

Slim and Soft Cover-Ups: Protecting Your Laptop with Function and Style
I’m a klutz. My phone has the scars and cracks to prove it. Likewise, my laptop bears scratches and dents in the lid, from me banging it into ...

Using AWS Lambda functions to create print ready files
... going to tell you about our processing architecture as well as at a recent performance improvement with the integration of AWS Lambda functions. ...

Power Through Your Work With a “Forcing Function”
... to flow faster and more easily when I know I only have a couple of hours to turn it in. Entrepreneur Dan Martell calls this a “forcing function” ...

Macphun Creative Kit 2016 review: Critical photo editing functions delivered in one diverse app
With Creative Kit, Macphun wants to pick up where Apple’s now-defunct Aperture left off. As a plug-in to Photos , Macphun’s apps significantly ...

Resources last updated: 2/6/2016 7:40:21 PM