def submitContact(self): name = self.nameLine.text() if name == "": QMessageBox.information(self, "Empty Field", "Please enter a name and address.") else: new_EMC = calc_EMC(140, 0.55) QMessageBox.information(self, "Success!", "Hello {0}! You calculated {1}".format(name, new_EMC))
feet = StringVar() meters = StringVar() feet_entry = ttk.Entry(mainframe, width=7, textvariable=feet) feet_entry.grid(column=2, row=1, sticky=(W, E)) ttk.Label(mainframe, textvariable=meters).grid(column=2, row=2, sticky=(W,E)) ttk.Button(mainframe, text="Calculate", command=calculate).grid(column=3, row=3, sticky=W) ttk.Label(mainframe, text="feet").grid(column=3, row=1, sticky=W) ttk.Label(mainframe, text="is equivalent to").grid(column=1, row=2, sticky=E) ttk.Label(mainframe, text="meters").grid(column=3, row=2, sticky=W) for child in mainframe.winfo_children(): child.grid_configure(padx=5, pady=5) feet_entry.focus() root.bind('<Return>', calculate) root.mainloop() for ii in range(0,200): print(calc_EMC(ii,0.50))
def __init__(self, parent=None): super(Form, self).__init__(parent) self.temperature = 140 self.humidity = 0.55 self.equilibrium_moisture_content = calc_EMC(self.temperature,self.humidity) fibre_saturation_Label = QLabel("Fiber Saturation Ratio (%) (from tables)") self.fibre_saturation_spinbox = QDoubleSpinBox() self.fibre_saturation_spinbox.setDecimals(1) self.fibre_saturation_spinbox.setRange(0, 100) self.fibre_saturation_spinbox.setSingleStep(0.1) self.fibre_saturation_spinbox.setValue(18) temperature_Label = QLabel("Current temperature measurement") self.temperature_value_label = QLabel("{0}".format(self.temperature)) humidity_Label = QLabel("Current humidity measurement") self.humidity_value_label = QLabel("{0}".format(self.humidity)) final_saturation_Label = QLabel("Target wood saturation Ratio (%)") self.final_saturation_spinbox = QDoubleSpinBox() self.final_saturation_spinbox.setDecimals(1) self.final_saturation_spinbox.setRange(0, 100) self.final_saturation_spinbox.setSingleStep(0.1) self.final_saturation_spinbox.setValue(6) emc_Label = QLabel("Equilibrium Moisture Content") self.emc_value_label = QLabel("{0}".format(self.equilibrium_moisture_content)) mainLayout = QGridLayout() mainLayout.addWidget(fibre_saturation_Label, 0 , 0) mainLayout.addWidget(self.fibre_saturation_spinbox, 1 , 0) mainLayout.addWidget(temperature_Label, 2 , 0) mainLayout.addWidget(self.temperature_value_label, 3 , 0) mainLayout.addWidget(humidity_Label, 4 , 0) mainLayout.addWidget(self.humidity_value_label, 5 , 0) mainLayout.addWidget(final_saturation_Label, 0 , 1) mainLayout.addWidget(self.final_saturation_spinbox, 1 , 1) mainLayout.addWidget(emc_Label, 2 , 1) mainLayout.addWidget(self.emc_value_label, 3 , 1) self.setLayout(mainLayout) self.setWindowTitle("Humidity Control V0.3") #def connect_and_emit_trigger(self): # Connect the trigger signal to a slot. self.update_EMC.connect(self.update_EMC_handle) # Emit the signal. self.update_EMC.emit() self.timer = QTimer(self) self.timer.timeout.connect(self.random_noise) self.timer.start(1000)
def update_EMC_handle(self): self.equilibrium_moisture_content = calc_EMC(self.temperature, self.humidity) self.temperature_value_label.setNum(self.temperature) self.humidity_value_label.setNum(self.humidity) self.emc_value_label.setNum(self.equilibrium_moisture_content)