소스 검색

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 년 전
부모
커밋
d28d882826
2개의 변경된 파일14개의 추가작업 그리고 12개의 파일을 삭제
  1. 8
    6
      data/pd-buddy-gtk.ui
  2. 6
    6
      pd-buddy-gtk.py

+ 8
- 6
data/pd-buddy-gtk.ui 파일 보기

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

+ 6
- 6
pd-buddy-gtk.py 파일 보기

@@ -284,8 +284,8 @@ class Handler:
284 284
 
285 285
     def on_select_list_row_activated(self, selectlist, serport):
286 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 289
         giveback = self.builder.get_object("giveback-toggle")
290 290
         pd_frame = self.builder.get_object("power-delivery-frame")
291 291
         output = self.builder.get_object("output-switch")
@@ -420,13 +420,13 @@ class Handler:
420 420
         # Set visibility
421 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 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 431
         self._set_save_button_visibility()
432 432
 

Loading…
취소
저장