Browse Source

Use the adjustments for updating V and I

There's not much reason to use the widgets themselves when I can use the
model instead.
Clara Hobbs 6 years ago
parent
commit
d28d882826
2 changed files with 14 additions and 12 deletions
  1. 8
    6
      data/pd-buddy-gtk.ui
  2. 6
    6
      pd-buddy-gtk.py

+ 8
- 6
data/pd-buddy-gtk.ui View File

9
   </object>
9
   </object>
10
   <object class="GtkAdjustment" id="current-adjustment">
10
   <object class="GtkAdjustment" id="current-adjustment">
11
     <property name="upper">5</property>
11
     <property name="upper">5</property>
12
-    <property name="step_increment">1</property>
13
-    <property name="page_increment">10</property>
12
+    <property name="step_increment">0.10000000000000001</property>
13
+    <property name="page_increment">1</property>
14
+    <signal name="value-changed" handler="on_current_adjustment_value_changed" swapped="no"/>
14
   </object>
15
   </object>
15
   <object class="GtkAdjustment" id="voltage-adjustment">
16
   <object class="GtkAdjustment" id="voltage-adjustment">
16
-    <property name="upper">20</property>
17
-    <property name="step_increment">0.01</property>
17
+    <property name="upper">21</property>
18
+    <property name="step_increment">0.10000000000000001</property>
18
     <property name="page_increment">1</property>
19
     <property name="page_increment">1</property>
20
+    <signal name="value-changed" handler="on_voltage_adjustment_value_changed" swapped="no"/>
19
   </object>
21
   </object>
20
   <object class="GtkApplicationWindow" id="pdb-window">
22
   <object class="GtkApplicationWindow" id="pdb-window">
21
     <property name="can_focus">False</property>
23
     <property name="can_focus">False</property>
217
                                                 <property name="can_focus">True</property>
219
                                                 <property name="can_focus">True</property>
218
                                                 <property name="width_chars">5</property>
220
                                                 <property name="width_chars">5</property>
219
                                                 <property name="text" translatable="yes">0.00</property>
221
                                                 <property name="text" translatable="yes">0.00</property>
222
+                                                <property name="xalign">1</property>
220
                                                 <property name="input_purpose">number</property>
223
                                                 <property name="input_purpose">number</property>
221
                                                 <property name="adjustment">voltage-adjustment</property>
224
                                                 <property name="adjustment">voltage-adjustment</property>
222
                                                 <property name="digits">2</property>
225
                                                 <property name="digits">2</property>
223
                                                 <property name="numeric">True</property>
226
                                                 <property name="numeric">True</property>
224
-                                                <signal name="value-changed" handler="on_voltage_spinbutton_changed" swapped="no"/>
225
                                               </object>
227
                                               </object>
226
                                               <packing>
228
                                               <packing>
227
                                                 <property name="left_attach">1</property>
229
                                                 <property name="left_attach">1</property>
270
                                                 <property name="can_focus">True</property>
272
                                                 <property name="can_focus">True</property>
271
                                                 <property name="margin_left">12</property>
273
                                                 <property name="margin_left">12</property>
272
                                                 <property name="width_chars">5</property>
274
                                                 <property name="width_chars">5</property>
275
+                                                <property name="xalign">1</property>
273
                                                 <property name="input_purpose">number</property>
276
                                                 <property name="input_purpose">number</property>
274
                                                 <property name="adjustment">current-adjustment</property>
277
                                                 <property name="adjustment">current-adjustment</property>
275
                                                 <property name="digits">2</property>
278
                                                 <property name="digits">2</property>
276
                                                 <property name="numeric">True</property>
279
                                                 <property name="numeric">True</property>
277
-                                                <signal name="value-changed" handler="on_current_spinbutton_changed" swapped="no"/>
278
                                               </object>
280
                                               </object>
279
                                               <packing>
281
                                               <packing>
280
                                                 <property name="left_attach">1</property>
282
                                                 <property name="left_attach">1</property>

+ 6
- 6
pd-buddy-gtk.py View File

284
 
284
 
285
     def on_select_list_row_activated(self, selectlist, serport):
285
     def on_select_list_row_activated(self, selectlist, serport):
286
         # Get relevant widgets
286
         # Get relevant widgets
287
-        voltage = self.builder.get_object("voltage-spinbutton")
288
-        current = self.builder.get_object("current-spinbutton")
287
+        voltage = self.builder.get_object("voltage-adjustment")
288
+        current = self.builder.get_object("current-adjustment")
289
         giveback = self.builder.get_object("giveback-toggle")
289
         giveback = self.builder.get_object("giveback-toggle")
290
         pd_frame = self.builder.get_object("power-delivery-frame")
290
         pd_frame = self.builder.get_object("power-delivery-frame")
291
         output = self.builder.get_object("output-switch")
291
         output = self.builder.get_object("output-switch")
420
         # Set visibility
420
         # Set visibility
421
         rev.set_reveal_child(self.cfg != self.cfg_clean)
421
         rev.set_reveal_child(self.cfg != self.cfg_clean)
422
 
422
 
423
-    def on_voltage_spinbutton_changed(self, spin):
424
-        self.cfg = self.cfg._replace(v=int(spin.get_value() * 1000))
423
+    def on_voltage_adjustment_value_changed(self, adj):
424
+        self.cfg = self.cfg._replace(v=int(adj.get_value() * 1000))
425
 
425
 
426
         self._set_save_button_visibility()
426
         self._set_save_button_visibility()
427
 
427
 
428
-    def on_current_spinbutton_changed(self, spin):
429
-        self.cfg = self.cfg._replace(i=int(spin.get_value() * 1000))
428
+    def on_current_adjustment_value_changed(self, adj):
429
+        self.cfg = self.cfg._replace(i=int(adj.get_value() * 1000))
430
 
430
 
431
         self._set_save_button_visibility()
431
         self._set_save_button_visibility()
432
 
432
 

Loading…
Cancel
Save