zoukankan      html  css  js  c++  java
  • Ubuntu下的wxWidgets编程(学生信息管理写入文件,文件格式是.txt)

    wxWidgets和Codeblocks的编译安装,GUI程序开发平台的搭建具体步骤如下:
    (1)基本编译环境安装
    安装编译工具(gcc之类)sudo apt-get install build-essential 
    安装X11sudo apt-get install libx11-dev
    安装GTK需要的东西sudo apt-get install?gnome-core-devel
    (2)下载wxWidgets源码包并解压缩到 #{wxdir}
    (3)创建基于gtk和x11的编译目录${wx}
    mkdir ${wx}/buildgtk
    mkdir ${wx}/buildx11
    (4)编译wxgtk
    cd ${wx}/buildgtk
    sudo ${wxdir}/configure –with-gtk
    sudo make
    sudo make install
    sudo ldconfig
    (5)编译wxx11
    cd ${wx}/buildxll
    sudo ${wxdir}/configure -–with-x11
    sudo make
    sudo make install
    sudo ldconfig
    (6)此时wxGTK与wxX11就都编译并且安装完成了,以后编译程序的时候只需要调用不用的类库即可。
    (7)wxconfig --help

    1.#include <wx/string.h>

    #include <wx/utils.h>
    #include <wx/datetime.h>
    #include <unistd.h>
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
      wxPrintf(wxT("开发平台描述 "));
      wxPrintf(wxGetOsDescription());
      wxPrintf(wxT("the amount of free memory: "));
      long mem = wxGetFreeMemory().ToLong();
      wxPrintf(wxT("Memory: %ld "), mem);
      wxPrintf("主机名 ");
      wxPuts(wxGetUserName());
      wxPuts(wxGetFullHostName());
      wxDateTime now = wxDateTime::Now();
      wxString date1 = now.Format();
      wxString date2 = now.Format(wxT("%X"));
      wxString date3 = now.Format(wxT("%x"));
      wxPuts(date1);
      wxPuts(date2);
      wxPuts(date3);
    return 0;
    }
    2.#include <wx/file.h>
    #include<wx/string.h> 
    #include <wx/textfile.h>
    int main() 

    wxFile file1;
    file1.Create(wxT("stu.txt"), true);
    wxString str1,str2;
    wxPrintf("输入学生信息: ");
    str1="Mary  0001";
    str2="Mike  0002";
    file1.Write(str1);
    file1.Write(str2);
    wxTextFile file(wxT("stu.txt"));   
    file.Open(); 
    wxPrintf(wxT("行数: %d "), file.GetLineCount());
    wxPrintf(wxT("第一行: %s "), file.GetFirstLine().c_str());
    wxPrintf(wxT("最后一: %s "), file.GetLastLine().c_str());
    wxPuts(wxT("-------------------------------------")); 
    wxString s; 
    for ( s = file.GetFirstLine(); !file.Eof(); s = file.GetNextLine() ) 

    wxPuts(s); 
    wxPrintf(" ");

    file.Close();
    return 0; 
    }





  • 相关阅读:
    Codeforces Round #613 选讲
    Codeforces Round #612 选讲
    Codeforces917E
    一道题20
    LOJ#2244. 「NOI2014」起床困难综合症
    求欧拉回路
    *LOJ#2134. 「NOI2015」小园丁与老司机
    vim操作命令
    常见问题解决
    CentOS7下如何修改mysql的数据目录
  • 原文地址:https://www.cnblogs.com/zhangaihua/p/3718077.html
Copyright © 2011-2022 走看看