Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question

IES-VE Python API / Use navigator or gui to enter data

asked 2020-05-15 11:05:28 -0600

We're working on a script and want to accept a single-line of text from a user. For example.. proj_name = [insert code] # user to enter project name

Ideally, I'd like this to be in a new navigator just for the script, but a mini gui (using tkinter) could also work.

There are a bunch of example scripts that install with VE that are helpful, but none I've found show how to take text from a user prompt. I'm hoping somebody here can provide an example of how to do this from within VE.

edit retag flag offensive close merge delete


I have been looking into this and cannot find anything useful. There is an option to import win32gui but I can't find a away to create an input box for that.

I tried using readline and that also failed :(. Try suggesting this a a feature to ies ;)

gazzat5's avatar gazzat5  ( 2022-04-08 11:00:17 -0600 )edit

I found a way to do it using the tkinter libary (look for example script) but my answer post here hasn't appeared yet.

gazzat5's avatar gazzat5  ( 2022-04-11 02:27:02 -0600 )edit

I'll keep an eye out for your answer. Thanks for replying back to this though. This post was a while ago and we've done quite a bit of Python development since this question.. We actually removed the "project name" from our script, as it seemed silly to use Python to automate something that requires a manual user input. However, if you did want to do something like this, I'd recommend writing the entered value to a file (temp.txt or something) so that you can read it as the default value in the tkinter dialogue.. I haven't used win32gui but tkinter would certainly do what was needed here.

Greg Collins's avatar Greg Collins  ( 2022-04-11 10:49:51 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2022-04-12 10:43:51 -0600

gazzat5's avatar

On further looking i have found an example code that generates an inputbox. You can use tkinter library to do this. The code example is as below:

import tkinter as tk

def generate_window(project):

    class Window(tk.Frame):
        def __init__(self, master=None):
            tk.Frame.__init__(self, master)

            self.project = project
            self.project_folder = project.path
            self.text_entry = ''
            self.master = master

        # Creation of init_window
        def init_window(self):

            # changing the title of our master widget
            self.master.title("Input text")
            self.master.columnconfigure(0, weight=1)
            self.master.rowconfigure(0, weight=1)

            tk.Label(self, text=' ').grid(row=7, sticky=tk.W)

            tk.Label(self, text='Text will be returned in the console').grid(row=8, sticky=tk.W)
            tk.Label(self, text='Enter the text below:').grid(row=9, sticky=tk.W)

            self.text_entry_box = tk.Entry(self)
            self.text_entry_box.insert(0, self.text_entry)
            self.text_entry_box.grid(row=10, sticky='ew')
            tk.Label(self, text=' ').grid(row=11, sticky=tk.W)

            # creating a button instance
            tk.Button(self, text="Return text", command=self.return_text).grid(row=12, sticky=tk.W)

            self.columnconfigure(0, weight=1)
            self.grid(row=0, column=0, sticky='nsew')

        def return_text(self):
            self.text_entry = self.text_entry_box.get()
            print('Text entered = ' + self.text_entry)

    root = tk.Tk()
    app = Window(root)

if __name__ == '__main__':
    project = iesve.VEProject.get_current_project()

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer


Question Tools



Asked: 2020-05-15 11:05:28 -0600

Seen: 471 times

Last updated: Apr 13 '22