def run(self): """Starts the application using 'MainController' with the 'StartView'.""" # init resources Resources(self) # init language lang = Settings.get_instance().get_settings().general.language.current if lang == 0: Language('en') elif lang == 1: Language('de') else: Language() # start view and controller start_view = StartView() __main_controller = MainController(start_view) __main_controller.start() return self.app.exec_()
def main (): from model import MainModel from controller import MainController from view import MainView m = MainModel() v = MainView() c = MainController(m, v) gtk.main()
def setUp(self): self.controller = MainController(use_settings=False) self.img_model = self.controller.img_model self.mask_model = self.controller.mask_model self.spectrum_model = self.controller.spectrum_model self.calibration_model = self.controller.calibration_model self.calibration_model.integrate_1d = MagicMock(return_value=(self.calibration_model.tth, self.calibration_model.int)) self.phase_model = self.controller.phase_model self.calibration_widget = self.controller.widget.calibration_widget self.mask_widget = self.controller.widget.mask_widget self.integration_widget = self.controller.widget.integration_widget self.integration_controller = self.controller.integration_controller self.calibration_model.load(os.path.join(data_path, 'CeO2_Pilatus1M.poni')) self.img_model.load(os.path.join(data_path, 'CeO2_Pilatus1M.tif')) self.integration_spectrum_controller = self.integration_controller.spectrum_controller self.integration_image_controller = self.integration_controller.image_controller
def test_phase_name_difference_after_modified(self): self.main_controller = MainController(use_settings=False) self.main_controller.calibration_model.integrate_1d = self.calibration_model.integrate_1d self.main_controller.calibration_controller.load_calibration( os.path.join(data_path, 'LaB6_40keV_MarCCD.poni'), update_all=False) self.main_controller.calibration_controller.set_calibrant(7) self.main_controller.calibration_controller.load_img( os.path.join(data_path, 'LaB6_40keV_MarCCD.tif')) self.main_controller.widget.tabWidget.setCurrentIndex(2) self.main_controller.widget.integration_widget.tabWidget.setCurrentIndex( 3) self.main_controller.integration_controller.phase_controller.add_btn_click_callback( os.path.join(jcpds_path, 'au_Anderson.jcpds')) # Erwin starts the software loads Gold and wants to see what is in the jcpds file, however since he does not # change anything the names every are the same... self.phase_controller = self.main_controller.integration_controller.phase_controller self.jcpds_editor_controller = self.phase_controller.jcpds_editor_controller self.jcpds_widget = self.jcpds_editor_controller.widget self.jcpds_phase = self.main_controller.phase_model.phases[0] self.jcpds_in_spec = self.main_controller.integration_controller.widget.pattern_widget.phases[ 0] self.assertEqual('au_Anderson', self.jcpds_phase.name) self.assertEqual( 'au_Anderson', str(self.phase_controller.widget.phase_tw.item(0, 2).text())) self.phase_controller.widget.phase_tw.selectRow(0) QTest.mouseClick(self.phase_controller.widget.phase_edit_btn, QtCore.Qt.LeftButton) QtGui.QApplication.processEvents() self.assertEqual('au_Anderson', self.jcpds_phase.name) self.assertEqual( 'au_Anderson', str(self.phase_controller.widget.phase_tw.item(0, 2).text()))
from gui.render import CanvasRenderer if __name__ == '__main__': """ Application start sequence """ logging.basicConfig(filename='debug.log', level=logging.DEBUG) log('Starting application ...') root = Tk() root.wm_title('Project 1') root.wm_protocol('WM_DELETE_WINDOW', root.quit) # Render the main window main = Main(root, MainController(), name='main') main.controller.set_window(main) # Set the initial renderer renderer = CanvasRenderer(main.content_area) renderer.set_controller(main.controller) main.set_renderer(renderer) # Register menubar components generate_menus(main) # Generate stats and options pane generate_options(main.options_area) generate_stats(main.stats_area) # Fill the window with main frame
def _prepare(self): self.add_controller("main", MainController(self)) self.wm_title("CP210x Control")
def test_high_pressure_values_are_shown_in_jcpds_editor(self): self.main_controller = MainController(use_settings=False) self.main_controller.calibration_model.integrate_1d = self.calibration_model.integrate_1d self.main_controller.calibration_controller.load_calibration( os.path.join(data_path, 'LaB6_40keV_MarCCD.poni'), update_all=False) self.main_controller.calibration_controller.set_calibrant(7) self.main_controller.calibration_controller.load_img( os.path.join(data_path, 'LaB6_40keV_MarCCD.tif')) self.main_controller.widget.tabWidget.setCurrentIndex(2) self.main_controller.widget.integration_widget.tabWidget.setCurrentIndex( 3) self.main_controller.integration_controller.phase_controller.add_btn_click_callback( os.path.join(jcpds_path, 'au_Anderson.jcpds')) # Erwin starts the software loads Gold and wants to see what is in the jcpds file, however since he does not self.phase_controller = self.main_controller.integration_controller.phase_controller self.jcpds_editor_controller = self.phase_controller.jcpds_editor_controller self.jcpds_widget = self.jcpds_editor_controller.widget self.jcpds_phase = self.main_controller.phase_model.phases[0] self.jcpds_in_spec = self.main_controller.integration_controller.widget.pattern_widget.phases[ 0] self.phase_controller.widget.phase_tw.selectRow(0) QTest.mouseClick(self.phase_controller.widget.phase_edit_btn, QtCore.Qt.LeftButton) QtGui.QApplication.processEvents() # he looks at the jcpds_editor and sees that there are not only hkl and intensity values for each reflection but # also d0, d, two_theta0 and two_theta # however, the zero values and non-zero values are all the same self.assertEqual(8, self.jcpds_widget.reflection_table.columnCount()) for row_ind in xrange(13): self.assertEqual(self.get_reflection_table_value(row_ind, 4), self.get_reflection_table_value(row_ind, 6)) self.assertAlmostEqual( self.get_reflection_table_value(row_ind, 5), self.convert_d_to_twotheta( self.jcpds_phase.reflections[row_ind].d0, 0.31), delta=0.0001) self.assertEqual(self.get_reflection_table_value(row_ind, 5), self.get_reflection_table_value(row_ind, 7)) # he further realizes that there are two sets of lattice parameters in the display, but both still show the same # values... self.assertEqual(float(self.jcpds_widget.lattice_eos_a_txt.text()), self.jcpds_widget.lattice_a_sb.value()) self.assertEqual(float(self.jcpds_widget.lattice_eos_b_txt.text()), self.jcpds_widget.lattice_b_sb.value()) self.assertEqual(float(self.jcpds_widget.lattice_eos_c_txt.text()), self.jcpds_widget.lattice_c_sb.value()) self.assertEqual( float(self.jcpds_widget.lattice_eos_volume_txt.text()), float(self.jcpds_widget.lattice_volume_txt.text())) # then he decides to increase pressure in the main_view and sees that the non "0" values resemble the high pressure # values self.phase_controller.widget.phase_pressure_sb.setValue(30) for row_ind in xrange(13): self.assertNotEqual(self.get_reflection_table_value(row_ind, 4), self.get_reflection_table_value(row_ind, 5)) self.assertNotAlmostEqual( self.get_reflection_table_value(row_ind, 6), self.convert_d_to_twotheta( self.jcpds_phase.reflections[row_ind].d0, 0.31), delta=0.0001) self.assertNotEqual(self.get_reflection_table_value(row_ind, 6), self.get_reflection_table_value(row_ind, 7)) self.assertNotEqual(float(self.jcpds_widget.lattice_eos_a_txt.text()), self.jcpds_widget.lattice_a_sb.value()) self.assertNotEqual(float(self.jcpds_widget.lattice_eos_b_txt.text()), self.jcpds_widget.lattice_b_sb.value()) self.assertNotEqual(float(self.jcpds_widget.lattice_eos_c_txt.text()), self.jcpds_widget.lattice_c_sb.value()) self.assertNotEqual( float(self.jcpds_widget.lattice_eos_volume_txt.text()), float(self.jcpds_widget.lattice_volume_txt.text()))
#lijst = [] # # #print("voer alleen integers in.") #print() #lijst_van_lift_objecten=[] #for x in range(0, aantal_liften): # floors=int(input("hoeveel vloeren heeft lift {} ?".format(x))) # print() # floorheight=int(input("hoogste verdieping die lift {} kan gaan ?".format(x))) # print() # expressLift=bool(input("is lift {} een express lift? voer 0 of 1 in. ".format(x))) # print() # lijst_van_lift_objecten.append(Elevator(x,floors,floorheight,expressLift)) #m = ClassWrapper(MainController, lijst_van_lift_objecten) slist = [Elevator(1, 10, 10, False), Elevator(1, 10, 10, False), Elevator(1, 10, 10, False)] e1 = Elevator(1, 10, 10, False) # Elevator(number, floors, floorheight, express lift?) e2 = Elevator(2, 4, 10, False) # Elevator(number, floors, floorheight, express lift?) e3 = Elevator(3, 4, 10, False) # Elevator(number, floors, floorheight, express lift?) m = MainController(e1, e2, e3) World(e1, e2, e3, m) #m = MainController(*slist) #World(slist[0], slist[1], slist[2], m) #m = MainController(lijst_van_lift_objecten) #ClassWrapper(World, lijst_van_lift_objecten) #World(*lijst_van_lift_objecten, m)
def test_connection_between_main_gui_and_jcpds_editor_lattice_and_eos_parameter( self): # Erwin opens up the program, loads image and calibration and some phases self.main_controller = MainController() self.main_controller.calibration_model.integrate_1d = self.calibration_model.integrate_1d self.main_controller.calibration_controller.load_calibration( os.path.join(data_path, 'LaB6_40keV_MarCCD.poni'), update_all=False) self.main_controller.calibration_controller.set_calibrant(7) self.main_controller.calibration_controller.load_img( os.path.join(data_path, 'LaB6_40keV_MarCCD.tif')) self.main_controller.widget.tabWidget.setCurrentIndex(2) self.main_controller.widget.integration_widget.tabWidget.setCurrentIndex( 3) self.main_controller.integration_controller.phase_controller.add_btn_click_callback( os.path.join(jcpds_path, 'au_Anderson.jcpds')) self.main_controller.integration_controller.phase_controller.add_btn_click_callback( os.path.join(jcpds_path, 'mo.jcpds')) self.main_controller.integration_controller.phase_controller.add_btn_click_callback( os.path.join(jcpds_path, 'ar.jcpds')) self.main_controller.integration_controller.phase_controller.add_btn_click_callback( os.path.join(jcpds_path, 're.jcpds')) self.phase_controller = self.main_controller.integration_controller.phase_controller self.jcpds_editor_controller = self.phase_controller.jcpds_editor_controller self.jcpds_widget = self.jcpds_editor_controller.widget self.phase_controller.widget.phase_tw.selectRow(0) QTest.mouseClick(self.phase_controller.widget.phase_edit_btn, QtCore.Qt.LeftButton) QtGui.QApplication.processEvents() # He changes some parameter but then realizes that he screwed it up and presses cancel to revert all his changes self.enter_value_into_spinbox(self.jcpds_widget.lattice_a_sb, 10.4) self.assertAlmostEqual(self.phase_controller.phase_model.phases[0].a0, 10.4) QTest.mouseClick(self.jcpds_widget.cancel_btn, QtCore.Qt.LeftButton) self.assertNotAlmostEqual( self.phase_controller.phase_model.phases[0].a0, 10.4) # Now he selects one phase in the phase table and starts the JCPDS editor and realizes he wanted to click another # phase -- so he just selects it without closing and reopening the editor # and magically the new parameters show up self.phase_controller.widget.phase_tw.selectRow(1) QTest.mouseClick(self.phase_controller.widget.phase_edit_btn, QtCore.Qt.LeftButton) QtGui.QApplication.processEvents() self.phase_controller.widget.phase_tw.selectRow(2) self.assertTrue(float(str(self.jcpds_widget.lattice_a_sb.text())), 5.51280) # Argon lattice parameter # Now he changes the lattice parameter and wants to see if there is any change in the line position in the graph prev_line_pos = self.get_phase_line_position(2, 0) self.enter_value_into_spinbox(self.jcpds_widget.lattice_a_sb, 3.4) QtGui.QApplication.processEvents() prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) # now he decides to have full control, changes the structure to TRICLINIC and plays with all parameters: self.set_symmetry('triclinic') self.enter_value_into_spinbox(self.jcpds_widget.lattice_b_sb, 3.2) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) self.enter_value_into_spinbox(self.jcpds_widget.lattice_c_sb, 3.1) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) self.enter_value_into_spinbox(self.jcpds_widget.lattice_ab_sb, 1.6) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) self.enter_value_into_spinbox(self.jcpds_widget.lattice_ca_sb, 1.9) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) self.enter_value_into_spinbox(self.jcpds_widget.lattice_ab_sb, 0.3) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) self.enter_value_into_spinbox(self.jcpds_widget.lattice_alpha_sb, 70) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) self.enter_value_into_spinbox(self.jcpds_widget.lattice_beta_sb, 70) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) self.enter_value_into_spinbox(self.jcpds_widget.lattice_gamma_sb, 70) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) # then he increases the pressure and sees the line moving, but he realizes that the equation of state may # be wrong so he decides to change the parameters in the jcpds-editor self.main_controller.integration_controller.widget.phase_pressure_sb.setValue( 10) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) self.enter_value_into_text_field(self.jcpds_widget.eos_K_txt, 120) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) self.enter_value_into_text_field(self.jcpds_widget.eos_Kp_txt, 6) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) # he decides to change temperature value and play with all equation of state parameters self.enter_value_into_text_field(self.jcpds_widget.eos_alphaT_txt, 6.234e-5) self.assertEqual(self.phase_controller.phase_model.phases[2].alpha_t0, 6.234e-5) self.main_controller.integration_controller.widget.phase_temperature_sb.setValue( 1300) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) self.enter_value_into_text_field(self.jcpds_widget.eos_alphaT_txt, 10.234e-5) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) self.enter_value_into_text_field(self.jcpds_widget.eos_dalphadT_txt, 10.234e-6) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) self.enter_value_into_text_field(self.jcpds_widget.eos_dKdT_txt, 1.2e-4) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0) self.enter_value_into_text_field(self.jcpds_widget.eos_dKpdT_txt, 1.3e-6) prev_line_pos = self.compare_line_position(prev_line_pos, 2, 0)
from SimPyLC import * from elevator import Elevator, Plotter from controller import MainController aantal_liften = int(input("Hoeveel liften?")) print() elevators = [] for x in range(0, aantal_liften): floors = int(input("hoeveel vloeren heeft lift {} ?".format(x))) print() floorheight = int( input("hoogste verdieping die lift {} kan gaan ?".format(x))) print() expressLift = bool( input("is lift {} een express lift? voer 0 of 1 in. ".format(x))) print() elevators.append(Elevator(x, floors, floorheight, expressLift)) m = MainController(elevators) g = Generator(elevators) MainController.__setattr__('sweep', g.sweep) World(*elevators, m)
def main(): ctrl = MainController() ctrl.run()
import wx from flask import Flask, request from flask.ext.api import status from controller import MainController import Queue import thread inputQ = Queue.Queue() app = Flask(__name__) app.config.from_object(__name__) @app.route('/', defaults={'path': ''},methods=['POST']) @app.route('/<path:path>',methods=['POST']) def main(path, *args, **kwargs): inputQ.put(request.data) return request.data, status.HTTP_200_OK if __name__ == '__main__': wxapp = wx.App() controller = MainController(inputQ) controller.show() app.debug = False thread.start_new(app.run, tuple(), {'host' : '192.168.173.1'}) wxapp.MainLoop()
# -*- coding: utf-8 -*- """ __Author__: Romain Maillard __Date__: 11.10.2017 __Name__: startStudioInfoScreen.py __Description__: Start the studio info screen """ from PyQt5.QtWidgets import QApplication, QWidget from mainUI import MainWindow import sys import config from controller import MainController app = QApplication(sys.argv) print("Start Info Display") userInterface = MainWindow() controller = MainController() controller.start() app.exec_() controller.stop() controller.wait() print("Stop Info Display")
def __init__(self): super().__init__(sys.argv) self.main_model = MainModel() self.main_controller = MainController(self.main_model) self.main_view = MainView(self.main_model, self.main_controller) self.main_view.show()
from database_connector import dao import smtplib import twilio from twilio.rest import Client app = Flask(__name__, static_url_path='') smtpObj = smtplib.SMTP('smtp.gmail.com', 587) smtpObj.starttls() smtpObj.login('Your Email Id', 'Your Password') acc = "Your Twilio Account " token = "Your Twilio Account token" twilioClient = Client(acc, token) MainController.MainController(app, request, dao, render_template, redirect, session, smtpObj) UPLOAD_FOLDER = 'datasets' app.secret_key = '12344sefsrfsrg' app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER app.after_request def add_header(r): """ Add headers to both force latest IE rendering engine or Chrome Frame, and also to cache the rendered page for 10 minutes. """ r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" r.headers["Pragma"] = "no-cache"
def test_connection_between_main_gui_and_jcpds_editor_reflections(self): # Erwin loads Dioptas with a previous calibration and image file then he adds several phases and looks into the # jcpds editor for the first phase. He sees that everything seems to be correct self.main_controller = MainController() self.main_controller.calibration_model.integrate_1d = self.calibration_model.integrate_1d self.main_controller.calibration_controller.load_calibration( os.path.join(data_path, 'LaB6_40keV_MarCCD.poni'), update_all=False) self.main_controller.calibration_controller.set_calibrant(7) self.main_controller.calibration_controller.load_img( os.path.join(data_path, 'LaB6_40keV_MarCCD.tif')) self.main_controller.widget.tabWidget.setCurrentIndex(2) self.main_controller.widget.integration_widget.tabWidget.setCurrentIndex( 3) self.main_controller.integration_controller.phase_controller.add_btn_click_callback( os.path.join(jcpds_path, 'au_Anderson.jcpds')) self.main_controller.integration_controller.phase_controller.add_btn_click_callback( os.path.join(jcpds_path, 'mo.jcpds')) self.main_controller.integration_controller.phase_controller.add_btn_click_callback( os.path.join(jcpds_path, 'ar.jcpds')) self.main_controller.integration_controller.phase_controller.add_btn_click_callback( os.path.join(jcpds_path, 're.jcpds')) self.phase_controller = self.main_controller.integration_controller.phase_controller self.jcpds_editor_controller = self.phase_controller.jcpds_editor_controller self.jcpds_widget = self.jcpds_editor_controller.widget self.jcpds_phase = self.main_controller.phase_model.phases[0] self.jcpds_in_spec = self.main_controller.integration_controller.widget.pattern_widget.phases[ 0] self.phase_controller.widget.phase_tw.selectRow(0) QTest.mouseClick(self.phase_controller.widget.phase_edit_btn, QtCore.Qt.LeftButton) QtGui.QApplication.processEvents() self.assertEqual(self.jcpds_widget.reflection_table.rowCount(), 13) self.assertEqual(len(self.jcpds_phase.reflections), 13) self.assertEqual(len(self.jcpds_in_spec.line_items), 13) self.assertEqual(len(self.jcpds_in_spec.line_visible), 13) # then he decides to add another reflection to the jcpds file and sees that after changing the parameters it is # miraculously connected to the view # adding the reflection QTest.mouseClick(self.jcpds_widget.reflections_add_btn, QtCore.Qt.LeftButton) self.assertEqual(self.jcpds_widget.reflection_table.rowCount(), 14) self.assertEqual(len(self.jcpds_phase.reflections), 14) self.assertEqual(len(self.jcpds_in_spec.line_items), 14) self.assertEqual(len(self.jcpds_in_spec.line_visible), 14) # putting reasonable values into the reflection self.insert_reflection_table_value(13, 0, 1) self.insert_reflection_table_value(13, 3, 90) self.assertAlmostEqual(self.get_phase_line_position(0, 13), self.convert_d_to_twotheta(4.0786, 0.31), delta=0.0005) # he looks through the reflection and sees that one is actually forbidden. Who has added this reflection to the # file? He decides to delete it self.jcpds_widget.reflection_table.selectRow(5) QTest.mouseClick(self.jcpds_widget.reflections_delete_btn, QtCore.Qt.LeftButton) self.assertEqual(self.jcpds_widget.reflection_table.rowCount(), 13) self.assertEqual(len(self.jcpds_phase.reflections), 13) self.assertEqual(len(self.jcpds_in_spec.line_items), 13) self.assertEqual(len(self.jcpds_in_spec.line_visible), 13) # then he looks again at all reflection and does not like it so he decides to clear all of them and build them # up from sketch... QTest.mouseClick(self.jcpds_widget.reflections_clear_btn, QtCore.Qt.LeftButton) self.assertEqual(self.jcpds_widget.reflection_table.rowCount(), 0) self.assertEqual(len(self.jcpds_phase.reflections), 0) self.assertEqual(len(self.jcpds_in_spec.line_items), 0) self.assertEqual(len(self.jcpds_in_spec.line_visible), 0) # He adds some lines and sees the values change: QTest.mouseClick(self.jcpds_widget.reflections_add_btn, QtCore.Qt.LeftButton) QTest.mouseClick(self.jcpds_widget.reflections_add_btn, QtCore.Qt.LeftButton) QTest.mouseClick(self.jcpds_widget.reflections_add_btn, QtCore.Qt.LeftButton) QTest.mouseClick(self.jcpds_widget.reflections_add_btn, QtCore.Qt.LeftButton) self.assertEqual(self.jcpds_widget.reflection_table.rowCount(), 4) self.assertEqual(len(self.jcpds_phase.reflections), 4) self.assertEqual(len(self.jcpds_in_spec.line_items), 4) self.assertEqual(len(self.jcpds_in_spec.line_visible), 4)
import sys from PySide2.QtWidgets import QApplication from controller import MainModel from controller import MainController from view import MainView if __name__ == '__main__': # Create the Qt Application app = QApplication(sys.argv) # Instantiate MVC classes and set bindings. # Binding order matters so that view and model are consistent: # (1) V<->M; (2) C<->M; (3) V<->C model = MainModel() view = MainView() view.bind_to_model(model) controller = MainController(model) controller.add_callbacks() view.bind_to_controller(controller) # Show and run QT loop view.show() sys.exit(app.exec_())
from database_connector import dao import smtplib import twilio from twilio.rest import Client acc= "ACd55d51bf0ffb776dd46ff9cf6e0d5cd6" token = 'b9f4fc3b69130ab082252801bb16b79c' twilioClient = Client(acc,token) app = Flask(__name__,static_url_path='') smtpObj = smtplib.SMTP('smtp.gmail.com',587) smtpObj.starttls() smtpObj.login('*****@*****.**','manosanthosh') MainController.MainController(app, request, dao, render_template,redirect,url_for, session,smtpObj, twilioClient) UPLOAD_FOLDER = 'datasets' app.secret_key = '12344sefsrfsrg' app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER app.after_request def add_header(r): """ Add headers to both force latest IE rendering engine or Chrome Frame, and also to cache the rendered page for 10 minutes. """ r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate" r.headers["Pragma"] = "no-cache" r.headers["Expires"] = "0"