auto-scripts/auto-wxWidgets


Home Back

#!/usr/bin/env python3
import sys
import os

try:
    path=os.path.join(os.getcwd(), sys.argv[1])
except IndexError:
    print("Si usa cosi' : auto-wxWidgets <nome progetto>")
    exit(-1)
try:
    os.mkdir(path)
except FileExistsError:
    print("Esiste una cartella con lo stesso nome! Esco.")
    exit(-1)

os.chdir(path)



t='''
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif
#include "wx/xrc/xmlres.h"

#include "gui.cpp" 
 

 
class MainFrame{
    public:
        wxFrame frame0;
        wxStaticText *label0;
        wxTextCtrl *text0;
        wxButton   *button0;
        void ShowFrame();
        void OnClickme(wxCommandEvent& event);
} ;
 
void MainFrame::ShowFrame()
{
    wxXmlResource::Get()->LoadFrame(&frame0, NULL,  wxT("frame0"));
    label0 = XRCCTRL(frame0, "label0", wxStaticText);
    text0 = XRCCTRL(frame0, "text0", wxTextCtrl);
    button0 = XRCCTRL(frame0, "button0", wxButton);
    button0->Bind(wxEVT_BUTTON, &MainFrame::OnClickme, this);
    frame0.Show();
 
}
 
void MainFrame::OnClickme(wxCommandEvent& event)
{
    label0->SetLabel(text0->GetValue());
    puts(text0->GetValue());
}
 



class MyApp: public wxApp
{
    virtual bool OnInit();
}; 
bool MyApp::OnInit()
{
    wxXmlResource::Get()->InitAllHandlers();  
    InitXmlResource(); 
 
    MainFrame *MainWin = new MainFrame(); 
    MainWin->ShowFrame();                   
 
    return true;
}
 
 
IMPLEMENT_APP(MyApp)
'''

f = open("main.cc", "a")
f.write(t)
f.close()


t='''
CPP = g++ 
OPTS =  `wx-config --cxxflags --libs`

all:
    wxrc gui.xrc -v -c -o gui.cpp
    $(CPP) main.cc -o wxtest $(OPTS)

windows:
    wxrc gui.xrc -v -c -o gui.cpp
    g++ -static  main.cc -o wxtest `wx-config --cxxflags --libs --static=yes`

'''
f = open("makefile", "a")
f.write(t)
f.close()

t='''<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
    <FileVersion major="1" minor="16" />
    <object class="Project" expanded="1">
        <property name="class_decoration">; </property>
        <property name="code_generation">XRC</property>
        <property name="disconnect_events">1</property>
        <property name="disconnect_mode">source_name</property>
        <property name="disconnect_php_events">0</property>
        <property name="disconnect_python_events">0</property>
        <property name="embedded_files_path">res</property>
        <property name="encoding">UTF-8</property>
        <property name="event_generation">connect</property>
        <property name="file">gui</property>
        <property name="first_id">1000</property>
        <property name="help_provider">none</property>
        <property name="image_path_wrapper_function_name"></property>
        <property name="indent_with_spaces"></property>
        <property name="internationalize">0</property>
        <property name="name">risorse</property>
        <property name="namespace"></property>
        <property name="path">.</property>
        <property name="precompiled_header"></property>
        <property name="relative_path">1</property>
        <property name="skip_lua_events">1</property>
        <property name="skip_php_events">1</property>
        <property name="skip_python_events">1</property>
        <property name="ui_table">UI</property>
        <property name="use_array_enum">0</property>
        <property name="use_enum">0</property>
        <property name="use_microsoft_bom">0</property>
        <object class="Frame" expanded="1">
            <property name="aui_managed">0</property>
            <property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
            <property name="bg"></property>
            <property name="center">wxBOTH</property>
            <property name="context_help"></property>
            <property name="context_menu">1</property>
            <property name="enabled">1</property>
            <property name="event_handler">impl_virtual</property>
            <property name="extra_style"></property>
            <property name="fg"></property>
            <property name="font"></property>
            <property name="hidden">0</property>
            <property name="id">wxID_ANY</property>
            <property name="maximum_size"></property>
            <property name="minimum_size"></property>
            <property name="name">frame0</property>
            <property name="pos"></property>
            <property name="size">500,300</property>
            <property name="style">wxDEFAULT_FRAME_STYLE</property>
            <property name="subclass">; ; forward_declare</property>
            <property name="title"></property>
            <property name="tooltip"></property>
            <property name="two_step_creation">0</property>
            <property name="window_extra_style"></property>
            <property name="window_name"></property>
            <property name="window_style">wxTAB_TRAVERSAL</property>
            <property name="xrc_skip_sizer">1</property>
            <object class="wxBoxSizer" expanded="1">
                <property name="minimum_size"></property>
                <property name="name">bSizer1</property>
                <property name="orient">wxVERTICAL</property>
                <property name="permission">none</property>
                <object class="sizeritem" expanded="1">
                    <property name="border">5</property>
                    <property name="flag">wxALL|wxEXPAND</property>
                    <property name="proportion">0</property>
                    <object class="wxStaticText" expanded="1">
                        <property name="BottomDockable">1</property>
                        <property name="LeftDockable">1</property>
                        <property name="RightDockable">1</property>
                        <property name="TopDockable">1</property>
                        <property name="aui_layer"></property>
                        <property name="aui_name"></property>
                        <property name="aui_position"></property>
                        <property name="aui_row"></property>
                        <property name="best_size"></property>
                        <property name="bg"></property>
                        <property name="caption"></property>
                        <property name="caption_visible">1</property>
                        <property name="center_pane">0</property>
                        <property name="close_button">1</property>
                        <property name="context_help"></property>
                        <property name="context_menu">1</property>
                        <property name="default_pane">0</property>
                        <property name="dock">Dock</property>
                        <property name="dock_fixed">0</property>
                        <property name="docking">Left</property>
                        <property name="enabled">1</property>
                        <property name="fg"></property>
                        <property name="floatable">1</property>
                        <property name="font"></property>
                        <property name="gripper">0</property>
                        <property name="hidden">0</property>
                        <property name="id">wxID_ANY</property>
                        <property name="label">iserisci del testo e premi il pulsante</property>
                        <property name="markup">0</property>
                        <property name="max_size"></property>
                        <property name="maximize_button">0</property>
                        <property name="maximum_size"></property>
                        <property name="min_size"></property>
                        <property name="minimize_button">0</property>
                        <property name="minimum_size"></property>
                        <property name="moveable">1</property>
                        <property name="name">label0</property>
                        <property name="pane_border">1</property>
                        <property name="pane_position"></property>
                        <property name="pane_size"></property>
                        <property name="permission">protected</property>
                        <property name="pin_button">1</property>
                        <property name="pos"></property>
                        <property name="resize">Resizable</property>
                        <property name="show">1</property>
                        <property name="size"></property>
                        <property name="style"></property>
                        <property name="subclass">; ; forward_declare</property>
                        <property name="toolbar_pane">0</property>
                        <property name="tooltip"></property>
                        <property name="window_extra_style"></property>
                        <property name="window_name"></property>
                        <property name="window_style"></property>
                        <property name="wrap">-1</property>
                    </object>
                </object>
                <object class="sizeritem" expanded="1">
                    <property name="border">5</property>
                    <property name="flag">wxALL|wxEXPAND</property>
                    <property name="proportion">0</property>
                    <object class="wxTextCtrl" expanded="1">
                        <property name="BottomDockable">1</property>
                        <property name="LeftDockable">1</property>
                        <property name="RightDockable">1</property>
                        <property name="TopDockable">1</property>
                        <property name="aui_layer"></property>
                        <property name="aui_name"></property>
                        <property name="aui_position"></property>
                        <property name="aui_row"></property>
                        <property name="best_size"></property>
                        <property name="bg"></property>
                        <property name="caption"></property>
                        <property name="caption_visible">1</property>
                        <property name="center_pane">0</property>
                        <property name="close_button">1</property>
                        <property name="context_help"></property>
                        <property name="context_menu">1</property>
                        <property name="default_pane">0</property>
                        <property name="dock">Dock</property>
                        <property name="dock_fixed">0</property>
                        <property name="docking">Left</property>
                        <property name="enabled">1</property>
                        <property name="fg"></property>
                        <property name="floatable">1</property>
                        <property name="font"></property>
                        <property name="gripper">0</property>
                        <property name="hidden">0</property>
                        <property name="id">wxID_ANY</property>
                        <property name="max_size"></property>
                        <property name="maximize_button">0</property>
                        <property name="maximum_size"></property>
                        <property name="maxlength"></property>
                        <property name="min_size"></property>
                        <property name="minimize_button">0</property>
                        <property name="minimum_size"></property>
                        <property name="moveable">1</property>
                        <property name="name">text0</property>
                        <property name="pane_border">1</property>
                        <property name="pane_position"></property>
                        <property name="pane_size"></property>
                        <property name="permission">protected</property>
                        <property name="pin_button">1</property>
                        <property name="pos"></property>
                        <property name="resize">Resizable</property>
                        <property name="show">1</property>
                        <property name="size"></property>
                        <property name="style"></property>
                        <property name="subclass">; ; forward_declare</property>
                        <property name="toolbar_pane">0</property>
                        <property name="tooltip"></property>
                        <property name="validator_data_type"></property>
                        <property name="validator_style">wxFILTER_NONE</property>
                        <property name="validator_type">wxDefaultValidator</property>
                        <property name="validator_variable"></property>
                        <property name="value"></property>
                        <property name="window_extra_style"></property>
                        <property name="window_name"></property>
                        <property name="window_style"></property>
                    </object>
                </object>
                <object class="sizeritem" expanded="1">
                    <property name="border">5</property>
                    <property name="flag">wxALL</property>
                    <property name="proportion">0</property>
                    <object class="wxButton" expanded="1">
                        <property name="BottomDockable">1</property>
                        <property name="LeftDockable">1</property>
                        <property name="RightDockable">1</property>
                        <property name="TopDockable">1</property>
                        <property name="aui_layer"></property>
                        <property name="aui_name"></property>
                        <property name="aui_position"></property>
                        <property name="aui_row"></property>
                        <property name="auth_needed">0</property>
                        <property name="best_size"></property>
                        <property name="bg"></property>
                        <property name="bitmap"></property>
                        <property name="caption"></property>
                        <property name="caption_visible">1</property>
                        <property name="center_pane">0</property>
                        <property name="close_button">1</property>
                        <property name="context_help"></property>
                        <property name="context_menu">1</property>
                        <property name="current"></property>
                        <property name="default">0</property>
                        <property name="default_pane">0</property>
                        <property name="disabled"></property>
                        <property name="dock">Dock</property>
                        <property name="dock_fixed">0</property>
                        <property name="docking">Left</property>
                        <property name="enabled">1</property>
                        <property name="fg"></property>
                        <property name="floatable">1</property>
                        <property name="focus"></property>
                        <property name="font"></property>
                        <property name="gripper">0</property>
                        <property name="hidden">0</property>
                        <property name="id">wxID_ANY</property>
                        <property name="label">invia</property>
                        <property name="margins"></property>
                        <property name="markup">0</property>
                        <property name="max_size"></property>
                        <property name="maximize_button">0</property>
                        <property name="maximum_size"></property>
                        <property name="min_size"></property>
                        <property name="minimize_button">0</property>
                        <property name="minimum_size"></property>
                        <property name="moveable">1</property>
                        <property name="name">button0</property>
                        <property name="pane_border">1</property>
                        <property name="pane_position"></property>
                        <property name="pane_size"></property>
                        <property name="permission">protected</property>
                        <property name="pin_button">1</property>
                        <property name="pos"></property>
                        <property name="position"></property>
                        <property name="pressed"></property>
                        <property name="resize">Resizable</property>
                        <property name="show">1</property>
                        <property name="size"></property>
                        <property name="style"></property>
                        <property name="subclass">; ; forward_declare</property>
                        <property name="toolbar_pane">0</property>
                        <property name="tooltip"></property>
                        <property name="validator_data_type"></property>
                        <property name="validator_style">wxFILTER_NONE</property>
                        <property name="validator_type">wxDefaultValidator</property>
                        <property name="validator_variable"></property>
                        <property name="window_extra_style"></property>
                        <property name="window_name"></property>
                        <property name="window_style"></property>
                    </object>
                </object>
            </object>
        </object>
    </object>
</wxFormBuilder_Project>

'''
f = open("gui.fbp", "a")
f.write(t)
f.close()

t='''<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<resource xmlns="http://www.wxwidgets.org/wxxrc" version="2.5.3.0">
    <object class="wxFrame" name="frame0">
        <style>wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL</style>
        <size>500,300</size>
        <title></title>
        <centered>1</centered>
        <aui_managed>0</aui_managed>
        <object class="wxBoxSizer">
            <orient>wxVERTICAL</orient>
            <object class="sizeritem">
                <option>0</option>
                <flag>wxALL|wxEXPAND</flag>
                <border>5</border>
                <object class="wxStaticText" name="label0">
                    <label>iserisci del testo e premi il pulsante</label>
                    <wrap>-1</wrap>
                </object>
            </object>
            <object class="sizeritem">
                <option>0</option>
                <flag>wxALL|wxEXPAND</flag>
                <border>5</border>
                <object class="wxTextCtrl" name="text0">
                    <value></value>
                </object>
            </object>
            <object class="sizeritem">
                <option>0</option>
                <flag>wxALL</flag>
                <border>5</border>
                <object class="wxButton" name="button0">
                    <label>invia</label>
                    <default>0</default>
                    <auth_needed>0</auth_needed>
                    <markup>0</markup>
                    <bitmap />
                </object>
            </object>
        </object>
    </object>
</resource>

'''

f = open("gui.xrc", "a")
f.write(t)
f.close()



t='''
project('wxtest', 'cpp')

#wxrc gui.xrc -v -c -o gui.cpp
run_command('wxrc', 'gui.xrc', '-v', '-c','-o','gui.cpp', check: true)


extra_args= []
wxwidgets = dependency('wxwidgets', version : '>=3.0.0', modules : ['std', 'stc'])

#meson.add_install_script('install.sh')

executable('wxtest','main.cc', 
            dependencies :[wxwidgets],
            c_args : extra_args, 
            install : false, 
            install_dir : '/usr/local/bin')





'''
f = open("meson.build", "a")
f.write(t)
f.close()

Powered by Code, a simple repository browser by Fabio Di Matteo