Files
phpy/examples/wxPython/hello.php
tianfenghan 1dd5be8d7d Optimize
2023-12-21 18:08:28 +08:00

34 lines
955 B
PHP

<?php
$wx = PyCore::import('wx');
$app = $wx->App();
$frame = $wx->Frame(null, title: 'hello world');
$frame->Show();
$fileMenu = $wx->Menu();
$helloItem = $fileMenu->Append(-1, "&Hello...\tCtrl-H", "Help string shown in status bar for this menu item");
$fileMenu->AppendSeparator();
$exitItem = $fileMenu->Append($wx->ID_EXIT);
$helpMenu = $wx->Menu();
$aboutItem = $helpMenu->Append($wx->ID_ABOUT);
$menuBar = $wx->MenuBar();
$menuBar->Append($fileMenu, "&File");
$menuBar->Append($helpMenu, "&Help");
$frame->Bind($wx->EVT_MENU, function () use ($wx) {
$wx->MessageBox("Hello again from wxPython");
}, $helloItem);
$frame->Bind($wx->EVT_MENU, function () use ($frame) {
$frame->Close();
}, $exitItem);
$frame->Bind($wx->EVT_MENU, function () use ($wx) {
$wx->MessageBox("This is a wxPython Hello World sample", "About Hello World 2", $wx->OK | $wx->ICON_INFORMATION);
}, $aboutItem);
$frame->SetMenuBar($menuBar);
$app->MainLoop();