Exemplo n.º 1
0
def main(ott, interf):
    #     a = M('plot')
    #     print(isinstance(a,QWidget))
    image = np.arange(512**2).reshape((512, 512))
    ott.referenceMirror.setPosition(
        np.array([0.e+00, 0.e+00, 0.e+00, 1.e-07, -4.e-07, 0.e+00]))
    ott.parabola.setPosition(
        np.array([0, 0, 9.9999997e-06, 1.0836526e-07, 2.2898718e-09, 0]))
    ott.parabolaSlider.setPosition(0.75)
    ott.angleRotator.setPosition(90.)
    ott.referenceMirrorSlider.setPosition(0.6)
    oi = OttImages(ott)
    smap1, smask = oi.ott_smap()

    cmap = 'viridis'
    gui = Gui([['hot'], ___, ['viridis'], ___],
              [M('plot'), M('plot2'),
               M('plot3'), M('plot4')])
    setPlot(gui, image)

    while True:
        try:
            name, event = gui.get(timeout=1)

        except Empty:
            setPlot(gui, image**2, cmap)
            setPlot2(gui, oi, smap1, smask, cmap)
            setPlot3(gui, oi, cmap)
            setPlot4(gui, oi, smap1, cmap)
            continue

        if name is None:
            break
        if name in ['viridis', 'hot']:
            cmap = name
Exemplo n.º 2
0
gui.widgets['tab1'].setRowCount(5)
gui.widgets['tab1'].horizontalHeader().setSectionResizeMode(
    QHeaderView.Stretch)

gui.l1 = "Label 1"
gui.l2 = "This is Label 2"

for x in range(4):
    for y in range(5):
        item = QTableWidgetItem(f'{x}, {y}')
        gui.widgets['tab1'].setItem(y, x, item)
        gui.widgets['tab1'].setHorizontalHeaderItem(
            x, QTableWidgetItem(f'Col: {x}'))
        gui.widgets['tab1'].setVerticalHeaderItem(
            y, QTableWidgetItem(f'Row: {y}'))

while True:
    name, event = gui.get()

    if name == 'slider1':
        gui.lcd.display(float(gui.slider1))
        gui.widgets['tab1'].itemAt(0, 0).setText(f'{gui.slider1}')

    elif name == 'dial':
        gui.widgets['tab1'].itemAt(0, 1).setText(f'{gui.dial}')
        gui.lcd2.display(float(gui.dial))
        gui.progbar = gui.dial

    elif name == None:
        break
                function_to_call = match_action_info['func']
                function_to_call(match_result, match_action_info)
            else:
                print("Warning unmatched: {!r}".format(lineread))
                print("Warning unmatched: {!r}".format(lineread))

    if runningAnalysisProcess.poll() is not None:
        print("process has exited")
        runningAnalysisProcess = None
        enableOrDisableRelevantWidgets()
        return


while True:
    try:
        name, event = gui.get(timeout=0.1)
    except Empty:
        #print("poll")
        if runningAnalysisProcess is not None:
            updateGuiFromProcessLog()
        continue

    if name is None:
        print("Exiting event loop")
        break

    print("Event {!r}".format(name))
    functionName = "cb_" + name
    function = globals().get(functionName, None)
    if function is None:
        print("Unknown " + functionName)
Exemplo n.º 4
0
# -*- coding: utf-8 -*-

from guietta import Gui, B, E, L, HS, VS, HSeparator, VSeparator
from guietta import Yes, No, Ok, Cancel, Quit, _, ___, III

gui = Gui(['<center>A big GUI with all of Guietta'
           's widgets</center>'], [HSeparator],
          ['Label', 'imagelabel.jpeg',
           L('another label'),
           VS('slider1')],
          [_, ['button'], B('another button'), III],
          ['__edit__', E('an edit box'), _, VSeparator],
          [Quit, Ok, Cancel, III], [Yes, No, _, III], [HSeparator],
          [HS('slider2'), ___, ___, _])

dummy = gui.get()
Exemplo n.º 5
0
# -*- coding: utf-8 -*-

# Non-blocking gui.get()
# causes thousands of exceptions per second using 100% CPU,
# while the GUI still works.

from guietta import B, _, Gui, Quit, Empty

counter = 0

gui = Gui(['Enter expression:', '__expr__',
           B('Eval!')], ['Result:', 'result', _], ['counter', _, Quit])

while True:
    try:
        name, event = gui.get(block=False)
    except Empty:
        counter += 1
        gui.counter = counter
        continue

    if name == 'Eval':
        try:
            gui.result = eval(gui.expr)
        except Exception as e:
            gui.result = 'Error: ' + str(e)

    elif name is None:
        break
Exemplo n.º 6
0
def main():
    global bucket
    sqs = boto3.resource('sqs')
    s3 = boto3.resource('s3')

    # Get the queue urls
    request_queue = sqs.get_queue_by_name(QueueName='request_queue')
    response_queue = sqs.get_queue_by_name(QueueName='response_queue')
    bucket = s3.Bucket('julgio-cli-bucket')

    print('AWS connection done. Starting application...')

    curr_img = 1

    gui = Gui(["Enter numbers:", _, _, _, _],
              ["__n1__", "__n2__", _, "Median:", "median_val"],
              ["__n3__", "__n4__", _, "Mean:", "mean_val"],
              ["__n5__", "__n6__", _, "Min:", "min_val"],
              ["__n7__", "__n8__", _, "Max:", "max_val"],
              [["Go"], ___, _, _, _], [HSeparator, ___, ___, ___, ___],
              [("img1.jpg", "img"), ___, VSeparator,
               ("img1.jpg", "img2"), ___],
              [(["<"], "prev"),
               ([">"], "next"), III, ["Effect 1"], ["Effect 2"]])

    gui.title("Julien's Cloud Computing Lab3")
    gui.window().resize(500, 100)
    gui.median_val = "."
    gui.mean_val = "."
    gui.min_val = "."
    gui.max_val = "."
    gui.img_label = ""

    # Handle ui events (e.g. button presses)
    while True:
        name, event = gui.get()

        if name == None:
            # The user pressed the X (quits the app)
            break

        elif name == 'Go':  # Calcuate the result
            # Fetch the values from the interface
            # The message must be comma seperated values
            message = str(gui.n1) + "," + str(gui.n2) + "," + str(gui.n3) + "," +\
                      str(gui.n4) + "," + str(gui.n5) + "," + str(gui.n6) + "," +\
                      str(gui.n7) + "," + str(gui.n8)

            send_average_request(request_queue, message)

            gui.median_val = "Waiting for response..."
            gui.mean_val = "Waiting for response..."
            gui.min_val = "Waiting for response..."
            gui.max_val = "Waiting for response..."
            gui.widgets["Go"].setEnabled(
                False
            )  # Disable the go button while waiting for a response from worker

            # Execute the queue monitoring funciton in a background thread as to not block the UI thread
            gui.execute_in_background(wait_for_response,
                                      args=[response_queue],
                                      callback=on_response_received)

        elif name == "prev":  # Image precedente
            curr_img -= 1
            if curr_img == 0:
                curr_img = 4
            gui.widgets["img"].setPixmap(
                QPixmap("./img" + str(curr_img) + ".jpg"))

        elif name == "next":  # Image suivante
            curr_img += 1
            if curr_img == 5:
                curr_img = 1
            gui.widgets["img"].setPixmap(
                QPixmap("./img" + str(curr_img) + ".jpg"))

        elif name.startswith("Effect"):
            ### Apply effect to selected image
            # Step 1 : Upload image to s3 bucket
            # Step 2 : Display "loading" image
            # Step 3 : Send message with the image link and effect number
            # Step 4 : Wait for response
            ###

            # Step 1
            img_destination = "lab3_img.jpg"
            bucket.upload_file("img" + str(curr_img) + ".jpg", img_destination)

            # Step 2
            gui.widgets["img2"].setPixmap(QPixmap("./imgLoad.jpg"))
            gui.widgets["Effect1"].setEnabled(False)  # Also disable buttons
            gui.widgets["Effect2"].setEnabled(False)

            # Step 3
            # The message is "[image path in bucket],[Effect number]"
            message = img_destination + ","
            if name == "Effect1":
                message += "1"
            elif name == "Effect2":
                message += "2"
            send_image_request(request_queue, message)

            # Step 4
            # Execute the queue monitoring funciton in a background thread as to not block the UI thread
            gui.execute_in_background(wait_for_response,
                                      args=[response_queue],
                                      callback=on_response_received)