en:examples
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende ÜberarbeitungLetzte ÜberarbeitungBeide Seiten der Revision | ||
en:examples [2022/03/09 08:54] – [EAN check] roehner | en:examples [2022/08/22 11:07] – [Car] roehner | ||
---|---|---|---|
Zeile 14: | Zeile 14: | ||
# Processing | # Processing | ||
if not EAN.isdigit(): | if not EAN.isdigit(): | ||
- | self.output(' | + | self.output(' |
if len(EAN) == 13: | if len(EAN) == 13: | ||
self.output(' | self.output(' | ||
Zeile 82: | Zeile 82: | ||
self.car1 = car(' | self.car1 = car(' | ||
</ | </ | ||
+ | |||
+ | === Tkinter/TKK === | ||
When refueling, the quantity entered in the entry widget is read in via the get() method of the control variable // | When refueling, the quantity entered in the entry widget is read in via the get() method of the control variable // | ||
Zeile 111: | Zeile 113: | ||
**Download** | **Download** | ||
*[[https:// | *[[https:// | ||
+ | |||
+ | === Qt === | ||
+ | |||
+ | When refueling, the quantity is read in via the text() method of the LineEdit widget and converted into the required data type using //float//. | ||
+ | |||
+ | <code python> | ||
+ | def bRefuel_Command(self): | ||
+ | # Input from the GUI | ||
+ | amount = float(self.leAmount.text()) | ||
+ | # Processing | ||
+ | self.car1.refuel(amount) | ||
+ | # Output | ||
+ | self.show() | ||
+ | </ | ||
+ | |||
+ | Then, according to the IPO principle, the entered amount is processed in the // | ||
+ | |||
+ | Finally, the result is output with a separate method //show()//. The values for license plate, tank contents and mileage are retrieved via the get() methods of the class car and passed to the setText() methods of the widgets leLicenseplate, | ||
+ | |||
+ | <code python> | ||
+ | def show(self): | ||
+ | self.leLicenseplate.setText(self.car1.get_licenseplate()) | ||
+ | self.leTankcontent.setText(self.car1.get_tankcontent()) | ||
+ | self.leMileage.setText(self.car1.get_mileage()) | ||
+ | self.lCar.move(x = self.car1.get_mileage(), | ||
+ | </ | ||
+ | |||
+ | The label widget //lCar// has been assigned a car image via the //Pixmap// attribute in the object inspector. The //move()// method sets the x position of the car to the mileage. | ||
+ | |||
+ | **Download** | ||
+ | *[[https:// | ||
==== Linked List ==== | ==== Linked List ==== |
en/examples.txt · Zuletzt geändert: 2022/08/25 21:28 von roehner