Hi there,

I have a simple piece of software written up that I'm running off the terminal's command line interface. Very recently, it was asked of me to create a GUI for it. So I basically made one to reflect how I would use the software but I actually haven't "connected" or "associated" the GUI with my software. There are plenty of examples on how to create this and that using Tkinter but I'm finding it very difficult to find information relating to actually getting an existing/working piece of software to mesh with the GUI.

Any ideas, tips or suggestions?

What problems are you having? What information do you need to find?

Basically, I've already got code with a whole bunch of functions. For example I've got something like:

monteCarloSim(trials)

Thus my GUI has a text entry portion where I'd put in the number of trials to run and then hit the 'Run' button to actually perform the simulations. I'm quite embarrassed to say that I don't know how to achieve this.

Additionally, I've got a function that saves a bunch of arrays to a .csv file. The function itself explicitly creates, writes to and sets the filename. It would be nice if I could just access the function from within the GUI, yet choose the filename and directory to save the file.

These are things I wish to achieve and due to my severe inexperience with Python, am failing to do.

When someone presses the "Run" button, the callback would execute the code from the text-based program, either calling a function or class. You would of course have to import the other program as well. See the button widget here http://effbot.org/tkinterbook/ for info on callbacks.

yet choose the filename and directory to save the file.

Google for Tkinter File Dialog. It is a built-in function to do that.

Edited 6 Years Ago by woooee: n/a

Oh I've got the file dialog working. It's just that I don't know how to tell the function to adhere to the file created using the file dialog :)

When someone presses the "Run" button, the callback would execute the code from the text-based program, either calling a function or class. You would of course have to import the other program as well. See the button widget here http://effbot.org/tkinterbook/ for info on callbacks. Google for Tkinter File Dialog. It is a built-in function to do that.

Apologies for the belated reply.

Basically, I know how to create the file dialog now but the difficult thing is that Python's CSV writer will automatically generate the file(name) for you and I've been hard-coding the directory (well it's based on the root folder where my code is). All I want to do is specify the name and directory and let the function write to the file/place I specified.

This article has been dead for over six months. Start a new discussion instead.