예제 #1
0
def main():
    window = make_window()
    # -- Event loop --
    while True:
        event, values = window.read()
        if event == sg.WIN_CLOSED:
            break
        if isinstance(event, tuple):
            color, color_hex = event[0], event[1]
        else:
            color, color_hex = hex_to_color[event], event
        # -- Create a secondary window that shows white and black text on chosen color
        layout2 = [[sg.Text(color_hex + ' on clipboard')],
                   [
                       sg.DummyButton(color,
                                      button_color=('white', color),
                                      tooltip=color_hex),
                       sg.DummyButton(color,
                                      button_color=('black', color),
                                      tooltip=color_hex)
                   ]]
        window2 = sg.Window('Buttons with white and black text',
                            layout2,
                            keep_on_top=True,
                            finalize=True)
        window2.TKroot.clipboard_clear()
        window2.TKroot.clipboard_append(color_hex)
    window.close()
예제 #2
0
    def __init__(self,
                 size=(None, None),
                 location=(None, None),
                 font=None,
                 no_titlebar=False,
                 no_button=False,
                 grab_anywhere=False,
                 keep_on_top=True):
        """

		:param size: Tuple[int, int] (w,h) w=characters-wide, h=rows-high
		:param location:  (Default = (None))
		:param font:  specifies the font family, size, etc
		:param no_titlebar:  (Default = False)
		:param no_button:  (Default = False)
		:param grab_anywhere: If True can grab anywhere to move the window (Default = False)
		:param location: Location on screen to display

		"""
        # Show a form that's a running counter
        self.size = size
        self.location = location
        self.font = font
        self.no_titlebar = no_titlebar
        self.no_button = no_button
        self.grab_anywhere = grab_anywhere
        self.keep_on_top = keep_on_top

        win_size = size if size != (None,
                                    None) else sg.DEFAULT_DEBUG_WINDOW_SIZE
        self.window = sg.Window('Debug Window',
                                no_titlebar=no_titlebar,
                                auto_size_text=True,
                                location=location,
                                font=font or ('Courier New', 10),
                                grab_anywhere=grab_anywhere,
                                keep_on_top=keep_on_top)
        self.output_element = sg.Multiline(size=win_size,
                                           autoscroll=True,
                                           key='_MULTILINE_')

        if no_button:
            self.layout = [[self.output_element]]
        else:
            self.layout = [[self.output_element],
                           [sg.DummyButton('Quit'),
                            sg.Stretch()]]
        self.window.AddRows(self.layout)
        self.window.Read(
            timeout=0)  # Show a non-blocking form, returns immediately

        self.output_element_W = self.output_element.Widget
        self.output_element_W.tag_config("stdin", foreground='black')
        self.output_element_W.tag_config("stderr", foreground='red')

        return
예제 #3
0
row = []
layout = []

# -- Create primary color viewer window --
for rows in range(40):
    row = []
    for i in range(12):
        try:
            color = COLORS[rows + 40 * i]
            row.append(
                sg.Button(color, button_color=('black', color), key=color))
        except:
            pass
    layout.append(row)

window = sg.Window('Color Viewer', layout, grab_anywhere=False, font=('any 9'))

# -- Event loop --
while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED:
        break
    # -- Create a secondary window that shows white and black text on chosen color
    layout2 = [[
        sg.DummyButton(event, button_color=('white', event)),
        sg.DummyButton(event, button_color=('black', event))
    ]]
    sg.Window('Buttons with white and black text', layout2,
              keep_on_top=True).read(timeout=0)

window.close()
예제 #4
0
    for i in range(12):
        try:
            color = color_list[rows + 40 * i]
            row.append(
                sg.Button(color,
                          button_color=('black', color),
                          key=color,
                          tooltip=color_map[color]))
        except:
            pass
    layout.append(row)

window = sg.Window('Color Viewer', grab_anywhere=False,
                   font=('any 9')).Layout(layout)

# -- Event loop --
while True:
    event, values = window.Read()
    if event is None:
        break
    # -- Create a secondary window that shows white and black text on chosen color
    layout2 = [[
        sg.DummyButton(event,
                       button_color=('white', event),
                       tooltip=color_map[event]),
        sg.DummyButton(event,
                       button_color=('black', event),
                       tooltip=color_map[event])
    ]]
    sg.Window('Buttons with white and black text',
              keep_on_top=True).Layout(layout2).Read(timeout=0)
          'grey20', 'grey21', 'grey22', 'grey23', 'grey24', 'grey25', 'grey26', 'grey27', 'grey28',
          'grey29', 'grey30', 'grey31', 'grey32', 'grey33', 'grey34', 'grey35', 'grey36', 'grey37',
          'grey38', 'grey39', 'grey40', 'grey42', 'grey43', 'grey44', 'grey45', 'grey46', 'grey47',
          'grey48', 'grey49', 'grey50', 'grey51', 'grey52', 'grey53', 'grey54', 'grey55', 'grey56',
          'grey57', 'grey58', 'grey59', 'grey60', 'grey61', 'grey62', 'grey63', 'grey64', 'grey65',
          'grey66', 'grey67', 'grey68', 'grey69', 'grey70', 'grey71', 'grey72', 'grey73', 'grey74',
          'grey75', 'grey76', 'grey77', 'grey78', 'grey79', 'grey80', 'grey81', 'grey82', 'grey83',
          'grey84', 'grey85', 'grey86', 'grey87', 'grey88', 'grey89', 'grey90', 'grey91', 'grey92',
          'grey93', 'grey94', 'grey95', 'grey97', 'grey98', 'grey99']

sg.SetOptions(button_element_size=(12,1), element_padding=(0,0), auto_size_buttons=False, border_width=0)

layout = [[sg.Text('Click on a color square to see both white and black text on that color', text_color='blue', font='Any 15')]]
row = []
# -- Create primary color viewer window --
for i, color in enumerate(COLORS):
    row.append(sg.RButton(color, button_color=('black', color), key=color))
    if (i+1) % 12 == 0:
        layout.append(row)
        row = []

window = sg.Window('Color Viewer', grab_anywhere=False, font=('any 9')).Layout(layout)

# -- Event loop --
while True:
    event, values = window.Read()
    if event is None:
        break
    # -- Create a secondary window that shows white and black text on chosen color
    layout2 =[[sg.DummyButton(event, button_color=('white', event)), sg.DummyButton(event, button_color=('black', event))]]
    sg.Window('Buttons with white and black text', keep_on_top=True).Layout(layout2).ReadNonBlocking()
예제 #6
0
    'yellow': '#FFFF00',
    'yellow green': '#9ACD32',
    'yellow1': '#FFFF00',
    'yellow2': '#EEEE00',
    'yellow3': '#CDCD00',
    'yellow4': '#8B8B00',
    'YellowGreen': '#9ACD32',
}


sg.SetOptions(button_element_size=(12,1), element_padding=(0,0), auto_size_buttons=False, border_width=1, tooltip_time=100)

layout = [[sg.Text('Hover mouse to see RGB value, click for white & black text', text_color='blue', font='Any 15', relief=sg.RELIEF_SUNKEN, justification='center', size=(100,1), background_color='light green', pad=(0,(0,20))),]]
row = []
# -- Create primary color viewer window --
for i, color in enumerate(color_map):
    row.append(sg.RButton(color, button_color=('black', color), key=color, tooltip=color_map[color]))
    if (i+1) % 15 == 0:
        layout.append(row)
        row = []

window = sg.Window('Color Viewer', grab_anywhere=False, font=('any 9')).Layout(layout)

# -- Event loop --
while True:
    b, v = window.Read()
    if b is None:
        break
    # -- Create a secondary window that shows white and black text on chosen color
    layout2 =[[sg.DummyButton(b, button_color=('white', b), tooltip=color_map[b]), sg.DummyButton(b, button_color=('black', b), tooltip=color_map[b])] ]
    sg.Window('Buttons with white and black text', keep_on_top=True).Layout(layout2).ReadNonBlocking()
          'grey20', 'grey21', 'grey22', 'grey23', 'grey24', 'grey25', 'grey26', 'grey27', 'grey28',
          'grey29', 'grey30', 'grey31', 'grey32', 'grey33', 'grey34', 'grey35', 'grey36', 'grey37',
          'grey38', 'grey39', 'grey40', 'grey42', 'grey43', 'grey44', 'grey45', 'grey46', 'grey47',
          'grey48', 'grey49', 'grey50', 'grey51', 'grey52', 'grey53', 'grey54', 'grey55', 'grey56',
          'grey57', 'grey58', 'grey59', 'grey60', 'grey61', 'grey62', 'grey63', 'grey64', 'grey65',
          'grey66', 'grey67', 'grey68', 'grey69', 'grey70', 'grey71', 'grey72', 'grey73', 'grey74',
          'grey75', 'grey76', 'grey77', 'grey78', 'grey79', 'grey80', 'grey81', 'grey82', 'grey83',
          'grey84', 'grey85', 'grey86', 'grey87', 'grey88', 'grey89', 'grey90', 'grey91', 'grey92',
          'grey93', 'grey94', 'grey95', 'grey97', 'grey98', 'grey99']

sg.SetOptions(button_element_size=(12,1), element_padding=(0,0), auto_size_buttons=False, border_width=0)

layout = [[sg.Text('Click on a color square to see both white and black text on that color', text_color='blue', font='Any 15')]]
row = []
# -- Create primary color viewer window --
for i, color in enumerate(COLORS):
    row.append(sg.RButton(color, button_color=('black', color), key=color))
    if (i+1) % 12 == 0:
        layout.append(row)
        row = []

window = sg.Window('Color Viewer', grab_anywhere=False, font=('any 9')).Layout(layout)

# -- Event loop --
while True:
    b, v = window.Read()
    if b is None:
        break
    # -- Create a secondary window that shows white and black text on chosen color
    layout2 =[[sg.DummyButton(b, button_color=('white', b)), sg.DummyButton(b, button_color=('black', b))] ]
    sg.Window('Buttons with white and black text', keep_on_top=True).Layout(layout2).ReadNonBlocking()