Changeset 4084
- Timestamp:
- 06/02/07 12:30:02 (6 years ago)
- Location:
- experimental/components/image_display/trunk/image_display
- Files:
-
- 2 modified
-
WorkModule.py (modified) (2 diffs)
-
image_display.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
experimental/components/image_display/trunk/image_display/WorkModule.py
r4073 r4084 52 52 self.process_thread = threading.Thread(target=self.Process) 53 53 self.process_thread.start() 54 55 self.toggle = 1 54 56 55 57 … … 74 76 75 77 while len(self.data_queue) > 0: 76 #get data from the buffer: 78 #get data from the buffer: 77 79 self.data_queue_lock.acquire() 78 80 new_data = self.data_queue.pop() 79 81 self.data_queue_lock.release() 80 82 83 # my_file = open("/sdr/tmp.jpg", 'w') 84 # my_file.write(new_data) 85 # my_file.close() 86 81 87 #rescale the image to the standardized size 82 self.image.Rescale(self.width, self.height) 88 #self.image.Rescale(self.width, self.height) 89 90 #create new image out of the incomming bytes 91 #self.image.SetData(new_data) 83 92 84 #create new image out of the incomming bytes 85 self.image.SetData(new_data) 93 self.set_image() 94 if self.toggle == 1: 95 self.toggle = 0 96 else: 97 self.toggle = 1 86 98 87 self.image_display_ref.prnt_orb.prnt_frame.refresh(self.image) 88 99 89 100 # reset the signal event variable 90 101 self.data_signal.clear() 91 92 102 103 def set_image(self): 104 locker = wx.MutexGuiLocker() #should refresh the gui when leaving the scope of this function 105 #should i start this function as a thread for this to work? 106 if self.toggle == 1: 107 tmp_filename = '/sdr/wxpython_cover_2.jpg' 108 else: 109 tmp_filename = '/sdr/wxpython_cover.jpg' 110 111 self.image = wx.Image(tmp_filename, wx.BITMAP_TYPE_JPEG) # load a jpeg from file 112 self.image_display_ref.prnt_orb.prnt_frame.refresh(self.image) 113 114 -
experimental/components/image_display/trunk/image_display/image_display.py
r4073 r4084 108 108 class ORB_Init: 109 109 """Takes care of initializing the ORB and bind the object""" 110 110 111 # remove __init__ for threading approach. thread cannot take input args? 111 112 def __init__(self, prnt_frame, uuid, label): 112 self.prnt_frame = prnt_frame 113 114 print uuid 115 # for __init__: 116 #self.prnt_frame = prnt_frame 117 # for no __init__: 118 self.prnt_frame = app.frame 113 119 114 120 # initialize the orb … … 131 137 132 138 self.orb.run() 133 139 140 def ORB_Init_fun(): 141 orb = ORB_Init(app, uuid, label) 142 134 143 135 144 #------------------------------------------------------------------- … … 148 157 self.frame_size = temp_bmp.GetWidth(), temp_bmp.GetHeight() 149 158 wx.Frame.__init__(self, parent, id, self.title, wx.DefaultPosition, self.frame_size) 150 151 152 153 159 154 160 self.bmp = wx.StaticBitmap(parent=self, bitmap = temp_bmp) … … 160 166 161 167 def OnStartBtnButton(self, event): 162 # locker = wx.MutexGuiLocker()163 168 orb = ORB_Init(self,uuid, label) 164 169 event.Skip() … … 166 171 167 172 def refresh(self, image): 168 #locker = wx.MutexGuiLocker()169 173 temp = image.ConvertToBitmap() 170 174 size = temp.GetWidth(), temp.GetHeight() … … 177 181 def OnInit(self): 178 182 image = wx.Image("/sdr/wxpython_cover.jpg", wx.BITMAP_TYPE_JPEG) 183 179 184 self.frame = Frame(image) 180 185 self.frame.Show() … … 184 189 185 190 186 class AppThread(threading.Thread): 187 def run(self): 188 app = App() 189 app.MainLoop() 190 191 192 class ORBThread(threading.Thread): 193 def run(self): 194 orb = ORB_Init(uuid, label) 195 196 191 class my_threads: 192 def __init__(self): 193 194 ## for non-global app: 195 #self.app = App() 196 #self.app_thread = threading.Thread(target=self.app.MainLoop) 197 198 #for global app: 199 self.app_thread = threading.Thread(target=app.MainLoop) 200 201 self.app_thread.start() 202 203 ## with arguments: 204 #self.orb_thread = threading.Thread(target=ORB_Init(app.frame, uuid, label)) 205 #without arguments: 206 self.orb_thread = threading.Thread(target=ORB_Init_fun) 207 208 self.orb_thread.start() 209 210 print "\nthe orb thread has been started\n" 211 212 197 213 #------------------------------------------------------------------- 198 214 # Code run when this file is executed … … 207 223 print "Identifier - " + uuid + " Label - " + label 208 224 209 i_am_threading = False225 i_am_threading = True 210 226 211 227 if i_am_threading: 212 print "starting the App thread\n" 213 mainAppThread = AppThread() 214 mainAppThread.start() 215 216 print "starting the ORB thread\n" 217 mainORBThread = ORBThread() 218 mainORBThread.start() 228 #for global app: 229 app = App() 230 231 threads_running = my_threads() 219 232 220 233 else: