GithubHelp home page GithubHelp logo

seisgo / qtpythonembedding Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 0.0 15 KB

Simple demonstrations about Python embedding in C++ project, implemented with Qt

License: MIT License

C++ 86.93% QMake 9.45% Python 3.61%
cpp python embedding qmake

qtpythonembedding's Introduction

QtPythonEmbedding

Simple demonstrations about Python embedding in C++ project, implemented with Qt

It includes five different implementations of embedding:

  • Execuate simple string
  • Execuate simple file
  • Execuate certain function by set global path
  • Execuate certain function by module importing
  • Call embedded python interpreter

Test of simple python script file

  • The test python script file is runtest.py.
  • This implementation is stored in master branch.

NOTE: For rerunning, abosulte path of python script file should be modified.

Test of complex python project

  • To run some complex python project, I have tested a python project for video and image super-resolution processing, which is named as VideoSuperResolution.
  • I have made some modifications in main.cpp to execute main function in python project.
    • For complex python project, directories of imported non-Python-standard-library modules and sefl-defined modules should be added into search path.
    • What's more, if there is relative directory used in python project, we should make sure python script executing in its real path, not that of exectubale file in Qt project. Some pieces of codes can be inserted at the beginning of python main functoin, shown as:
      # 'import os' is needed
      script_path = os.path.realpath(__file__)
      script_dir = os.path.dirname(script_path)
      os.chdir(script_dir)

NOTE:

  • The implementation of complex python project is just a demonstration, to show the process and some tips about this type of implementation.
  • Since I have only uploaded main python script (named as run.py) of VideoSuperResolution project, and it depends on more relative python scripts and configuration files, this implementation can't be rerun successfully.
  • This implementation of running complex python project is forked in a branch repository, named as complexPythonProject, to avoid the rerunning failure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.