def __init__(self):
		Gtk.Window.__init__(self)

		self.channel = implementations.insecure_channel('localhost', 60000)
		self.stub = gui_pb2.beta_create_ControllerView_stub(self.channel)

		self.connect("delete-event", Gtk.main_quit)
		self.set_title("Superposition 2")
		self.resize(800, 600)
		self.daQubits = [self.registerSize]
		self.ePolarizations = [self.registerSize]
		self.eMeasurementAngles = [self.registerSize]
		self.bPolarize = [self.registerSize]
		self.bMeasure = [self.registerSize]
		self.bChangeAngle = [self.registerSize]

		self.polarizations = [0.0, 0.0, 0.0, 0.0]
		self.measurementAngles = [0.0, 0.0, 0.0, 0.0]

		cVLauncher = Gtk.VBox()
		cHLauncher = Gtk.HBox()
		cHLauncher.set_size_request(700, 30)
		cHma = Gtk.HBox()
		cHma.set_size_request(700, 30)
		cHdaQubits = Gtk.HBox()
		cHdaQubits.set_size_request(800, 100)
		
		cVLauncher.pack_start(cHLauncher, True, False, 0)
		cVLauncher.pack_start(cHma, True, False, 0)
		cVLauncher.pack_start(cHdaQubits, True, False, 0)

		for i in range(self.registerSize):
			self.daQubits.insert(i, Gtk.DrawingArea())
			self.daQubits[i].set_size_request(200, 150)
			self.daQubits[i].connect("draw", self.expose, i)
			cHdaQubits.pack_start(self.daQubits[i], True, False, 0)

		for i in range(self.registerSize):
			self.ePolarizations.insert(i,Gtk.Entry())
			self.ePolarizations[i].set_text(str(self.polarizations[i]))
			self.ePolarizations[i].set_width_chars(5)
			self.bPolarize.insert(i,Gtk.Button())
			self.bPolarize[i].set_label("Polarize")
			self.bPolarize[i].connect("clicked", self.bPolarize_exec, i)
			self.bMeasure.insert(i,Gtk.Button())
			self.bMeasure[i].set_label("Measure")
			self.bMeasure[i].connect("clicked", self.bMeasure_exec, i)
			cHLauncher.pack_start(
				self.ePolarizations[i], True, False, 0)
			cHLauncher.pack_start(
				self.bPolarize[i], True, False, 0)
			cHLauncher.pack_start(
				self.bMeasure[i], True, False, 0)

		for i in range(self.registerSize):
			self.eMeasurementAngles.insert(i,Gtk.Entry())
			self.eMeasurementAngles[i].set_text(str(self.measurementAngles[i]))
			self.eMeasurementAngles[i].set_width_chars(5)
			self.bChangeAngle.insert(i,Gtk.Button())
			self.bChangeAngle[i].set_label("Set Detector Angle")
			self.bChangeAngle[i].connect("clicked", self.bChangeAngle_exec, i)

			cHma.pack_start(
				self.eMeasurementAngles[i], True, False, 0)
			cHma.pack_start(
				self.bChangeAngle[i], True, False, 0)

		self.daRegister = Gtk.DrawingArea()
		self.daRegister.set_size_request(800, 100)
		self.daRegister.connect("draw", self.exposeRegister)
		cVLauncher.pack_start(self.daRegister, True, False, 0)

		self.vt = Vte.Terminal()
		self.vt.set_size_request(800, 400)
		self.vt.fork_command_full(
			Vte.PtyFlags.DEFAULT,
			os.environ['PWD'],
			["/bin/bash"],
			[],
			GLib.SpawnFlags.DO_NOT_REAP_CHILD,
			None,
			None,
		)

		command = "./superpositionController\r\n"
		self.vt.feed_child(command, len(command))
		cVLauncher.pack_start(self.vt, True, True, 0)	

		self.add(cVLauncher)
		self.show_all()
		time.sleep(1)
		self.initDone = 1
Esempio n. 2
0
	def __init__(self):
		Gtk.Window.__init__(self)

		self.channel = implementations.insecure_channel('localhost', 60000)
		self.stub = gui_pb2.beta_create_ControllerView_stub(self.channel)

		self.connect("delete-event", Gtk.main_quit)
		self.set_title("Measurement")
		self.resize(800, 400)
		self.daQubits = [self.registerSize]
		self.hQubits = [self.registerSize]
		self.eZeros = [self.registerSize]
		self.eOnes = [self.registerSize]
		self.cVquBitInfo = [self.registerSize]
		self.ePolarizations = [self.registerSize]
		self.eMeasurementAngles = [self.registerSize]
		self.bFindAngle = [self.registerSize]
		self.bMeasure = [self.registerSize]

		self.polarizations = [0.0, 0.0, 0.0, 0.0]
		self.measurementAngles = [0.0, 0.0, 0.0, 0.0]

		cGMain = Gtk.Grid(column_spacing=10)

		cGQubits = Gtk.Grid()
		cGUserInput = Gtk.Grid()

		cVRegister = Gtk.VBox()
		cVRegister.set_size_request(150, 400)

		lGQubits = Gtk.Label()
		lGQubits.set_text("Qubit State")
		lGRegister = Gtk.Label()
		lGRegister.set_text("Register State")
		lGUserInput = Gtk.Label()
		lGUserInput.set_text("Outcome Probability")

		cGMain.attach(lGUserInput, 0, 0, 1, 1)
		cGMain.attach(lGQubits, 1, 0, 2, 1)
		cGMain.attach(lGRegister, 3, 0, 1, 1)

		cGMain.attach(cGQubits, 0, 1, 3, 8)
		cGMain.attach(cVRegister, 3, 1, 1, 8)

		for i in range(self.registerSize):
			cGProbabilities = Gtk.Grid()
			lProbabilities = Gtk.Label()
			lProbabilities.set_text("Qubit " + str(i))
			lProbabilities.set_size_request(80, 20)

			lZero = Gtk.Label()
			lZero.set_text("|0>")
			lZero.set_size_request(40, 20)
			self.eZeros.insert(i, Gtk.Entry())
			self.eZeros[i].set_text("1.0")
			self.eZeros[i].set_width_chars(5)
			lOne = Gtk.Label()
			lOne.set_text("|1>")
			lOne.set_size_request(40, 20)
			self.eOnes.insert(i, Gtk.Entry())
			self.eOnes[i].set_text("0.0")
			self.eOnes[i].set_width_chars(5)

			userInputOffset = 5 * i

			cGQubits.attach(lProbabilities, 0, userInputOffset + 0, 2, 1)
			cGQubits.attach(lZero, 0, userInputOffset + 1, 1, 1)
			cGQubits.attach(self.eZeros[i], 1, userInputOffset + 1, 1, 1)
			cGQubits.attach(lOne, 0, userInputOffset + 2, 1, 1)
			cGQubits.attach(self.eOnes[i], 1, userInputOffset + 2, 1, 1)

			self.daQubits.insert(i, Gtk.DrawingArea())
			self.daQubits[i].set_size_request(150, 100)
			self.daQubits[i].connect("draw", self.expose, i)
			cGQubits.attach(self.daQubits[i], 2, userInputOffset, 1, 3)
		
			self.bFindAngle.insert(i, Gtk.Button())
			self.bFindAngle[i].set_label("Find Angle")
			self.bFindAngle[i].connect("clicked", self.bFindAngle_exec, i)
			cGQubits.attach(self.bFindAngle[i], 3, userInputOffset, 1, 1)
			
			self.bMeasure.insert(i, Gtk.Button())
			self.bMeasure[i].set_label("Measure")
			self.bMeasure[i].connect("clicked", self.bMeasure_exec, i)
			cGQubits.attach(self.bMeasure[i], 4, userInputOffset, 1, 1)

			lPolarization = Gtk.Label()
			lPolarization.set_justify(Gtk.Justification.LEFT)
			lPolarization.set_text("Polarization:")
			lPolarization.set_size_request(200, 20)
			self.ePolarizations.insert(i, Gtk.Entry())
			self.ePolarizations[i].set_text(str(self.polarizations[i]))
			self.ePolarizations[i].set_width_chars(5)
			self.ePolarizations[i].set_editable(False)
			self.ePolarizations[i].set_has_frame(False)
			self.ePolarizations[i].set_can_focus(False)
			cGQubits.attach(lPolarization, 3, userInputOffset + 1, 1, 1)
			cGQubits.attach(self.ePolarizations[i], 4, userInputOffset + 1, 1, 1)

			lMeasurementAngle = Gtk.Label()
			lMeasurementAngle.set_justify(Gtk.Justification.LEFT)
			lMeasurementAngle.set_text("Detector Angle:")
			lMeasurementAngle.set_size_request(200, 20)
			self.eMeasurementAngles.insert(i, Gtk.Entry())
			self.eMeasurementAngles[i].set_text(str(self.measurementAngles[i]))
			self.eMeasurementAngles[i].set_width_chars(5)
			cGQubits.attach(lMeasurementAngle, 3, userInputOffset+2, 1, 1)
			cGQubits.attach(self.eMeasurementAngles[i], 4, userInputOffset+2, 1, 1)

		self.daRegister = Gtk.DrawingArea()
		self.daRegister.set_size_request(150, 400)
		self.daRegister.connect("draw", self.exposeRegister)
		cVRegister.pack_start(self.daRegister, True, False, 0)

		self.vt = Vte.Terminal()
		self.vt.set_size_request(400, 400)
		self.vt.fork_command_full(
			Vte.PtyFlags.DEFAULT,
			os.environ['PWD'],
			["/bin/bash"],
			[],
			GLib.SpawnFlags.DO_NOT_REAP_CHILD,
			None,
			None,
		)

		command = "./superpositionController\r\n"
		self.vt.feed_child(command, len(command))
		self.vt.hide()
		cGMain.attach(self.vt, 4, 1, 1, 8)

		self.add(cGMain)
		self.show_all()
		self.vt.hide()
		time.sleep(1)
		self.initDone = 1
Esempio n. 3
0
    def __init__(self):
        Gtk.Window.__init__(self)

        self.channel = implementations.insecure_channel('localhost', 60000)
        self.stub = gui_pb2.beta_create_ControllerView_stub(self.channel)

        self.connect("delete-event", Gtk.main_quit)
        self.set_title("Superposition 1")
        self.resize(800, 600)
        self.daQubits = [self.registerSize]
        self.ePolarizations = [self.registerSize]
        self.bPolarize = [self.registerSize]
        self.bMeasure = [self.registerSize]
        self.polarizations = [0.0, 0.0, 0.0, 0.0]
        self.measurementAngles = [0.0, 0.0, 0.0, 0.0]

        cVLauncher = Gtk.VBox()
        cHLauncher = Gtk.HBox()
        cHLauncher.set_size_request(700, 30)
        cHdaQubits = Gtk.HBox()
        cHdaQubits.set_size_request(800, 100)

        cVLauncher.pack_start(cHLauncher, True, False, 0)
        cVLauncher.pack_start(cHdaQubits, True, False, 0)

        for i in range(self.registerSize):
            self.daQubits.insert(i, Gtk.DrawingArea())
            self.daQubits[i].set_size_request(200, 150)
            self.daQubits[i].connect("draw", self.expose, i)
            cHdaQubits.pack_start(self.daQubits[i], True, False, 0)

        for i in range(self.registerSize):
            self.ePolarizations.insert(i, Gtk.Entry())
            self.ePolarizations[i].set_text(str(self.polarizations[i]))
            self.ePolarizations[i].set_width_chars(5)
            #			self.ePolarizations[i].connect("draw", self.updateDaQubits, i)
            self.bPolarize.insert(i, Gtk.Button())
            self.bPolarize[i].set_label("Polarize")
            self.bPolarize[i].connect("clicked", self.bPolarize_exec, i)
            self.bMeasure.insert(i, Gtk.Button())
            self.bMeasure[i].set_label("Measure")
            self.bMeasure[i].connect("clicked", self.bMeasure_exec, i)
            cHLauncher.pack_start(self.ePolarizations[i], True, False, 0)
            cHLauncher.pack_start(self.bPolarize[i], True, False, 0)
            cHLauncher.pack_start(self.bMeasure[i], True, False, 0)

        self.daRegister = Gtk.DrawingArea()
        self.daRegister.set_size_request(800, 100)
        self.daRegister.connect("draw", self.exposeRegister)
        cVLauncher.pack_start(self.daRegister, True, False, 0)

        self.vt = Vte.Terminal()
        self.vt.set_size_request(800, 400)
        self.vt.fork_command_full(
            Vte.PtyFlags.DEFAULT,
            os.environ['PWD'],
            ["/bin/bash"],
            [],
            GLib.SpawnFlags.DO_NOT_REAP_CHILD,
            None,
            None,
        )

        command = "./superpositionController\r\n"
        self.vt.feed_child(command, len(command))
        cVLauncher.pack_start(self.vt, True, True, 0)

        self.add(cVLauncher)
        self.show_all()
        time.sleep(1)
        self.initDone = 1
Esempio n. 4
0
    def __init__(self):
        Gtk.Window.__init__(self)

        self.channel = implementations.insecure_channel('localhost', 60000)
        self.stub = gui_pb2.beta_create_ControllerView_stub(self.channel)

        self.connect("delete-event", Gtk.main_quit)
        self.set_title("Measurement")
        self.resize(800, 400)
        self.daQubits = [self.registerSize]
        self.hQubits = [self.registerSize]
        self.eZeros = [self.registerSize]
        self.eOnes = [self.registerSize]
        self.cVquBitInfo = [self.registerSize]
        self.ePolarizations = [self.registerSize]
        self.eMeasurementAngles = [self.registerSize]
        self.bFindAngle = [self.registerSize]
        self.bMeasure = [self.registerSize]

        self.polarizations = [0.0, 0.0, 0.0, 0.0]
        self.measurementAngles = [0.0, 0.0, 0.0, 0.0]

        cGMain = Gtk.Grid(column_spacing=10)

        cGQubits = Gtk.Grid()
        cGUserInput = Gtk.Grid()

        cVRegister = Gtk.VBox()
        cVRegister.set_size_request(150, 400)

        lGQubits = Gtk.Label()
        lGQubits.set_text("Qubit State")
        lGRegister = Gtk.Label()
        lGRegister.set_text("Register State")
        lGUserInput = Gtk.Label()
        lGUserInput.set_text("Outcome Probability")

        cGMain.attach(lGUserInput, 0, 0, 1, 1)
        cGMain.attach(lGQubits, 1, 0, 2, 1)
        cGMain.attach(lGRegister, 3, 0, 1, 1)

        cGMain.attach(cGQubits, 0, 1, 3, 8)
        cGMain.attach(cVRegister, 3, 1, 1, 8)

        for i in range(self.registerSize):
            cGProbabilities = Gtk.Grid()
            lProbabilities = Gtk.Label()
            lProbabilities.set_text("Qubit " + str(i))
            lProbabilities.set_size_request(80, 20)

            lZero = Gtk.Label()
            lZero.set_text("|0>")
            lZero.set_size_request(40, 20)
            self.eZeros.insert(i, Gtk.Entry())
            self.eZeros[i].set_text("1.0")
            self.eZeros[i].set_width_chars(5)
            lOne = Gtk.Label()
            lOne.set_text("|1>")
            lOne.set_size_request(40, 20)
            self.eOnes.insert(i, Gtk.Entry())
            self.eOnes[i].set_text("0.0")
            self.eOnes[i].set_width_chars(5)

            userInputOffset = 5 * i

            cGQubits.attach(lProbabilities, 0, userInputOffset + 0, 2, 1)
            cGQubits.attach(lZero, 0, userInputOffset + 1, 1, 1)
            cGQubits.attach(self.eZeros[i], 1, userInputOffset + 1, 1, 1)
            cGQubits.attach(lOne, 0, userInputOffset + 2, 1, 1)
            cGQubits.attach(self.eOnes[i], 1, userInputOffset + 2, 1, 1)

            self.daQubits.insert(i, Gtk.DrawingArea())
            self.daQubits[i].set_size_request(150, 100)
            self.daQubits[i].connect("draw", self.expose, i)
            cGQubits.attach(self.daQubits[i], 2, userInputOffset, 1, 3)

            self.bFindAngle.insert(i, Gtk.Button())
            self.bFindAngle[i].set_label("Find Angle")
            self.bFindAngle[i].connect("clicked", self.bFindAngle_exec, i)
            cGQubits.attach(self.bFindAngle[i], 3, userInputOffset, 1, 1)

            self.bMeasure.insert(i, Gtk.Button())
            self.bMeasure[i].set_label("Measure")
            self.bMeasure[i].connect("clicked", self.bMeasure_exec, i)
            cGQubits.attach(self.bMeasure[i], 4, userInputOffset, 1, 1)

            lPolarization = Gtk.Label()
            lPolarization.set_justify(Gtk.Justification.LEFT)
            lPolarization.set_text("Polarization:")
            lPolarization.set_size_request(200, 20)
            self.ePolarizations.insert(i, Gtk.Entry())
            self.ePolarizations[i].set_text(str(self.polarizations[i]))
            self.ePolarizations[i].set_width_chars(5)
            self.ePolarizations[i].set_editable(False)
            self.ePolarizations[i].set_has_frame(False)
            self.ePolarizations[i].set_can_focus(False)
            cGQubits.attach(lPolarization, 3, userInputOffset + 1, 1, 1)
            cGQubits.attach(self.ePolarizations[i], 4, userInputOffset + 1, 1,
                            1)

            lMeasurementAngle = Gtk.Label()
            lMeasurementAngle.set_justify(Gtk.Justification.LEFT)
            lMeasurementAngle.set_text("Detector Angle:")
            lMeasurementAngle.set_size_request(200, 20)
            self.eMeasurementAngles.insert(i, Gtk.Entry())
            self.eMeasurementAngles[i].set_text(str(self.measurementAngles[i]))
            self.eMeasurementAngles[i].set_width_chars(5)
            cGQubits.attach(lMeasurementAngle, 3, userInputOffset + 2, 1, 1)
            cGQubits.attach(self.eMeasurementAngles[i], 4, userInputOffset + 2,
                            1, 1)

        self.daRegister = Gtk.DrawingArea()
        self.daRegister.set_size_request(150, 400)
        self.daRegister.connect("draw", self.exposeRegister)
        cVRegister.pack_start(self.daRegister, True, False, 0)

        self.vt = Vte.Terminal()
        self.vt.set_size_request(400, 400)
        self.vt.fork_command_full(
            Vte.PtyFlags.DEFAULT,
            os.environ['PWD'],
            ["/bin/bash"],
            [],
            GLib.SpawnFlags.DO_NOT_REAP_CHILD,
            None,
            None,
        )

        command = "./superpositionController\r\n"
        self.vt.feed_child(command, len(command))
        self.vt.hide()
        cGMain.attach(self.vt, 4, 1, 1, 8)

        self.add(cGMain)
        self.show_all()
        self.vt.hide()
        time.sleep(1)
        self.initDone = 1