3

I want to know, how to pop-up messages while processing/executing a program/function. I mean,

def Select():
    path=tkFileDialog.askopenfilename(filetypes=[("Image File",'.jpg')])
    im = skimage.io.imread(path, as_grey=True)
    im = skimage.img_as_ubyte(im)
    im /= 32
    g = skimage.feature.greycomatrix(im, [1], [0], levels=8, symmetric=False, normed=True)
    cont = skimage.feature.greycoprops(g, 'contrast')[0][0]
    cont_list1.append(cont)
    ene = skimage.feature.greycoprops(g, 'energy')[0][0]
    ene_list1.append(ene)
    homo = skimage.feature.greycoprops(g, 'homogeneity')[0][0]
    homo_list1.append(homo)
    cor = skimage.feature.greycoprops(g, 'correlation')[0][0]
    cor_list1.append(cor)
    dis = skimage.feature.greycoprops(g, 'dissimilarity')[0][0]
    dis_list1.append(dis)

I want to display a message stating Features are being calculated, and once it calculates, the message should disappear.

But I don't need the ok button.I don't know how to achieve this.The result of these calculations will be displayed in separate Entry box. Any suggestions are welcome.

6
  • effbot.org/tkinterbook/tkinter-standard-dialogs.htm <-- for a message box with buttons. Or effbot.org/tkinterbook/toplevel.htm for a pop-up window that you can customize (ie, no buttons, just a message, is destroyed automatically). Commented Apr 22, 2014 at 11:07
  • Do you want to know more about "creating message boxes/windows" or on "how to keep the GUI interactive while computing something?". The addition is so fast that it may not be visible. Commented Apr 22, 2014 at 12:43
  • @User addition was an example, but I want to know "how to keep the GUI interactive while computing something?" Commented Apr 22, 2014 at 15:21
  • Then I recomment reading this: stackoverflow.com/questions/21532523/… and reporting back, if it adjustments need to be made. Commented Apr 22, 2014 at 19:48
  • @User This is not what i meant, have you observed the processing thing in google? just like that I want to display the message like _ computing the sum_ arranging in order then the result should display. I hope you got my view! Commented Apr 23, 2014 at 5:16

1 Answer 1

4

Have a look at this. It opens a window with the text and when the computation is done the text is changed to the result.

>>> import time
>>> def processingPleaseWait(text, function):
    import Tkinter, time, threading
    window = Tkinter.Toplevel() # or tkinter.Tk()
    # code before computation starts
    label = Tkinter.Label(window, text = text)
    label.pack()
    done = []
    def call():
        result = function()
        done.append(result)

    thread = threading.Thread(target = call)
    thread.start() # start parallel computation
    while thread.is_alive():
        # code while computing
        window.update()
        time.sleep(0.001)
    # code when computation is done
    label['text'] = str(done)


>>> processingPleaseWait('waiting 2 seconds...', lambda: time.sleep(2))
Sign up to request clarification or add additional context in comments.

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.