Shahin
Shahin

Reputation: 1316

Creating a GUI for a C library in Python vs. C++

I have an C library that I compiled into an executable which takes in two required args (input file path and one option). I would like to create a GUI for it that will allow the users to choose the file path and the option from a drop down menu(for simplicity). The executable looks like this:

my_executable --file_location /path/to/file --read_mode ASCII

I have previously used Python's built-in TkInter library. Would it be possible to use Python's TkInter to run my C executable? I am looking for something simple like this for now:

import tkinter
from tkinter import filedialog as fd

window = tkinter.Tk()
window.title("Welcome to my software")
file_location = fd.askopenfilename()

Or should I start looking into GTK+ or QT in C++?

Upvotes: 0

Views: 454

Answers (2)

Daniel Koch
Daniel Koch

Reputation: 610

You can use Python's tkinter to create a simple GUI tool for your command line tool.

It all depends the way that you plan to pack and distribute your program. One of the advantages of tkinter is that it comes by default.

Once you have chosen your GUI toolkit, use the subprocess module to attach your executable into the GUI program.

Upvotes: 1

Bryan Oakley
Bryan Oakley

Reputation: 386240

You don't need tkinter, you need tcl/tk - it was designed to be embedded in C programs. Tkinter itself embeds tcl/tk into python. You can avoid the overhead of embedding python and directly use tcl/tk.

For more information see How to embed Tcl in C applications on the Tcl'ers Wiki.

Upvotes: 1

Related Questions