[tuxdroid-svn] r854 - in software/gadgets/tux_controller/trunk: . TuxController/Scripts/Python/GUI/
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2008-01-18 10:47:47
|
Author: Paul_R Date: 2008-01-18 11:47:27 +0100 (Fri, 18 Jan 2008) New Revision: 854 Modified: software/gadgets/tux_controller/trunk/TuxController.tgf software/gadgets/tux_controller/trunk/TuxController/Scripts/Python/GUI/widget/other.pyp Log: * Fixed the desynchronization bug. Now I refresh all the picture on a thread. * Fixed some minors bugs... Modified: software/gadgets/tux_controller/trunk/TuxController/Scripts/Python/GUI/widget/other.pyp =================================================================== --- software/gadgets/tux_controller/trunk/TuxController/Scripts/Python/GUI/widget/other.pyp 2008-01-17 09:52:57 UTC (rev 853) +++ software/gadgets/tux_controller/trunk/TuxController/Scripts/Python/GUI/widget/other.pyp 2008-01-18 10:47:27 UTC (rev 854) @@ -5,6 +5,7 @@ print sys.exc_info() __led_toggled_by_event = False +__plugged = False class Window(SimpleGladeApp): @@ -23,7 +24,10 @@ def new(self): global __led_toggled_by_event + global __plugged + __led_toggled_by_event = False + __plugged = False _me.set_param('generalStop', False) self.get_widget("window1").set_title(_me.string('name_to_read')) self.create_tooltips() @@ -101,7 +105,6 @@ tux.event.on_mouth_open = self.on_mouth_open tux.event.on_mouth_close = self.on_mouth_close tux.event.on_spin_stop = self.on_spin_stop - tux.event.on_power_unplugged = self.on_unplugged tux.event.on_remote_bt[K_UP] = self.on_key_up #eyes tux.event.on_remote_bt[K_DOWN] = self.on_key_down #wings @@ -368,16 +371,16 @@ self.__eyes_active = False self.__eyes_stop = True self.__eyes_infinite = False - self.get_widget('imgEyesRun').set_from_pixbuf(self.run) - tux.cmd.eyes_open() + thread.start_new_thread(self.refresh_picture, ('imgEyesRun', self.run)) + tux.cmd.eyes_on(1) if self.__mouth_active: tux.cmd.mouth_off() self.__mouth_active = False self.__mouth_stop = True self.__mouth_infinite = False - self.get_widget('imgMouthRun').set_from_pixbuf(self.run) - tux.cmd.mouth_close() + thread.start_new_thread(self.refresh_picture, ('imgMouthRun', self.run)) + tux.cmd.mouth_on(1) if self.__wings_active: @@ -385,15 +388,15 @@ self.__wings_active = False self.__wings_stop = True self.__wings_infinite = False - self.get_widget('imgWingsRun').set_from_pixbuf(self.run) - self.get_widget('imgWings').set_from_pixbuf(self.wings_down) + thread.start_new_thread(self.refresh_picture, ('imgWingsRun', self.run)) + thread.start_new_thread(self.refresh_picture, ('imgWings', self.wings_down)) tux.cmd.raw(0x3A, 0, 0, 0) if self.__spin_active: self.__spin_active = False self.__spin_infinite = False - self.get_widget('imgSpinRun').set_from_pixbuf(self.run) - self.get_widget('imgSpin').set_from_pixbuf(self.spin_off) + thread.start_new_thread(self.refresh_picture, ('imgSpinRun', self.run)) + thread.start_new_thread(self.refresh_picture, ('imgSpin', self.spin_off)) tux.cmd.spinl_off() tux.cmd.spinr_off() @@ -411,7 +414,8 @@ def on_btnEyesOpen_released(self, widget, *args): - self.get_widget('imgLed').set_from_pixbuf(self.led_on) + thread.start_new_thread(self.refresh_picture, ('imgLed', self.led_on)) + #self.get_widget('imgLed').set_from_pixbuf(self.led_on) tux.cmd.eyes_open() def on_btnEyesClose_released(self, widget, *args): @@ -423,11 +427,11 @@ self.__mouth_active = False self.__mouth_stop = True self.__mouth_infinite = False - self.get_widget('imgMouthRun').set_from_pixbuf(self.run) + thread.start_new_thread(self.refresh_picture, ('imgMouthRun', self.run)) if self.__eyes_active == False: self.__eyes_active = True - self.get_widget('imgEyesRun').set_from_pixbuf(self.stop) + thread.start_new_thread(self.refresh_picture, ('imgEyesRun', self.stop)) value = self.get_widget('spinEyes').get_value() value = value * 2 if value == 0: @@ -435,11 +439,11 @@ tux.cmd.eyes_on_free(int(value)) tux.sys.looped_function(self.__update_eyes_buttons, 0.2) else: - tux.cmd.eyes_off() + tux.cmd.eyes_on(1) self.__eyes_active = False self.__eyes_stop = True self.__eyes_infinite = False - self.get_widget('imgEyesRun').set_from_pixbuf(self.run) + thread.start_new_thread(self.refresh_picture, ('imgEyesRun', self.run)) def on_btnMouthClose_released(self, widget, *args): @@ -454,11 +458,11 @@ self.__eyes_active = False self.__eyes_stop = True self.__eyes_infinite = False - self.get_widget('imgEyesRun').set_from_pixbuf(self.run) + thread.start_new_thread(self.refresh_picture, ('imgEyesRun', self.run)) if self.__mouth_active == False: self.__mouth_active = True - self.get_widget('imgMouthRun').set_from_pixbuf(self.stop) + thread.start_new_thread(self.refresh_picture, ('imgMouthRun', self.stop)) value = self.get_widget('spinMouth').get_value() value = value * 2 if value == 0: @@ -466,24 +470,24 @@ tux.cmd.mouth_on_free(int(value)) tux.sys.looped_function(self.__update_mouth_buttons, 0.2) else: - tux.cmd.mouth_off() + tux.cmd.mouth_on(1) self.__mouth_active = False self.__mouth_stop = True self.__mouth_infinite = False - self.get_widget('imgMouthRun').set_from_pixbuf(self.run) + thread.start_new_thread(self.refresh_picture, ('imgMouthRun', self.run)) def on_btnWingsUp_released(self, widget, *args): - self.get_widget('imgWings').set_from_file(self.path+'wings_up.png') + thread.start_new_thread(self.refresh_picture, ('imgWings', self.wings_up)) tux.cmd.raw(0x39, 0, 0, 0) def on_btnWingsDown_released(self, widget, *args): - self.get_widget('imgWings').set_from_file(self.path+'wings_down.png') + thread.start_new_thread(self.refresh_picture, ('imgWings', self.wings_down)) tux.cmd.raw(0x3A, 0, 0, 0) def on_btnWingsRun_clicked(self, widget, *args): if self.__wings_active == False: self.__wings_active = True - self.get_widget('imgWingsRun').set_from_pixbuf(self.stop) + thread.start_new_thread(self.refresh_picture, ('imgWingsRun', self.stop)) value = self.get_widget('spinWings').get_value() value = value * 2 if value == 0: @@ -492,18 +496,22 @@ tux.cmd.wings_on_free(int(value), int(freq)) tux.sys.looped_function(self.__update_wings_buttons, 0.2) else: - tux.cmd.wings_off() + tux.cmd.wings_on(1) self.__wings_active = False self.__wings_stop = True self.__wings_infinite = False - self.get_widget('imgWingsRun').set_from_pixbuf(self.run) + thread.start_new_thread(self.refresh_picture, ('imgWingsRun', self.run)) + #tux.sys.wait(0.2) + thread.start_new_thread(self.refresh_picture, ('imgWings', self.wings_down)) + tux.cmd.raw(0x3A, 0, 0, 0) + def on_btnSpinLeft_pressed(self, widget, *args): if tux.status.power_plug(): - self.get_widget('imgSpin').set_from_pixbuf(self.spin_transfo) + thread.start_new_thread(self.refresh_picture, ('imgSpin', self.spin_transfo)) thread.start_new_thread(self.__wait2, ()) return - self.get_widget('imgSpin').set_from_pixbuf(self.spin_left) + thread.start_new_thread(self.refresh_picture, ('imgSpin', self.spin_left)) tux.cmd.spinl_on_free(0) def on_btnSpinLeft_released(self, widget, *args): @@ -511,10 +519,10 @@ def on_btnSpinRight_pressed(self, widget, *args): if tux.status.power_plug(): - self.get_widget('imgSpin').set_from_pixbuf(self.spin_transfo) + thread.start_new_thread(self.refresh_picture, ('imgSpin', self.spin_transfo)) thread.start_new_thread(self.__wait2, ()) return - self.get_widget('imgSpin').set_from_file(self.path+'spin_right.png') + thread.start_new_thread(self.refresh_picture, ('imgSpin', self.spin_right)) tux.cmd.spinr_on_free(0) def on_btnSpinRight_released(self, widget, *args): @@ -522,7 +530,7 @@ def on_btnSpinRun_clicked(self, widget, *args): if tux.status.power_plug(): - self.get_widget('imgSpin').set_from_pixbuf(self.spin_transfo) + thread.start_new_thread(self.refresh_picture, ('imgSpin', self.spin_transfo)) thread.start_new_thread(self.__wait2, ()) return @@ -536,11 +544,11 @@ freq = self.get_widget('slideSpin').get_value() if self.get_widget('radSpinDirLeft').get_active(): tux.cmd.spinl_on_free(int(value), int(freq)) - self.get_widget('imgSpin').set_from_pixbuf(self.spin_left) + thread.start_new_thread(self.refresh_picture, ('imgSpin', self.spin_left)) else: tux.cmd.spinr_on_free(int(value), int(freq)) - self.get_widget('imgSpin').set_from_pixbuf(self.spin_right) - self.get_widget('imgSpinRun').set_from_pixbuf(self.stop) + thread.start_new_thread(self.refresh_picture, ('imgSpin', self.spin_right)) + thread.start_new_thread(self.refresh_picture, ('imgSpinRun', self.stop)) else: tux.cmd.spinl_off() @@ -548,7 +556,7 @@ self.__spin_active = False self.__spin_stop = True self.__spin_infinite = False - self.get_widget('imgSpinRun').set_from_pixbuf(self.run) + thread.start_new_thread(self.refresh_picture, ('imgSpinRun', self.run)) ## chkLEDRight @@ -566,10 +574,10 @@ return if widget.get_active(): tux.cmd.ledr_on() - self.get_widget('imgLed').set_from_pixbuf(self.led_on) + thread.start_new_thread(self.refresh_picture, ('imgLed', self.led_on)) else: tux.cmd.ledr_off() - self.get_widget('imgLed').set_from_pixbuf(self.led_off) + thread.start_new_thread(self.refresh_picture, ('imgLed', self.led_off)) ## chkLEDLeft def on_chkLEDLeft_toggled(self, widget, *args): @@ -579,10 +587,10 @@ if widget.get_active(): tux.cmd.ledl_on() - self.get_widget('imgLed').set_from_pixbuf(self.led_on) + thread.start_new_thread(self.refresh_picture, ('imgLed', self.led_on)) else: tux.cmd.ledl_off() - self.get_widget('imgLed').set_from_pixbuf(self.led_off) + thread.start_new_thread(self.refresh_picture, ('imgLed', self.led_off)) def on_btnTTS_clicked(self, widget, *args): @@ -609,7 +617,7 @@ global __led_toggled_by_event __led_toggled_by_event = True self.get_widget('chkLEDLeft').set_active(True) - self.get_widget('imgLed').set_from_pixbuf(self.led_on) + thread.start_new_thread(self.refresh_picture, ('imgLed', self.led_on)) __led_toggled_by_event = False @@ -617,7 +625,7 @@ global __led_toggled_by_event __led_toggled_by_event = True self.get_widget('chkLEDLeft').set_active(False) - self.get_widget('imgLed').set_from_pixbuf(self.led_off) + thread.start_new_thread(self.refresh_picture, ('imgLed', self.led_off)) __led_toggled_by_event = False @@ -625,7 +633,7 @@ global __led_toggled_by_event __led_toggled_by_event = True self.get_widget('chkLEDRight').set_active(True) - self.get_widget('imgLed').set_from_pixbuf(self.led_on) + thread.start_new_thread(self.refresh_picture, ('imgLed', self.led_on)) __led_toggled_by_event = False @@ -633,12 +641,12 @@ global __led_toggled_by_event __led_toggled_by_event = True self.get_widget('chkLEDRight').set_active(False) - self.get_widget('imgLed').set_from_pixbuf(self.led_off) + thread.start_new_thread(self.refresh_picture, ('imgLed', self.led_off)) __led_toggled_by_event = False def on_eyes_close(self): - self.get_widget('imgLed').set_from_pixbuf(self.eyes_close) + thread.start_new_thread(self.refresh_picture, ('imgLed', self.eyes_close)) def on_eyes_open(self): @@ -647,18 +655,21 @@ def on_mouth_open(self): - self.get_widget('imgMouth').set_from_pixbuf(self.beak_open) + thread.start_new_thread(self.refresh_picture, ('imgMouth', self.beak_open)) def on_mouth_close(self): - self.get_widget('imgMouth').set_from_pixbuf(self.beak_closed) + thread.start_new_thread(self.refresh_picture, ('imgMouth', self.beak_closed)) def on_spin_stop(self): - self.get_widget('imgSpin').set_from_pixbuf(self.spin_off) + thread.start_new_thread(self.refresh_picture, ('imgSpin', self.spin_off)) self.__spin_active = False - self.get_widget('imgSpinRun').set_from_pixbuf(self.run) + thread.start_new_thread(self.refresh_picture, ('imgSpinRun', self.run)) - def on_unplugged(self): - self.get_widget('imgSpin').set_from_pixbuf(self.spin_off) + + def refresh_picture(self, widget, picture): + print ('refresh thread enter : %s'%widget) + self.get_widget(widget).set_from_pixbuf(picture) + print 'refresh thread leave' #-------------------------------- # Remote events #-------------------------------- @@ -739,7 +750,8 @@ if tux.status.eyes_counter() == 0 and self.__eyes_active == True and self.__eyes_infinite == False: self.__eyes_active = False - self.get_widget('imgEyesRun').set_from_pixbuf(self.run) + thread.start_new_thread(self.refresh_picture, ('imgEyesRun', self.run)) + #self.get_widget('imgEyesRun').set_from_pixbuf(self.run) return False return True @@ -755,7 +767,8 @@ if tux.status.mouth_counter() == 0 and self.__mouth_active == True and self.__mouth_infinite == False: self.__mouth_active = False - self.get_widget('imgMouthRun').set_from_pixbuf(self.run) + thread.start_new_thread(self.refresh_picture, ('imgMouthRun', self.run)) + #self.get_widget('imgMouthRun').set_from_pixbuf(self.run) return False return True @@ -771,7 +784,8 @@ if tux.status.wings_counter() == 0 and self.__wings_active == True and self.__wings_infinite == False: self.__wings_active = False - self.get_widget('imgWingsRun').set_from_pixbuf(self.run) + thread.start_new_thread(self.refresh_picture, ('imgWingsRun', self.run)) + #self.get_widget('imgWingsRun').set_from_pixbuf(self.run) return False return True @@ -779,4 +793,4 @@ def __wait2(self): tux.sys.wait(2) - self.get_widget('imgSpin').set_from_pixbuf(self.spin_off) + thread.start_new_thread(self.refresh_picture, ('imgSpin', self.spin_off)) Modified: software/gadgets/tux_controller/trunk/TuxController.tgf =================================================================== (Binary files differ) |