| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Tkx::Login; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
19255
|
use Tkx; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use warnings; |
|
6
|
|
|
|
|
|
|
use strict; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
$Tkx::Login::VERSION='1.11'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub askpass { |
|
11
|
|
|
|
|
|
|
my $interation = 0; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $mw = shift @_; |
|
14
|
|
|
|
|
|
|
my $text = shift @_; |
|
15
|
|
|
|
|
|
|
my $user = shift @_; |
|
16
|
|
|
|
|
|
|
my $pass = shift @_; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $original_user = $user; |
|
19
|
|
|
|
|
|
|
my $original_pass = $pass; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $win = $mw->new_toplevel(); |
|
22
|
|
|
|
|
|
|
$win->g_wm_title("Login"); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$win->new_ttk__label(-text => $text )->g_grid( -columnspan => 2 ) if $text; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$win->new_ttk__label(-text => "Username:" )->g_grid( -stick=> 'e', -column => 0, -row => 1 ); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $name_entry = $win->new_ttk__entry(-textvariable => \$user); |
|
29
|
|
|
|
|
|
|
$name_entry->g_grid( -column => 1, -row => 1 ); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$win->new_ttk__label(-text => "Password:" )->g_grid( -sticky => 'e', -column => 0, -row => 2 ); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
my $pass_entry = $win->new_ttk__entry(-textvariable => \$pass, -show => '*'); |
|
34
|
|
|
|
|
|
|
$pass_entry->g_grid( -column => 1, -row => 2 ); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my $okcancel; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
my $ok = $win->new_button( |
|
39
|
|
|
|
|
|
|
-text => 'Ok', |
|
40
|
|
|
|
|
|
|
-command => sub { |
|
41
|
|
|
|
|
|
|
$okcancel = 'ok'; |
|
42
|
|
|
|
|
|
|
$interation++; |
|
43
|
|
|
|
|
|
|
$win->g_destroy; |
|
44
|
|
|
|
|
|
|
}, |
|
45
|
|
|
|
|
|
|
)->g_grid( -column => 0, -row => 3 ); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $cancel = $win->new_button( |
|
48
|
|
|
|
|
|
|
-text => 'Cancel', |
|
49
|
|
|
|
|
|
|
-command => sub { |
|
50
|
|
|
|
|
|
|
$okcancel = 'cancel'; |
|
51
|
|
|
|
|
|
|
$interation++; |
|
52
|
|
|
|
|
|
|
$win->g_destroy; |
|
53
|
|
|
|
|
|
|
}, |
|
54
|
|
|
|
|
|
|
)->g_grid( -column => 1, -row => 3 ); |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
while ( $interation < 1 ) { |
|
57
|
|
|
|
|
|
|
Tkx::update(); |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
return $okcancel eq 'ok' ? ( $user, $pass ) : ( $original_user, $original_pass ); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 NAME |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Tkx::Login - A Simple Login Window for Tkx |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 SYNOPSIS: |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Tkx::Login provides a simple login interface for Tkx applications. Given |
|
72
|
|
|
|
|
|
|
a window value to extend, it opens a new window, queries for username and |
|
73
|
|
|
|
|
|
|
password and returns the values. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 USAGE: |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
use Tkx::Login; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my ($username,$password) = Tkx::Login::askpass($mainwindow,$message,$pre_user,$pre_password); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Parameters: |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$mainwindow - Current MainWindow in your Tkx app. (required) |
|
84
|
|
|
|
|
|
|
$message - A text message to display in the login window. (optional) |
|
85
|
|
|
|
|
|
|
$pre_user - A value to pre-populate the username blank with. (optional) |
|
86
|
|
|
|
|
|
|
$pre_pass - A value to pre-populate the password blank with. This will be obscured with asterisks. (optional) |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 BUGS AND SOURCE |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Bug tracking for this module: https://rt.cpan.org/Dist/Display.html?Name=Tkx-Login |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Source hosting: http://www.github.com/bennie/perl-Tkx-Login |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 VERSION |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Tkx::Login v1.11 (2014/04/29) |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
(c) 2012-2014, Phillip Pollard |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 LICENSE |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This source code is released under the "Perl Artistic License 2.0," the text of |
|
105
|
|
|
|
|
|
|
which is included in the LICENSE file of this distribution. It may also be |
|
106
|
|
|
|
|
|
|
reviewed here: http://opensource.org/licenses/artistic-license-2.0 |