Commit ef0b55dd by songxinkai

python/tkinter

parent e212b973
...@@ -3,6 +3,7 @@ project(hello) ...@@ -3,6 +3,7 @@ project(hello)
# headers # headers
set(PYTHON_INCLUDE_DIRS /home/songxinkai/anaconda3/include/python3.7m) set(PYTHON_INCLUDE_DIRS /home/songxinkai/anaconda3/include/python3.7m)
set(PYTHON_LIBRARIES /home/songxinkai/anaconda3/lib/libpython3.7m.so) set(PYTHON_LIBRARIES /home/songxinkai/anaconda3/lib/libpython3.7m.so)
include_directories(${PYTHON_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
# libraries # libraries
set(Boost_INCLUDE_DIRS /home/songxinkai/Boost_1.72.0/include) set(Boost_INCLUDE_DIRS /home/songxinkai/Boost_1.72.0/include)
set(Boost_LIBRARIES /home/songxinkai/Boost_1.72.0/lib/libboost_python37.so) set(Boost_LIBRARIES /home/songxinkai/Boost_1.72.0/lib/libboost_python37.so)
...@@ -17,7 +18,11 @@ add_library(_pure_virtual_inherit_example SHARED ${pure_virtual_inherit_example_ ...@@ -17,7 +18,11 @@ add_library(_pure_virtual_inherit_example SHARED ${pure_virtual_inherit_example_
set_target_properties(_function_example PROPERTIES PREFIX "" OUTPUT_NAME "_function_example") set_target_properties(_function_example PROPERTIES PREFIX "" OUTPUT_NAME "_function_example")
set_target_properties(_class_example PROPERTIES PREFIX "" OUTPUT_NAME "_class_example") set_target_properties(_class_example PROPERTIES PREFIX "" OUTPUT_NAME "_class_example")
set_target_properties(_pure_virtual_inherit_example PROPERTIES PREFIX "" OUTPUT_NAME "_pure_virtual_inherit_example") set_target_properties(_pure_virtual_inherit_example PROPERTIES PREFIX "" OUTPUT_NAME "_pure_virtual_inherit_example")
include_directories(${PYTHON_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
target_link_libraries(_class_example ${PYTHON_LIBRARIES} ${Boost_LIBRARIES}) target_link_libraries(_class_example ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
target_link_libraries(_function_example ${PYTHON_LIBRARIES} ${Boost_LIBRARIES}) target_link_libraries(_function_example ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
target_link_libraries(_pure_virtual_inherit_example ${PYTHON_LIBRARIES} ${Boost_LIBRARIES}) target_link_libraries(_pure_virtual_inherit_example ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
set(__linkname "${PROJECT_SOURCE_DIR}/_function_example.so")
add_custom_command(TARGET _function_example POST_BUILD
COMMAND ln -sf $<TARGET_LINKER_FILE:_function_example> "${__linkname}"
COMMENT "==")
/home/songxinkai/mytests/boost/python/build/_function_example.so
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
# The set of languages for which implicit dependencies are needed:
set(CMAKE_DEPENDS_LANGUAGES
"CXX"
)
# The set of files for implicit dependencies of each language:
set(CMAKE_DEPENDS_CHECK_CXX
"/home/songxinkai/mytests/boost/python/build/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp" "/home/songxinkai/mytests/boost/python/build/CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.o"
"/home/songxinkai/mytests/boost/python/hello.cpp" "/home/songxinkai/mytests/boost/python/build/CMakeFiles/pyhello.dir/hello.cpp.o"
)
set(CMAKE_CXX_COMPILER_ID "GNU")
# Preprocessor definitions for this target.
set(CMAKE_TARGET_DEFINITIONS_CXX
"pyhello_EXPORTS"
)
# The include file search paths:
set(CMAKE_CXX_TARGET_INCLUDE_PATH
"/home/songxinkai/anaconda3/include/python3.7m"
"/home/songxinkai/Boost_1.72.0/include"
)
# Targets to which this target links.
set(CMAKE_TARGET_LINKED_INFO_FILES
)
# Fortran module output directory.
set(CMAKE_Fortran_TARGET_MODULE_DIR "")
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.14
# Delete rule output on recipe failure.
.DELETE_ON_ERROR:
#=============================================================================
# Special targets provided by cmake.
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =
.SUFFIXES: .hpux_make_needs_suffix_list
# Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
cmake_force:
.PHONY : cmake_force
#=============================================================================
# Set environment variables for the build.
# The shell in which to execute make rules.
SHELL = /bin/sh
# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake3
# The command to remove a file.
RM = /usr/bin/cmake3 -E remove -f
# Escaping for special characters.
EQUALS = =
# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /home/songxinkai/mytests/boost/python
# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /home/songxinkai/mytests/boost/python/build
# Include any dependencies generated for this target.
include CMakeFiles/pyhello.dir/depend.make
# Include the progress variables for this target.
include CMakeFiles/pyhello.dir/progress.make
# Include the compile flags for this target's objects.
include CMakeFiles/pyhello.dir/flags.make
CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.o: CMakeFiles/pyhello.dir/flags.make
CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.o: CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/songxinkai/mytests/boost/python/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building CXX object CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.o"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.o -c /home/songxinkai/mytests/boost/python/build/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp
CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.i: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.i"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/songxinkai/mytests/boost/python/build/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp > CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.i
CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.s: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.s"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/songxinkai/mytests/boost/python/build/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp -o CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.s
CMakeFiles/pyhello.dir/hello.cpp.o: CMakeFiles/pyhello.dir/flags.make
CMakeFiles/pyhello.dir/hello.cpp.o: ../hello.cpp
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --progress-dir=/home/songxinkai/mytests/boost/python/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Building CXX object CMakeFiles/pyhello.dir/hello.cpp.o"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -o CMakeFiles/pyhello.dir/hello.cpp.o -c /home/songxinkai/mytests/boost/python/hello.cpp
CMakeFiles/pyhello.dir/hello.cpp.i: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Preprocessing CXX source to CMakeFiles/pyhello.dir/hello.cpp.i"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -E /home/songxinkai/mytests/boost/python/hello.cpp > CMakeFiles/pyhello.dir/hello.cpp.i
CMakeFiles/pyhello.dir/hello.cpp.s: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/pyhello.dir/hello.cpp.s"
/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S /home/songxinkai/mytests/boost/python/hello.cpp -o CMakeFiles/pyhello.dir/hello.cpp.s
# Object files for target pyhello
pyhello_OBJECTS = \
"CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.o" \
"CMakeFiles/pyhello.dir/hello.cpp.o"
# External object files for target pyhello
pyhello_EXTERNAL_OBJECTS =
_hello.so: CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.o
_hello.so: CMakeFiles/pyhello.dir/hello.cpp.o
_hello.so: CMakeFiles/pyhello.dir/build.make
_hello.so: /home/songxinkai/anaconda3/lib/libpython3.7m.so
_hello.so: /home/songxinkai/Boost_1.72.0/lib/libboost_python37.so
_hello.so: CMakeFiles/pyhello.dir/link.txt
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir=/home/songxinkai/mytests/boost/python/build/CMakeFiles --progress-num=$(CMAKE_PROGRESS_3) "Linking CXX shared library _hello.so"
$(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/pyhello.dir/link.txt --verbose=$(VERBOSE)
# Rule to build all files generated by this target.
CMakeFiles/pyhello.dir/build: _hello.so
.PHONY : CMakeFiles/pyhello.dir/build
CMakeFiles/pyhello.dir/clean:
$(CMAKE_COMMAND) -P CMakeFiles/pyhello.dir/cmake_clean.cmake
.PHONY : CMakeFiles/pyhello.dir/clean
CMakeFiles/pyhello.dir/depend:
cd /home/songxinkai/mytests/boost/python/build && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" /home/songxinkai/mytests/boost/python /home/songxinkai/mytests/boost/python /home/songxinkai/mytests/boost/python/build /home/songxinkai/mytests/boost/python/build /home/songxinkai/mytests/boost/python/build/CMakeFiles/pyhello.dir/DependInfo.cmake --color=$(COLOR)
.PHONY : CMakeFiles/pyhello.dir/depend
file(REMOVE_RECURSE
"CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.o"
"CMakeFiles/pyhello.dir/hello.cpp.o"
"_hello.pdb"
"_hello.so"
)
# Per-language clean rules from dependency scanning.
foreach(lang CXX)
include(CMakeFiles/pyhello.dir/cmake_clean_${lang}.cmake OPTIONAL)
endforeach()
This source diff could not be displayed because it is too large. You can view the blob instead.
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.14
# compile CXX with /usr/bin/c++
CXX_FLAGS = -fPIC
CXX_DEFINES = -Dpyhello_EXPORTS
CXX_INCLUDES = -I/home/songxinkai/anaconda3/include/python3.7m -I/home/songxinkai/Boost_1.72.0/include
/usr/bin/c++ -fPIC -shared -Wl,-soname,_hello.so -o _hello.so CMakeFiles/pyhello.dir/CMakeFiles/3.14.6/CompilerIdCXX/CMakeCXXCompilerId.cpp.o CMakeFiles/pyhello.dir/hello.cpp.o -Wl,-rpath,/home/songxinkai/anaconda3/lib:/home/songxinkai/Boost_1.72.0/lib /home/songxinkai/anaconda3/lib/libpython3.7m.so /home/songxinkai/Boost_1.72.0/lib/libboost_python37.so
CMAKE_PROGRESS_1 = 1
CMAKE_PROGRESS_2 = 2
CMAKE_PROGRESS_3 = 3
#include <boost/python.hpp>
using namespace boost::python;
const char* Greet()
{
return "hello, world";
}
int Add(int i, int j) {
return i+j;
}
BOOST_PYTHON_MODULE(_hello) {
scope().attr("__doc__") = "boost.python example plugin";
def("greet", Greet);
def("add", &Add, "A function which adds two numbers");
}
#!/home/songxinkai/anaconda3/bin/python
import sys
if sys.version_info.major == 2:
import Tkinter as tk # python2
else:
import tkinter as tk # python3
root = tk.Tk()
li = ['C','python','php','html','SQL','java']
movie = ['CSS','jQuery','Bootstrap']
listb = tk.Listbox(root) # 创建两个列表组件
listb2 = tk.Listbox(root)
for item in li: # 第一个小部件插入数据
listb.insert(0,item)
for item in movie: # 第二个小部件插入数据
listb2.insert(0,item)
listb.pack() # 将小部件放置到主窗口中
listb2.pack()
root.mainloop()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment