Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Quick-Buttons Toolbar

by PyrexKidd (Monk)
on Feb 28, 2011 at 07:42 UTC ( [id://890526]=note: print w/replies, xml ) Need Help??


in reply to Quick-Buttons Toolbar

The story so far...

  • For the time being I have decided to use Wx as the GUI engine for my application.
  • Figuring out Wx with only C++ documentation is interesting. (I'm not very familiar with C++)
  • My biggest challenge was determining a method to 'watch' for input focus to change. (there weren't many examples, I did find one in python, which--well,looks like line noise to me)
  • I still need to determine a method for sending special keys, i.e.: ^N, etc
  • and as someone pointed out on IRC, I don't format like a normal person... I'll leave that up to you to decide...

anyway, here is my first attempt on all of this. I was successful at sending text to the screen. As I am sure there is a better way to do all of this, Comments, suggestions, jokes, are welcomed, even invited.

#!/usr/bin/perl use strict; use warnings; use 5.010001; use Wx; my $last_id = 0; my $curr_id = 0; my @id_list = (undef) x 3; package MyFrame; use base 'Wx::Frame'; use Wx::Event qw(EVT_BUTTON EVT_TIMER); sub new { #use X11::GUITest qw/:ALL/; use X11::GUITest qw/GetInputFocus SetInputFocus SendKeys/; my $ref = shift; my $self= $ref->SUPER::new( undef, #Parent Window -1, #Window ID (-1 means any) 'wxPerl', #Window Title [-1, -1], #Default Position [171, 30], #size ); #create panel my $panel = Wx::Panel->new( $self, #parent window -1, #id ); #create send key button my $button = Wx::Button->new( $panel, # Parent Panel -1, # id 'Send Hello', # label [85, 1], # position [-1, -1], # default size ); # create Quit button my $button_quit = Wx::Button->new( $panel, # Parent Panel -1, # id 'Quit', # label [1, 1], # position [-1, -1], # default size ); my $timer = Wx::Timer->new( $self, # Parent Frame -1, # Timer ID ); $timer->Start(1); EVT_TIMER $self, $timer,\&do_stuff; #send key button EVT_BUTTON $self, $button, \&on_click_button; #send key click quit EVT_BUTTON $self, $button_quit, \&on_click_quit; return $self; } sub do_stuff { my $this_id = GetInputFocus; if ($this_id != $id_list[2]){ print STDOUT $this_id . "\n"; shift @id_list; push @id_list, $this_id; } else { #do nothing for now } } sub on_click_quit { my ($self, $event) = @_; $self->quit; } sub on_click_button { my ($self, $event) = @_; say @id_list; SetInputFocus $id_list[0]; print STDOUT "sent to: $id_list[0], last: $id_list[1], $id_list[2] +\n"; # SendKeys QuoteStringForSendKeys("%N"); SendKeys ('hello'); $self->SetTitle( 'Clicked'); } package MyApp; use base 'Wx::App'; sub OnInit { my $frame = MyFrame->new; $frame->Show(1); } package main; my $app = MyApp->new; $app->MainLoop;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://890526]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2024-04-25 14:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found