1Wx(3) User Contributed Perl Documentation Wx(3)
2
3
4
6 Wx - interface to the wxWidgets cross-platform GUI toolkit
7
9 use Wx;
10
11 my $app = Wx::SimpleApp->new;
12 my $frame = Wx::Frame->new( undef, -1, 'Hello, world!' );
13
14 $frame->Show;
15 $app->MainLoop;
16
18 The Wx module is a wrapper for the wxWidgets (formerly known as
19 wxWindows) GUI toolkit.
20
21 This module comes with extensive documentation in HTML format; you can
22 download it from http://wxperl.sourceforge.net/
23
25 Please see docs/INSTALL.pod in source package.
26
28 For wxWidgets 2.9.3 and greater, Wx can switch runtime assertions on
29 and off. In wxWidgets 2.9.x and above, there are three levels of
30 debuging
31
32 0 - No debug assertions 1 - Low cost debug assertions 2 - All debug
33 assertions
34
35 If you used Alien::wxWidgets 0.61 or greater to build your wxWidgets,
36 then the libraries will be built using debug level 1. If you specified
37 --wxWidgets-debug for a debug build, then debug level 2 will have been
38 used.
39
40 By default in Wx, debug assertions are switched off. However you may
41 switch assertions on by using
42
43 Wx::EnableDefaultAssertHandler();
44
45 you can switch assertions off again by using
46
47 Wx::DisableAssertHandler();
48
49 You may also set en enviroment variable to cause all invocations of Wx
50 to call Wx::EnableDefaultAssertHandler().
51
52 export WXPERL_OPTIONS=ENABLE_DEFAULT_ASSERT_HANDLER
53
54 This may be useful during tests.
55
56 The enviroment setting WXPERL_OPTIONS can contain multiple options.
57 Options are checked for using a simple regex match. So
58
59 export WXPERL_OPTIONS="ENABLE_DEFAULT_ASSERT_HANDLER SOME_OTHER_SETTING"
60
61 would evaluate as ENABLE_DEFAULT_ASSERT_HANDLER being set.
62
63 If you want to handle assert failures yourself you can override
64 wxApp::OnAssertFailure in your Wx::App derived class.
65
66 sub OnAssertFailure {
67 my ( $self, $file, $line, $function, $condition, $msg ) = @_;
68 ......
69 }
70
71 For wxWidgets 2.8.x, the assert methods have no effect. You may however
72 still usefully override wxApp::OnAssertFailure in a debug build.
73
75 From version 0.98 wxPerl no longer needs to use the special startup
76 executable 'wxperl' to run scripts on the Mac. The ordinary perl
77 interpreter now works without problems. This is because wxPerl now
78 contains code that brings the running application to the front and
79 gives it the focus.
80
81 In a syntax checking editor you may prevent Wx code from being given
82 focus as the front process by setting an environment variable
83
84 export WXPERL_OPTIONS=NO_MAC_SETFRONTPROCESS
85
86 or
87
88 $ENV{WXPERL_OPTIONS} = 'NO_MAC_SETFRONTPROCESS';
89
90 The enviroment setting WXPERL_OPTIONS can contain multiple options.
91 Options are checked for using a simple regex match. So
92
93 export WXPERL_OPTIONS="NO_MAC_SETFRONTPROCESS SOME_OTHER_SETTING"
94
95 would evaluate as NO_MAC_SETFRONTPROCESS being set.
96
97 The code that makes the SetFrontProcess call is in Wx::Mini as
98
99 Wx::MacSetFrontProcess();
100
101 so it is also straightforward to override this method if you wish.
102
103 Finally, any code can force the running application to become the front
104 process regardless of environment settings by calling the xs method
105 directly. (Note the underscore in the method name).
106
107 Wx::_MacSetFrontProcess();
108
110 Beginning with 2.9.0 wxWidgets sets the application locale to the
111 current system locale. Formally in wxWidgets 2.8.x, the locale by
112 default was 'C'.
113
114 A problem arises because in addition to loading gettext translation
115 files, this affects other C calls like printf, sprintf,...
116
117 Perl makes calls to these functions when formatting numbers. Number
118 formatting always uses underlying C library functions. The statements
119 'use locale', or 'no locale' make no difference here.
120
121 So, if your locale is 'de' then when Wx starts, the C library locale
122 gets set accordingly.
123
124 use Wx;
125 print 8.3
126
127 will output 8,3 to the terminal. Formatting uses ',' as the fractional
128 separator.
129
130 This, whilst possibly correct, isn't what most users will be expecting.
131
132 If you want to set the locale to the system default you can do so
133 explicitly.
134
135 $app->{locale} = Wx::Locale->new( &Wx::wxLANGUAGE_DEFAULT );
136
137 You can then also reset just the locale for number formatting to 'C' if
138 that is what you require
139
140 use POSIX qw( setlocale LC_NUMERIC );
141
142 setlocale( LC_NUMERIC, C );
143
144 This code applies equally regardless of which wxWidgets version is
145 being used.
146
148 For standalone (packed using PAR, Perl2Exe, Perl2App, ...)
149 applications to get Windows XP look, a file named "App.exe.manifest"
150 (assuming the program is named "App.exe") and containing the text below
151 must either be placed in the same directory as the executable file or
152 compiled into the file itself. The module Win32::Exe can place a
153 manifest in an executable file
154
155 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
156 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
157 <assemblyIdentity version="1.0.0.0" type="win32" name="Super.wxPerl.Application" />
158 <description>Super wxPerl Application</description>
159 <dependency>
160 <dependentAssembly>
161 <assemblyIdentity type="win32"
162 name="Microsoft.Windows.Common-Controls"
163 version="6.0.0.0"
164 publicKeyToken="6595b64144ccf1df"
165 language="*"
166 processorArchitecture="*" />
167 </dependentAssembly>
168 </dependency>
169 <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
170 <security>
171 <requestedPrivileges>
172 <requestedExecutionLevel level="asInvoker" uiAccess="false" />
173 </requestedPrivileges>
174 </security>
175 </trustInfo>
176 </assembly>
177
179 Mattia Barbon <mbarbon@cpan.org>
180
182 This program is free software; you can redistribute it and/or modify it
183 under the same terms as Perl itself.
184
185
186
187perl v5.34.0 2021-07-27 Wx(3)