示例#1
0
    def build_ext_window(self):
        self.layout = self.build_basic_layout()
        for param, param_info in self.effect_params.items():
            if param in ['self', 'area']:
                continue

            if param_info.annotation is Color:
                self.layout.extend([[sg.Text(param)],
                                    [
                                        sg.Input(visible=False,
                                                 enable_events=True,
                                                 key=f'COLOR_{param}'),
                                        sg.ColorChooserButton(
                                            'Pick a color',
                                            key=f'COLOR_{param}_btn',
                                            target=f'COLOR_{param}')
                                    ]])
            elif param_info.annotation is List[Color]:
                self.layout.extend([[sg.Text(param)]])
                for i in range(8):
                    self.layout.extend(
                        [[
                            sg.Input(visible=False,
                                     enable_events=True,
                                     key=f'COLOR_LIST_{i}_{param}')
                        ],
                         [
                             sg.ColorChooserButton(
                                 'Pick a color',
                                 key=f'COLOR_LIST_{i}_{param}_btn',
                                 target=f'COLOR_LIST_{i}_{param}')
                         ]])
            else:
                self.layout.extend([[
                    sg.Text(param)
                ], [sg.InputText(key=param, default_text=param_info.default)]])

        self.layout.extend(
            [[sg.Button('Run', key='RUN')],
             [sg.Button('Stop', key='STOP', visible=False)],
             [sg.Button('Save as default', key='SAVE', visible=True)],
             [
                 sg.Button('Load defaults',
                           key='LOAD',
                           visible=self.has_defaults)
             ],
             [
                 sg.Text('Waiting for the effect thread to stop...',
                         justification='center',
                         key='STOP_TXT',
                         visible=False),
                 sg.Input(visible=False,
                          enable_events=True,
                          key='THREAD_STOPPED')
             ]])

        self.window = sg.Window('Mystic Why', self.layout, finalize=True)
示例#2
0
        except:
            # Manual input of the COM port failed so giving the user the possibility to try again or leave
            decision = sg.PopupOKCancel("The COM port you entered is not available.\nClick OK to try again or Cancel to exit!")
            if decision == "Cancel" or decision is None:
                exit()
            

# **************************************** Defines the GUI *****************************************************************************************************
#
layout = [

            [sg.Text('Select RGB LED color...')],        
            [sg.Button('RED', button_color = ("white", "red"), key='red', size=(207,40)), sg.Button('GREEN', button_color = ("white", "green"), key='green', size=(207,40))],
            [sg.Button('BLUE', button_color = ("white", "blue"), key='blue', size=(207,40)), sg.Button('PURPLE', button_color = ("white", "purple"), key='purple', size=(207,40))],
            [sg.Text('_'  * lineLength)],
            [sg.ColorChooserButton("", button_color=sg.TRANSPARENT_BUTTON, image_filename="rgb.png", image_subsample=2, size=(207, 40), border_width=0, key="rgbSelect"), sg.Button('Apply selected color', size=(207,40), key="apply"), ],
            [sg.Text('_'  * lineLength)],
            [sg.Button('LED off', size=(207,40), key='Off'), sg.Button('Exit', size=(207,40), key='exit')],
            [sg.Text("...currently connected to " + comPort), sg.Text((" " * 39) + "p43lz3r", text_color="blue")]

          ]

window = sg.Window('RGB Color Selector', no_titlebar=False).Layout(layout)


# **************************************** Runs the GUI ********************************************************************************************************
#
while True:
    event, values = window.Read()
    
    # Checks which of the buttons has been clicked and calls the requestColor function with the according value