Benutzer-Werkzeuge

Webseiten-Werkzeuge


en:examples

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Beide Seiten der vorigen RevisionVorhergehende Überarbeitung
Nächste Überarbeitung
Vorhergehende Überarbeitung
Letzte ÜberarbeitungBeide Seiten der Revision
en:examples [2022/03/09 08:54] – [EAN check] roehneren:examples [2022/08/22 11:07] – [Car] roehner
Zeile 14: Zeile 14:
     # Processing     # Processing
     if not EAN.isdigit():     if not EAN.isdigit():
-        self.output('An EAN may not contain any characters other than digits!')+        self.output('An EAN must not contain any characters other than digits!')
     if len(EAN) == 13:     if len(EAN) == 13:
         self.output('Length of EAN: 13 ')         self.output('Length of EAN: 13 ')
Zeile 82: Zeile 82:
       self.car1 = car('DA RR 1013', 47, 7.3)       self.car1 = car('DA RR 1013', 47, 7.3)
 </code> </code>
 +
 +=== Tkinter/TKK ===
  
 When refueling, the quantity entered in the entry widget is read in via the get() method of the control variable //eAmountCV// belonging to the widget and converted into the required data type using //float//. When refueling, the quantity entered in the entry widget is read in via the get() method of the control variable //eAmountCV// belonging to the widget and converted into the required data type using //float//.
Zeile 111: Zeile 113:
 **Download** **Download**
   *[[https://www.guipy.de/examples/en/car.zip |car.zip]]    *[[https://www.guipy.de/examples/en/car.zip |car.zip]] 
 +
 +=== 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()
 +</code>
 +
 +Then, according to the IPO principle, the entered amount is processed in the //refuel()// method.
 +
 +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, leTankcontent and leMileage:
 +
 +<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(), y = 160)
 +</code>
 +
 +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://www.guipy.de/examples/en/qtcar.zip |qtcar.zip]] 
  
 ==== Linked List ==== ==== Linked List ====
en/examples.txt · Zuletzt geändert: 2022/08/25 21:28 von roehner