Python :: Aufgabe #235 :: Lösung #1
3 Lösungen

#235
Funktionswerte einer Parabel berechnen - Windows Forms
Anfänger - Python
von paddlboot
- 04.12.2019 um 16:13 Uhr
#1

von Waldgeist (2310 Punkte)
- 10.02.2020 um 18:00 Uhr
Hallo,
ich habe mir das GUI mit PyQt, genauer gesagt mit Qt-Designer, gebastelt.
Den Code selber habe ich dann in PyCharm geschrieben.
Da es mein erstes Programm in Python mit einer graphischen Oberfläche ist, bitte ich Fehler zu entschuldigen.
Tipps und Tricks sind dagegen jederzeit willkommen.
Python-Code
XML-Code
ich habe mir das GUI mit PyQt, genauer gesagt mit Qt-Designer, gebastelt.
Den Code selber habe ich dann in PyCharm geschrieben.
Da es mein erstes Programm in Python mit einer graphischen Oberfläche ist, bitte ich Fehler zu entschuldigen.
Tipps und Tricks sind dagegen jederzeit willkommen.

import sys import PyQt5.QtWidgets as widgets import PyQt5.uic as uic import matplotlib.pyplot as plt import numpy as np app = widgets.QApplication(sys.argv) w = uic.loadUi("mainwindow.ui") def loeschetext(): w.startwert.setText("0") w.endwert.setText("0") w.schrittweite.setText("0") def berechnen(): start = w.startwert.text() schritt = w.schrittweite.text() ende = w.endwert.text() print(start) print(schritt) print(ende) s = float(start) e = float(ende) i = float(start) while i <= e: x = i b = float(x) y = b * b print(x) print(y) w.listWidget.addItem(" X-Wert: " + str(x) + " Y-Wert: " + str(y)) i = i + float(schritt) A = np.linspace(s,e, endpoint=True) F1 = A * A plt.plot(A, F1) plt.show() w.pushButtonclear.clicked.connect(loeschetext) w.pushButtonstart.clicked.connect(berechnen) w.show() sys.exit(app.exec_())

<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>MainWindow</class> <widget class="QMainWindow" name="MainWindow"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>598</width> <height>374</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralwidget"> <widget class="QLineEdit" name="startwert"> <property name="geometry"> <rect> <x>140</x> <y>80</y> <width>113</width> <height>20</height> </rect> </property> <property name="text"> <string>1</string> </property> <property name="clearButtonEnabled"> <bool>false</bool> </property> </widget> <widget class="QLineEdit" name="endwert"> <property name="geometry"> <rect> <x>140</x> <y>130</y> <width>113</width> <height>20</height> </rect> </property> <property name="text"> <string>1</string> </property> </widget> <widget class="QLineEdit" name="schrittweite"> <property name="geometry"> <rect> <x>140</x> <y>170</y> <width>113</width> <height>20</height> </rect> </property> <property name="text"> <string>1</string> </property> </widget> <widget class="QLabel" name="label1"> <property name="geometry"> <rect> <x>80</x> <y>80</y> <width>47</width> <height>13</height> </rect> </property> <property name="text"> <string>Startwert</string> </property> </widget> <widget class="QLabel" name="label2"> <property name="geometry"> <rect> <x>80</x> <y>130</y> <width>47</width> <height>13</height> </rect> </property> <property name="text"> <string>Endwert</string> </property> </widget> <widget class="QLabel" name="label"> <property name="geometry"> <rect> <x>60</x> <y>170</y> <width>71</width> <height>16</height> </rect> </property> <property name="text"> <string>Schrittweite</string> </property> </widget> <widget class="QPushButton" name="pushButtonstart"> <property name="geometry"> <rect> <x>10</x> <y>240</y> <width>75</width> <height>23</height> </rect> </property> <property name="text"> <string>start</string> </property> </widget> <widget class="QPushButton" name="pushButtonclear"> <property name="geometry"> <rect> <x>100</x> <y>240</y> <width>75</width> <height>23</height> </rect> </property> <property name="text"> <string>löschen</string> </property> </widget> <widget class="QListWidget" name="listWidget"> <property name="geometry"> <rect> <x>280</x> <y>80</y> <width>256</width> <height>192</height> </rect> </property> </widget> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>598</width> <height>21</height> </rect> </property> </widget> <widget class="QStatusBar" name="statusbar"/> </widget> <resources/> <connections/> </ui>
Kommentare:
Für diese Lösung gibt es noch keinen Kommentar
Seite 1 von 0
1