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
en:examples [2022/03/09 08:59] – [EAN check] roehneren:examples [2022/08/25 21:28] (aktuell) – [EAN check] roehner
Zeile 1: Zeile 1:
 ===== Examples ===== ===== Examples =====
 ==== EAN check ==== ==== EAN check ====
 +=== Tkinter/TTK ===
  
 The EAN check is an example of a simple GUI application. It has an entry widget for entering an EAN and a text widget for the multi-line output of results. The EAN check is an example of a simple GUI application. It has an entry widget for entering an EAN and a text widget for the multi-line output of results.
Zeile 61: Zeile 62:
 **Download**: **Download**:
   *[[https://www.guipy.de/examples/en/ean.zip|ean.zip]]    *[[https://www.guipy.de/examples/en/ean.zip|ean.zip]] 
 +
 +=== Qt variant of EAN check ===
 +In Qt we have a LineEdit widget for input and a PlainTextWidget for output. To read the EAN we use the //text()// method of LineEdit widget.
 +
 +<code python>
 +    EAN = self.leEAN.text()
 +</code>
 +
 +The output is easier in Qt than in Tkinter/TTK:
 +
 +<code python>
 +    def output(self, line):
 +        self.Output.appendPlainText(line)
 +</code>
 +  
 +**Download**:
 +  *[[https://www.guipy.de/examples/en/qtean.zip|qtean.zip]] 
  
 ==== Car==== ==== Car====
Zeile 82: Zeile 100:
       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 131:
 **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.1646812768.txt.gz · Zuletzt geändert: 2022/03/09 08:59 von roehner