I'm planning to make an online program, actually it would only be a login system with GUI and a chat window after login. The client program would recieve some data from the server (like names, ages, etc). I don't want to use C++ for sockets, I want to use Python instead. My question is: how do I create a program which could use Python scripts and get data from them?

Recommended Answers

All 3 Replies

My first recommendation would be to use Python exclusively. Python is a fully-featured programming language with thousands of libraries for doing just about everything. There are 3 principle GUI toolkits for Python. These are PyQt, wxPython, and Tkinter. PyQt (my preference) and wxPython are very powerful and higly supported. Tkinter is probably easier for extremely basic UI programs, but it is old, ugly, and under-documented. Of course, Python is much slower than c++ and lacks the natural obfuscation that comes with a compiled language.

If you really must write the bulk of the program in C++, there are many options for interfacing to Python. First, you can use the Python/C API that's built into Python. I wouldn't recommend this. The built in API has a very steep learning curve. However, there are many wrappers for the API that aim to improve instant usability. These include SWiG, Pyrex/Cython, Ctypes, and many others. Finally, the Boost library provides a full interoperability package for C++ and Python.

If you want to begin exploring some options for yourself, try googling "c++ python"

Okay, I wasn't really posting what I should had. I'd like to create an online game (not MMORPG though), which would be just a login screen first. This Python-C++ stuff is something I saw Battlefield: Heroes is using, I'm not sure about how does it do it, but with the client program, comes some .py files which if are changed, the client program reacts at next launch (like you can change scoring and other stuff).

If all you need to do from c++ is extract text information from a python file, any sort of file i/o will work:

google: fstream

If you need to check how recently a file was modified, you simply need to use C system calls:

google: lstat

If you are trying to interface running python code to running c++ code, read my previous post.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.