Running into problems using a simple gui multithreaded application. FRUSTRATED AND NEED HELP !
-
Will upload it very soon. Just got back from Prague :)
-
Sorry for the delay, as I promised I am uploading the code.
Gui.py
@
import Tkinter as Tk
from PIL import Image, ImageTk
import tkMessageBox as tkMsgBoxdef version_click(shr_objs):
print "version_click is called"
print 'this is my global segment:', shr_objs
tkMsgBox.showinfo('say hello', 'hello world')def setupUi(MainDlg, shr_objs = None):
#setting up all the images and other stuff
raw_img_good = Image.open('images/good.jpg')
MainDlg.img_good = ImageTk.PhotoImage(raw_img_good)#setting up all the widgets, and if needed, putting pictures to them
MainDlg.bg = Tk.Label(MainDlg)
MainDlg.bg.pack(expand=Tk.YES, fill=Tk.BOTH)
MainDlg.bg['image'] = MainDlg.img_bgMainDlg.btnVer = Tk.Button(MainDlg, text='start', command = (lambda: start_click(shr_objs) ) )
widgets can be arranged using three main geometry managers: pack, grid and place, for this example I chosed pack (the recommended and simplest)
MainDlg.btnVer.pack()
MainDlg.btnVer.place(x=620, y=650, width=100, height=40)
if name == 'main':
MainDlg = Tk.Tk()
setupUi(MainDlg, {'action': 'init'})MainDlg.mainloop() # for a gui app only enable this, or just run with -i option (interactive mode)
@
main.py
@
#!/usr/bin/pythonimport threading
import sys, time
import Gui
import Tkinter as Tkimport AA_Tester
shared queue object
mqGui2AA = mp.Queue()
global vars dictionary, I can choose any IPC I want here ..
shared_objects = {'action': 'init', 'mqGui2AA':mqGui2AA}
#shared_objects = {'action': 'init'}creating main gui form
MainDlg = Tk.Tk()
Gui.setupUi(MainDlg, shr_objs = shared_objects)shared_objects['MainDlg'] = MainDlg
AA = AA_Tester.MainAA(shared_objects)
MainDlg.mainloop()
@partial file from AA_Tester.py
@
MainDlg = shr_objs['MainDlg']
MainDlg.bg['image'] = MainDlg.img_good
@