[tuxdroid-svn] r570 - in software/gadgets/light_monitor/trunk: . Light_monitor Light_monitor/Script
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2007-10-02 13:35:55
|
Author: Paul_R Date: 2007-10-02 15:35:54 +0200 (Tue, 02 Oct 2007) New Revision: 570 Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py software/gadgets/light_monitor/trunk/Light_monitor/about.xml software/gadgets/light_monitor/trunk/Light_monitor/settings.xml software/gadgets/light_monitor/trunk/Light_monitor/strings.xml Log: * Changed the index format in the treeview object (str -> int) * Protected the entry box in the settings window. Modified: software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-02 13:19:03 UTC (rev 569) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/GUI/conf/other.pyp 2007-10-02 13:35:54 UTC (rev 570) @@ -6,27 +6,15 @@ path=_me.get_path('root') + '/Scripts/Python/GUI/conf/other.glade', root="window1", domain="params", **kwargs): - - """ - Constructor - """ SimpleGladeApp.__init__(self, path, root, domain, **kwargs) - - def new(self): - """ - On new window - """ self.measure = _me.get_param('measure') self.updates_commons() - self.updates_specifics() self.make_viewtree() + self.update_labels() def updates_commons(self): - """ - Updates common widgets - """ # Window title txt = "%s : %s" % (_me.string('name_to_read'), _me.string('gui_conf_window_title')) @@ -69,9 +57,6 @@ self.get_widget('txt_conf_sample').set_text(str(_me.get_param('Sample'))) - def updates_specifics(self): - pass - ########################################################### # # Light configuration control @@ -119,7 +104,7 @@ self.behavior_column.pack_start(self.behavior_cell, True) self.behavior_column.add_attribute(self.behavior_cell, 'text', 6) - self.value_list = gtk.TreeStore(str, str, str, str, str, str, str) + self.value_list = gtk.TreeStore(int, str, str, str, str, str, str) self.gadget_viewer = gtk.TreeView(self.value_list) self.gadget_viewer.append_column(self.index_column) self.gadget_viewer.append_column(self.event_column) @@ -142,7 +127,14 @@ for i in range(len(self.measure.event_tab)): self.add_row(i) - + + + ########################################################### + # + # Update the labels + # + ########################################################### + def update_labels(self): self.get_widget("lbl_conf_event").set_text(_me.string('conf_lblEvent')) self.get_widget("lbl_conf_type").set_text(_me.string('conf_lblType')) self.get_widget("lbl_conf_value").set_text(_me.string('conf_lblValue')) @@ -157,7 +149,11 @@ self.get_widget("lblControlFrame").set_text(_me.string('conf_lblControl')) - + ########################################################### + # + # On row selected + # + ########################################################### def on_row_selected(self, treeview, path, view_column): self.iter = self.value_list.get_iter(path) index = self.value_list.get_value(self.iter, 0) @@ -203,18 +199,21 @@ else: self.get_widget('conf_behavior').set_filename('None') + + ########################################################### + # + # On row modified + # + ########################################################### def on_btn_conf_modify_clicked(self, widget, *args): index = self.value_list.get_value(self.iter, 0) self.measure.event_tab = _me.get_param('config') length = len(_me.get_param('config')) - if self.get_widget('txt_conf_time').get_text() in ('','0' ,'0.0' ,'None'): - self.get_widget('txt_conf_time').set_text('0.1') - - if self.get_widget('txt_conf_value').get_text() in ('', '0', '0.0', 'None'): - self.get_widget('txt_conf_value').set_text('1.0') + self.verify_value() + value = [] - value = [int(index), + value = [index, self.get_widget('cbb_conf_event').get_active(), self.get_widget('cbb_conf_type').get_active(), float(self.get_widget('txt_conf_value').get_text()), @@ -224,31 +223,35 @@ False, 0] self.measure.event_tab = _me.get_param('config') - self.measure.event_tab[int(index)-1] = value + self.measure.event_tab[(index-1)] = value _me.set_param('config', self.measure.event_tab) self.value_list.clear() for i in range(len(self.measure.event_tab)): self.add_row(i) - + ########################################################### + # + # On row deleted + # + ########################################################### def on_btn_conf_remove_clicked(self, widget, *args): - index = int(self.value_list.get_value(self.iter, 0)) + index = self.value_list.get_value(self.iter, 0) self.measure.event_tab =_me.get_param('config') - self.measure.event_tab.pop(int(index - 1)) + self.measure.event_tab.pop(index - 1) _me.set_param('config', self.measure.event_tab) self.iter = 0 self.value_list.clear() for i in range(len(self.measure.event_tab)): self.add_row(i) - + ########################################################### + # + # On row added + # + ########################################################### def on_btn_conf_add_clicked(self, widget, *args): length = len(_me.get_param('config')) - if self.get_widget('txt_conf_time').get_text() in ('','0' ,'0.0' ,'None'): - self.get_widget('txt_conf_time').set_text('0.1') - - if self.get_widget('txt_conf_value').get_text() in ('', '0', '0.0', 'None'): - self.get_widget('txt_conf_value').set_text('1.0') + self.verify_value() value = [] value = [(length + 1), self.get_widget('cbb_conf_event').get_active(), @@ -267,7 +270,11 @@ for i in range(len(self.measure.event_tab)): self.add_row(i) - + ########################################################### + # + # Add row function + # + ########################################################### def add_row(self, tab_index): self.measure.event_tab = _me.get_param('config') i = tab_index @@ -306,9 +313,13 @@ Notify = _me.string('conf_lblNotNotified') Behavior = 'N.A.' - self.value_list.append(None,[str(i+1), Event, Type, Value, Time, Notify, Behavior]) + self.value_list.append(None,[(i+1), Event, Type, Value, Time, Notify, Behavior]) - + ########################################################### + # + # On combo box event + # + ########################################################### def on_cbb_conf_event_changed(self, widget, *args): if self.get_widget('cbb_conf_event').get_active() == 0: for i in range (4): @@ -325,11 +336,14 @@ self.get_widget('cbb_conf_type').append_text(_me.string('conf_lblDecrease')) self.get_widget('cbb_conf_type').append_text(_me.string('conf_lblBoth')) self.get_widget('cbb_conf_type').set_active(0) - + + + ########################################################### + # + # On accept button clicked + # + ########################################################### def on_accept_clicked(self, widget, *args): - """ - On button 'accept' clicked - """ _me.set_param('Rate', float(self.get_widget('txt_conf_rate').get_text())) _me.set_param('Sample',float(self.get_widget('txt_conf_sample').get_text())) self.measure.rate = _me.get_param('Rate') @@ -338,9 +352,39 @@ _me.set_var('notify_delay', int(self.get_widget("delay_spinbutton").get_value())) self.get_widget("window1").destroy() - + + + ########################################################### + # + # On cancel button clicked + # + ########################################################### def on_cancel_clicked(self, widget, *args): - """ - On button 'cancel' clicked - """ self.get_widget("window1").destroy() + + + ########################################################### + # + # Verify the value + # + ########################################################### + def verify_value(self): + try: + float(self.get_widget('txt_conf_time').get_text()) + except: + self.get_widget('txt_conf_time').set_text('0.1') + + if float(self.get_widget('txt_conf_time').get_text()) < 0.1: + self.get_widget('txt_conf_time').set_text('0.1') + if float(self.get_widget('txt_conf_time').get_text()) > self.measure.rate * self.measure.sample: + self.get_widget('txt_conf_time').set_text(str(self.measure.rate * self.measure.sample)) + + try: + float(self.get_widget('txt_conf_value').get_text()) + except: + self.get_widget('txt_conf_value').set_text('1') + + if float(self.get_widget('txt_conf_value').get_text()) < 1: + self.get_widget('txt_conf_value').set_text('1') + if float(self.get_widget('txt_conf_value').get_text()) > 100: + self.get_widget('txt_conf_value').set_text('100') Modified: software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py 2007-10-02 13:19:03 UTC (rev 569) +++ software/gadgets/light_monitor/trunk/Light_monitor/Scripts/Python/lightGraph_class.py 2007-10-02 13:35:54 UTC (rev 570) @@ -138,6 +138,7 @@ ########################################################### def event_control(self): for i in range (len(self.event_tab)): + print self.event_tab[i][0] self.Threshold_control(i) self.Change_control(i) Modified: software/gadgets/light_monitor/trunk/Light_monitor/about.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-02 13:19:03 UTC (rev 569) +++ software/gadgets/light_monitor/trunk/Light_monitor/about.xml 2007-10-02 13:35:54 UTC (rev 570) @@ -1,7 +1,7 @@ <?xml version='1.0' encoding='UTF-8'?> <about> + <gadget_author type='str'>Paul Rathgeb</gadget_author> + <gadget_version type='str'>0.0.1</gadget_version> <gadget_name type='str'>light_monitor</gadget_name> - <gadget_author type='str'>Paul Rathgeb</gadget_author> <gadget_description type='str'>Light monitor for tux droid</gadget_description> - <gadget_version type='str'>0.0.1</gadget_version> </about> Modified: software/gadgets/light_monitor/trunk/Light_monitor/settings.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/settings.xml 2007-10-02 13:19:03 UTC (rev 569) +++ software/gadgets/light_monitor/trunk/Light_monitor/settings.xml 2007-10-02 13:35:54 UTC (rev 570) @@ -1,7 +1,7 @@ <?xml version='1.0' encoding='UTF-8'?> <settings> <parameters> - <drop type='float'>10.0</drop> + <drop_rad type='bool'>True</drop_rad> <increase_rad type='bool'>True</increase_rad> <changeU_time type='int'>1</changeU_time> <changeD_rad type='bool'>False</changeD_rad> @@ -17,7 +17,7 @@ <drop_time type='int'>1</drop_time> <changeU type='float'>10.0</changeU> <raise_time type='int'>1</raise_time> - <drop_rad type='bool'>True</drop_rad> + <drop type='float'>10.0</drop> <Sample type='float'>500.0</Sample> <threshold_chk type='bool'>False</threshold_chk> <Rate type='float'>0.1</Rate> Modified: software/gadgets/light_monitor/trunk/Light_monitor/strings.xml =================================================================== --- software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-02 13:19:03 UTC (rev 569) +++ software/gadgets/light_monitor/trunk/Light_monitor/strings.xml 2007-10-02 13:35:54 UTC (rev 570) @@ -9,7 +9,6 @@ <widget_lblControl type='str'>Control</widget_lblControl> <gui_conf_accept_bt type='str'>Accept</gui_conf_accept_bt> <help_text type='str'>Bla bla bla bla</help_text> - <conf_lblBehavior type='str'>Behavior script</conf_lblBehavior> <conf_lblChange type='str'>Change</conf_lblChange> <conf_lblBoth type='str'>Both</conf_lblBoth> <widget_lblBtnApply type='str'>Apply changes</widget_lblBtnApply> @@ -19,10 +18,12 @@ <gui_conf_update_title type='str'>Update</gui_conf_update_title> <widget_lblValue type='str'>Value (%)</widget_lblValue> <gui_conf_cancel_bt type='str'>Cancel</gui_conf_cancel_bt> - <widget_lblBoth type='str'>Both direction</widget_lblBoth> + <gui_conf_rate_lb type='str'>Refresh rate :</gui_conf_rate_lb> + <conf_btnRemove type='str'>Remove</conf_btnRemove> <gui_conf_delay_lb type='str'>Delay (sec)</gui_conf_delay_lb> <gui_conf_about_title type='str'>About</gui_conf_about_title> <conf_lblChangeD type='str'>Drop and raise</conf_lblChangeD> + <conf_lblChangeU type='str'>Raise and drop</conf_lblChangeU> <speaker_name type='str'>Ryan8k</speaker_name> <conf_lblSample type='str'>Samples</conf_lblSample> <conf_lblType type='str'>Type</conf_lblType> @@ -38,10 +39,9 @@ <conf_lblNotifiedBehavior type='str'>Notified</conf_lblNotifiedBehavior> <gui_conf_author_lb type='str'>Author</gui_conf_author_lb> <widget_lblDrop type='str'>Drop</widget_lblDrop> - <conf_lblNotified type='str'>Notified ?</conf_lblNotified> - <gui_conf_rate_lb type='str'>Refresh rate :</gui_conf_rate_lb> + <widget_lblBoth type='str'>Both direction</widget_lblBoth> <conf_lblDefaultBehavior type='str'>Default behavior</conf_lblDefaultBehavior> - <conf_lblChangeU type='str'>Raise and drop</conf_lblChangeU> + <conf_lblBehavior type='str'>Behavior script</conf_lblBehavior> <gui_conf_remote_set_bt type='str'>Set</gui_conf_remote_set_bt> <widget_lblChange type='str'>Change</widget_lblChange> <name_to_read type='str'>Light monitor</name_to_read> @@ -55,5 +55,5 @@ <widget_lblChangeD type='str'>Drop and raise</widget_lblChangeD> <conf_lblTime type='str'>Time (sec.)</conf_lblTime> <conf_lblControl type='str'>Control</conf_lblControl> - <conf_btnRemove type='str'>Remove</conf_btnRemove> + <conf_lblNotified type='str'>Notified ?</conf_lblNotified> </strings> Modified: software/gadgets/light_monitor/trunk/Light_monitor.tgf =================================================================== (Binary files differ) |