Re: pass vars to sub via TK/Button
Greetings, 16.12.2003, R. Joseph Newton wrote: There is no decoding happening. Entry is a Tk widget. It is not a string. The string contents are a property held in the widget's hash. The get method is an accessor function that returns this value. AFAIK, Tk does not use the sort of default properties that you might find in VB, where you can assign a Text widget to a string, and the string gets the value of that widgets text. Since Perl stores its references at least partly as strings, you get the reference string when you assign or use a widget referencxe in string context. Ah, I can see the light (Faintly. At the other side of the tunnel. Wait, don't run!). Maybe I should use modules more often. Thanks a bunch! :) Best regards, oliver. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
pass vars to sub via TK/Button
Greetings, I'd like to know how to pass variables fetched by TK/entry to a subroutine by using a Button. The Button/-command line in the following script is obviously wrong, but should suffice to illustrate what I want it to do. I'd be happy if someone could tell me how to do this properly. --- #! /usr/bin/perl -w use strict; use Tk; my $main = MainWindow-new; my $var1 = $main - Entry( -width = 30 ); $var1 - pack; my $var2 = $main - Entry( -width = 30 ); $var2 - pack; $main - Button ( -text = 'Add', -command = \add_item($var1, $var2) # ^^ ) - pack; MainLoop; sub add_item { print Added @_\n; } --- Best regards, oliver. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: pass vars to sub via TK/Button
Greetings, 15.12.2003, [EMAIL PROTECTED] wrote: $mw-Button (-text=run, -command= sub {test($rb_val,$bonobo,$oracleid)}) -place(-x=320,-y=250 ,-width=75); thanks for your reply. I tried to adapt to your example: $main-Button ( -text = 'Add', -command = sub { add_item($var1, $var2) } ) - pack; but the output add_item delivers looks more like hash references than the content of aforementioned variables: Added Tk::Entry=HASH(0x1c1956c) Tk::Entry=HASH(0x1c1e3a8) Is it possible to pass simple variables via Entry/Button in the first place, and if, how? Best regards, oliver. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: pass vars to sub via TK/Button
Greetings, 15.12.2003, zentara wrote: $main - Button ( -text = 'Add', -command = sub{\add_item($var1,$var2)} ) - pack; [...] sub add_item { [...] my $entry1 = $_[0]-get(); my $entry2 = $_[1]-get(); [...] } thanks for your reply. I tried this out and it works, though I have no idea what it actually does and why I have to alter/decode/whatever the fetched data in the first place. I guess I have to read into get() a bit. Thanks a bunch, same goes to Laurent. Best regards, oliver. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: pass vars to sub via TK/Button
Greetings, thanks for your reply. 16.12.2003, R. Joseph Newton wrote: What does perldoc Tk::Entry tell you? a) that there is a doc for Entry in the first place - I didn't know that, only read the main TK documentation. ^^; b) Now that I read it, hmm, not much I'm afraid. Either I missed the part where it states how the data is encoded or I don't know enough about Perl (true, of course) to have it trigger something in my brain. Try something like this: [...] command = [\read_entry_and_print, $entry])-pack; [...] my $entry = shift; my $response = $entry-get(); [...] It works, thanks. As mentioned in the other mail (which should have been out to the list by yesterday already) I'll read into get as soon as possible. my $win = MainWindow-new(height = 150, -width = 250); Hmm, are you sure this works? The window my script creates shrinks to width and height of the widgets (ActivePerl 5.8 on WinXP if that matters). Ok, and now breakfast. :) Joseph Best regards, oliver. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: looking for help with Net::IRC
Hello Dan, Thursday, April 3, 2003, 11:04:36 PM, you wrote: Net::IRC isn't the best way in the world of creating an IRC bot. I just use IO::Socket, and establish maintain the connection to IRC myself within my own source. Personally that's the better option. thanks for your advice. Since I didn't get one step ahead with Net::IRC I switched to IO::Socket. Some simple routines already work though I still do not know how to detect the modes of a channel or its users. RFC 2810-2812 either do not provide such an option or I just cannot find it. :) Best regards, oliver. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
looking for help with Net::IRC
Greetings, I'm trying to put up a simple IRC bot using the Net::IRC module. Connecting and joining the test channel works quite fine, but I do not quite understand how to make the bot - for example - realize and react when its mode is changed. Is there a good tutorial or in depth documentation covering Net::IRC? Maybe I just do not get the hang of it, but the accompanying Cpan documentation doesn't help me very much. Best regards, oliver. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]