0

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++?

3
  • Sure, you can use Python to run an executable. Commented Mar 16, 2020 at 18:40
  • 1
    What the executable was written in isn't relevant, because you are just writing a wrapper that executes it, rather than linking to the original library. Commented Mar 16, 2020 at 19:08
  • 1
    The cost of starting the wrapper and using the GUI is, presumably, negligible compared to the work the executable itself does. Commented Mar 16, 2020 at 19:08

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.