From 03d9c2dde434685d7808e0265ef55b2313571abc Mon Sep 17 00:00:00 2001 From: MikeTheWatchGuy Date: Mon, 25 Feb 2019 12:58:12 -0500 Subject: [PATCH] Initial check-in of a bunch of demo programs --- .../Demo Programs/Web_Color_Names.py | 703 ++++++++++++++++++ .../Demo Programs/Web_Demo_Font_Sizer.py | 29 + .../Demo Programs/Web_Demo_HowDoI.py | 88 +++ .../Web_Desktop_Widget_CPU_Utilization.py | 95 +++ PySimpleGUIWeb/Demo Programs/Web_Timer.py | 8 +- .../Demo Programs/Web_Widget_Summary.py | 45 ++ .../Demo Programs/widgets_overview_app.py | 329 ++++++++ PySimpleGUIWeb/PySimpleGUIWeb.py | 4 +- 8 files changed, 1297 insertions(+), 4 deletions(-) create mode 100644 PySimpleGUIWeb/Demo Programs/Web_Color_Names.py create mode 100644 PySimpleGUIWeb/Demo Programs/Web_Demo_Font_Sizer.py create mode 100644 PySimpleGUIWeb/Demo Programs/Web_Demo_HowDoI.py create mode 100644 PySimpleGUIWeb/Demo Programs/Web_Desktop_Widget_CPU_Utilization.py create mode 100644 PySimpleGUIWeb/Demo Programs/Web_Widget_Summary.py create mode 100644 PySimpleGUIWeb/Demo Programs/widgets_overview_app.py diff --git a/PySimpleGUIWeb/Demo Programs/Web_Color_Names.py b/PySimpleGUIWeb/Demo Programs/Web_Color_Names.py new file mode 100644 index 00000000..22dfb77d --- /dev/null +++ b/PySimpleGUIWeb/Demo Programs/Web_Color_Names.py @@ -0,0 +1,703 @@ +#!/usr/bin/env python +import PySimpleGUIWeb as sg + + +""" + + Shows a big chart of colors... give it a few seconds to create it + Once large window is shown, you can click on any color and another window will popup + showing both white and black text on that color + Uses TOOLTIPS to show the hex values for the colors. Hover over a color and a tooltip will show you the RGB + You will find the list of tkinter colors here: + http://www.tcl.tk/man/tcl8.5/TkCmd/colors.htm + +""" + +color_map = { + 'alice blue': '#F0F8FF', + 'AliceBlue': '#F0F8FF', + 'antique white': '#FAEBD7', + 'AntiqueWhite': '#FAEBD7', + 'AntiqueWhite1': '#FFEFDB', + 'AntiqueWhite2': '#EEDFCC', + 'AntiqueWhite3': '#CDC0B0', + 'AntiqueWhite4': '#8B8378', + 'aquamarine': '#7FFFD4', + 'aquamarine1': '#7FFFD4', + 'aquamarine2': '#76EEC6', + 'aquamarine3': '#66CDAA', + 'aquamarine4': '#458B74', + 'azure': '#F0FFFF', + 'azure1': '#F0FFFF', + 'azure2': '#E0EEEE', + 'azure3': '#C1CDCD', + 'azure4': '#838B8B', + 'beige': '#F5F5DC', + 'bisque': '#FFE4C4', + 'bisque1': '#FFE4C4', + 'bisque2': '#EED5B7', + 'bisque3': '#CDB79E', + 'bisque4': '#8B7D6B', + 'black': '#000000', + 'blanched almond': '#FFEBCD', + 'BlanchedAlmond': '#FFEBCD', + 'blue': '#0000FF', + 'blue violet': '#8A2BE2', + 'blue1': '#0000FF', + 'blue2': '#0000EE', + 'blue3': '#0000CD', + 'blue4': '#00008B', + 'BlueViolet': '#8A2BE2', + 'brown': '#A52A2A', + 'brown1': '#FF4040', + 'brown2': '#EE3B3B', + 'brown3': '#CD3333', + 'brown4': '#8B2323', + 'burlywood': '#DEB887', + 'burlywood1': '#FFD39B', + 'burlywood2': '#EEC591', + 'burlywood3': '#CDAA7D', + 'burlywood4': '#8B7355', + 'cadet blue': '#5F9EA0', + 'CadetBlue': '#5F9EA0', + 'CadetBlue1': '#98F5FF', + 'CadetBlue2': '#8EE5EE', + 'CadetBlue3': '#7AC5CD', + 'CadetBlue4': '#53868B', + 'chartreuse': '#7FFF00', + 'chartreuse1': '#7FFF00', + 'chartreuse2': '#76EE00', + 'chartreuse3': '#66CD00', + 'chartreuse4': '#458B00', + 'chocolate': '#D2691E', + 'chocolate1': '#FF7F24', + 'chocolate2': '#EE7621', + 'chocolate3': '#CD661D', + 'chocolate4': '#8B4513', + 'coral': '#FF7F50', + 'coral1': '#FF7256', + 'coral2': '#EE6A50', + 'coral3': '#CD5B45', + 'coral4': '#8B3E2F', + 'cornflower blue': '#6495ED', + 'CornflowerBlue': '#6495ED', + 'cornsilk': '#FFF8DC', + 'cornsilk1': '#FFF8DC', + 'cornsilk2': '#EEE8CD', + 'cornsilk3': '#CDC8B1', + 'cornsilk4': '#8B8878', + 'cyan': '#00FFFF', + 'cyan1': '#00FFFF', + 'cyan2': '#00EEEE', + 'cyan3': '#00CDCD', + 'cyan4': '#008B8B', + 'dark blue': '#00008B', + 'dark cyan': '#008B8B', + 'dark goldenrod': '#B8860B', + 'dark gray': '#A9A9A9', + 'dark green': '#006400', + 'dark grey': '#A9A9A9', + 'dark khaki': '#BDB76B', + 'dark magenta': '#8B008B', + 'dark olive green': '#556B2F', + 'dark orange': '#FF8C00', + 'dark orchid': '#9932CC', + 'dark red': '#8B0000', + 'dark salmon': '#E9967A', + 'dark sea green': '#8FBC8F', + 'dark slate blue': '#483D8B', + 'dark slate gray': '#2F4F4F', + 'dark slate grey': '#2F4F4F', + 'dark turquoise': '#00CED1', + 'dark violet': '#9400D3', + 'DarkBlue': '#00008B', + 'DarkCyan': '#008B8B', + 'DarkGoldenrod': '#B8860B', + 'DarkGoldenrod1': '#FFB90F', + 'DarkGoldenrod2': '#EEAD0E', + 'DarkGoldenrod3': '#CD950C', + 'DarkGoldenrod4': '#8B6508', + 'DarkGray': '#A9A9A9', + 'DarkGreen': '#006400', + 'DarkGrey': '#A9A9A9', + 'DarkKhaki': '#BDB76B', + 'DarkMagenta': '#8B008B', + 'DarkOliveGreen': '#556B2F', + 'DarkOliveGreen1': '#CAFF70', + 'DarkOliveGreen2': '#BCEE68', + 'DarkOliveGreen3': '#A2CD5A', + 'DarkOliveGreen4': '#6E8B3D', + 'DarkOrange': '#FF8C00', + 'DarkOrange1': '#FF7F00', + 'DarkOrange2': '#EE7600', + 'DarkOrange3': '#CD6600', + 'DarkOrange4': '#8B4500', + 'DarkOrchid': '#9932CC', + 'DarkOrchid1': '#BF3EFF', + 'DarkOrchid2': '#B23AEE', + 'DarkOrchid3': '#9A32CD', + 'DarkOrchid4': '#68228B', + 'DarkRed': '#8B0000', + 'DarkSalmon': '#E9967A', + 'DarkSeaGreen': '#8FBC8F', + 'DarkSeaGreen1': '#C1FFC1', + 'DarkSeaGreen2': '#B4EEB4', + 'DarkSeaGreen3': '#9BCD9B', + 'DarkSeaGreen4': '#698B69', + 'DarkSlateBlue': '#483D8B', + 'DarkSlateGray': '#2F4F4F', + 'DarkSlateGray1': '#97FFFF', + 'DarkSlateGray2': '#8DEEEE', + 'DarkSlateGray3': '#79CDCD', + 'DarkSlateGray4': '#528B8B', + 'DarkSlateGrey': '#2F4F4F', + 'DarkTurquoise': '#00CED1', + 'DarkViolet': '#9400D3', + 'deep pink': '#FF1493', + 'deep sky blue': '#00BFFF', + 'DeepPink': '#FF1493', + 'DeepPink1': '#FF1493', + 'DeepPink2': '#EE1289', + 'DeepPink3': '#CD1076', + 'DeepPink4': '#8B0A50', + 'DeepSkyBlue': '#00BFFF', + 'DeepSkyBlue1': '#00BFFF', + 'DeepSkyBlue2': '#00B2EE', + 'DeepSkyBlue3': '#009ACD', + 'DeepSkyBlue4': '#00688B', + 'dim gray': '#696969', + 'dim grey': '#696969', + 'DimGray': '#696969', + 'DimGrey': '#696969', + 'dodger blue': '#1E90FF', + 'DodgerBlue': '#1E90FF', + 'DodgerBlue1': '#1E90FF', + 'DodgerBlue2': '#1C86EE', + 'DodgerBlue3': '#1874CD', + 'DodgerBlue4': '#104E8B', + 'firebrick': '#B22222', + 'firebrick1': '#FF3030', + 'firebrick2': '#EE2C2C', + 'firebrick3': '#CD2626', + 'firebrick4': '#8B1A1A', + 'floral white': '#FFFAF0', + 'FloralWhite': '#FFFAF0', + 'forest green': '#228B22', + 'ForestGreen': '#228B22', + 'gainsboro': '#DCDCDC', + 'ghost white': '#F8F8FF', + 'GhostWhite': '#F8F8FF', + 'gold': '#FFD700', + 'gold1': '#FFD700', + 'gold2': '#EEC900', + 'gold3': '#CDAD00', + 'gold4': '#8B7500', + 'goldenrod': '#DAA520', + 'goldenrod1': '#FFC125', + 'goldenrod2': '#EEB422', + 'goldenrod3': '#CD9B1D', + 'goldenrod4': '#8B6914', + 'green': '#00FF00', + 'green yellow': '#ADFF2F', + 'green1': '#00FF00', + 'green2': '#00EE00', + 'green3': '#00CD00', + 'green4': '#008B00', + 'GreenYellow': '#ADFF2F', + 'grey': '#BEBEBE', + 'grey0': '#000000', + 'grey1': '#030303', + 'grey2': '#050505', + 'grey3': '#080808', + 'grey4': '#0A0A0A', + 'grey5': '#0D0D0D', + 'grey6': '#0F0F0F', + 'grey7': '#121212', + 'grey8': '#141414', + 'grey9': '#171717', + 'grey10': '#1A1A1A', + 'grey11': '#1C1C1C', + 'grey12': '#1F1F1F', + 'grey13': '#212121', + 'grey14': '#242424', + 'grey15': '#262626', + 'grey16': '#292929', + 'grey17': '#2B2B2B', + 'grey18': '#2E2E2E', + 'grey19': '#303030', + 'grey20': '#333333', + 'grey21': '#363636', + 'grey22': '#383838', + 'grey23': '#3B3B3B', + 'grey24': '#3D3D3D', + 'grey25': '#404040', + 'grey26': '#424242', + 'grey27': '#454545', + 'grey28': '#474747', + 'grey29': '#4A4A4A', + 'grey30': '#4D4D4D', + 'grey31': '#4F4F4F', + 'grey32': '#525252', + 'grey33': '#545454', + 'grey34': '#575757', + 'grey35': '#595959', + 'grey36': '#5C5C5C', + 'grey37': '#5E5E5E', + 'grey38': '#616161', + 'grey39': '#636363', + 'grey40': '#666666', + 'grey41': '#696969', + 'grey42': '#6B6B6B', + 'grey43': '#6E6E6E', + 'grey44': '#707070', + 'grey45': '#737373', + 'grey46': '#757575', + 'grey47': '#787878', + 'grey48': '#7A7A7A', + 'grey49': '#7D7D7D', + 'grey50': '#7F7F7F', + 'grey51': '#828282', + 'grey52': '#858585', + 'grey53': '#878787', + 'grey54': '#8A8A8A', + 'grey55': '#8C8C8C', + 'grey56': '#8F8F8F', + 'grey57': '#919191', + 'grey58': '#949494', + 'grey59': '#969696', + 'grey60': '#999999', + 'grey61': '#9C9C9C', + 'grey62': '#9E9E9E', + 'grey63': '#A1A1A1', + 'grey64': '#A3A3A3', + 'grey65': '#A6A6A6', + 'grey66': '#A8A8A8', + 'grey67': '#ABABAB', + 'grey68': '#ADADAD', + 'grey69': '#B0B0B0', + 'grey70': '#B3B3B3', + 'grey71': '#B5B5B5', + 'grey72': '#B8B8B8', + 'grey73': '#BABABA', + 'grey74': '#BDBDBD', + 'grey75': '#BFBFBF', + 'grey76': '#C2C2C2', + 'grey77': '#C4C4C4', + 'grey78': '#C7C7C7', + 'grey79': '#C9C9C9', + 'grey80': '#CCCCCC', + 'grey81': '#CFCFCF', + 'grey82': '#D1D1D1', + 'grey83': '#D4D4D4', + 'grey84': '#D6D6D6', + 'grey85': '#D9D9D9', + 'grey86': '#DBDBDB', + 'grey87': '#DEDEDE', + 'grey88': '#E0E0E0', + 'grey89': '#E3E3E3', + 'grey90': '#E5E5E5', + 'grey91': '#E8E8E8', + 'grey92': '#EBEBEB', + 'grey93': '#EDEDED', + 'grey94': '#F0F0F0', + 'grey95': '#F2F2F2', + 'grey96': '#F5F5F5', + 'grey97': '#F7F7F7', + 'grey98': '#FAFAFA', + 'grey99': '#FCFCFC', + 'grey100': '#FFFFFF', + 'honeydew': '#F0FFF0', + 'honeydew1': '#F0FFF0', + 'honeydew2': '#E0EEE0', + 'honeydew3': '#C1CDC1', + 'honeydew4': '#838B83', + 'hot pink': '#FF69B4', + 'HotPink': '#FF69B4', + 'HotPink1': '#FF6EB4', + 'HotPink2': '#EE6AA7', + 'HotPink3': '#CD6090', + 'HotPink4': '#8B3A62', + 'indian red': '#CD5C5C', + 'IndianRed': '#CD5C5C', + 'IndianRed1': '#FF6A6A', + 'IndianRed2': '#EE6363', + 'IndianRed3': '#CD5555', + 'IndianRed4': '#8B3A3A', + 'ivory': '#FFFFF0', + 'ivory1': '#FFFFF0', + 'ivory2': '#EEEEE0', + 'ivory3': '#CDCDC1', + 'ivory4': '#8B8B83', + 'khaki': '#F0E68C', + 'khaki1': '#FFF68F', + 'khaki2': '#EEE685', + 'khaki3': '#CDC673', + 'khaki4': '#8B864E', + 'lavender': '#E6E6FA', + 'lavender blush': '#FFF0F5', + 'LavenderBlush': '#FFF0F5', + 'LavenderBlush1': '#FFF0F5', + 'LavenderBlush2': '#EEE0E5', + 'LavenderBlush3': '#CDC1C5', + 'LavenderBlush4': '#8B8386', + 'lawn green': '#7CFC00', + 'LawnGreen': '#7CFC00', + 'lemon chiffon': '#FFFACD', + 'LemonChiffon': '#FFFACD', + 'LemonChiffon1': '#FFFACD', + 'LemonChiffon2': '#EEE9BF', + 'LemonChiffon3': '#CDC9A5', + 'LemonChiffon4': '#8B8970', + 'light blue': '#ADD8E6', + 'light coral': '#F08080', + 'light cyan': '#E0FFFF', + 'light goldenrod': '#EEDD82', + 'light goldenrod yellow': '#FAFAD2', + 'light gray': '#D3D3D3', + 'light green': '#90EE90', + 'light grey': '#D3D3D3', + 'light pink': '#FFB6C1', + 'light salmon': '#FFA07A', + 'light sea green': '#20B2AA', + 'light sky blue': '#87CEFA', + 'light slate blue': '#8470FF', + 'light slate gray': '#778899', + 'light slate grey': '#778899', + 'light steel blue': '#B0C4DE', + 'light yellow': '#FFFFE0', + 'LightBlue': '#ADD8E6', + 'LightBlue1': '#BFEFFF', + 'LightBlue2': '#B2DFEE', + 'LightBlue3': '#9AC0CD', + 'LightBlue4': '#68838B', + 'LightCoral': '#F08080', + 'LightCyan': '#E0FFFF', + 'LightCyan1': '#E0FFFF', + 'LightCyan2': '#D1EEEE', + 'LightCyan3': '#B4CDCD', + 'LightCyan4': '#7A8B8B', + 'LightGoldenrod': '#EEDD82', + 'LightGoldenrod1': '#FFEC8B', + 'LightGoldenrod2': '#EEDC82', + 'LightGoldenrod3': '#CDBE70', + 'LightGoldenrod4': '#8B814C', + 'LightGoldenrodYellow': '#FAFAD2', + 'LightGray': '#D3D3D3', + 'LightGreen': '#90EE90', + 'LightGrey': '#D3D3D3', + 'LightPink': '#FFB6C1', + 'LightPink1': '#FFAEB9', + 'LightPink2': '#EEA2AD', + 'LightPink3': '#CD8C95', + 'LightPink4': '#8B5F65', + 'LightSalmon': '#FFA07A', + 'LightSalmon1': '#FFA07A', + 'LightSalmon2': '#EE9572', + 'LightSalmon3': '#CD8162', + 'LightSalmon4': '#8B5742', + 'LightSeaGreen': '#20B2AA', + 'LightSkyBlue': '#87CEFA', + 'LightSkyBlue1': '#B0E2FF', + 'LightSkyBlue2': '#A4D3EE', + 'LightSkyBlue3': '#8DB6CD', + 'LightSkyBlue4': '#607B8B', + 'LightSlateBlue': '#8470FF', + 'LightSlateGray': '#778899', + 'LightSlateGrey': '#778899', + 'LightSteelBlue': '#B0C4DE', + 'LightSteelBlue1': '#CAE1FF', + 'LightSteelBlue2': '#BCD2EE', + 'LightSteelBlue3': '#A2B5CD', + 'LightSteelBlue4': '#6E7B8B', + 'LightYellow': '#FFFFE0', + 'LightYellow1': '#FFFFE0', + 'LightYellow2': '#EEEED1', + 'LightYellow3': '#CDCDB4', + 'LightYellow4': '#8B8B7A', + 'lime green': '#32CD32', + 'LimeGreen': '#32CD32', + 'linen': '#FAF0E6', + 'magenta': '#FF00FF', + 'magenta1': '#FF00FF', + 'magenta2': '#EE00EE', + 'magenta3': '#CD00CD', + 'magenta4': '#8B008B', + 'maroon': '#B03060', + 'maroon1': '#FF34B3', + 'maroon2': '#EE30A7', + 'maroon3': '#CD2990', + 'maroon4': '#8B1C62', + 'medium aquamarine': '#66CDAA', + 'medium blue': '#0000CD', + 'medium orchid': '#BA55D3', + 'medium purple': '#9370DB', + 'medium sea green': '#3CB371', + 'medium slate blue': '#7B68EE', + 'medium spring green': '#00FA9A', + 'medium turquoise': '#48D1CC', + 'medium violet red': '#C71585', + 'MediumAquamarine': '#66CDAA', + 'MediumBlue': '#0000CD', + 'MediumOrchid': '#BA55D3', + 'MediumOrchid1': '#E066FF', + 'MediumOrchid2': '#D15FEE', + 'MediumOrchid3': '#B452CD', + 'MediumOrchid4': '#7A378B', + 'MediumPurple': '#9370DB', + 'MediumPurple1': '#AB82FF', + 'MediumPurple2': '#9F79EE', + 'MediumPurple3': '#8968CD', + 'MediumPurple4': '#5D478B', + 'MediumSeaGreen': '#3CB371', + 'MediumSlateBlue': '#7B68EE', + 'MediumSpringGreen': '#00FA9A', + 'MediumTurquoise': '#48D1CC', + 'MediumVioletRed': '#C71585', + 'midnight blue': '#191970', + 'MidnightBlue': '#191970', + 'mint cream': '#F5FFFA', + 'MintCream': '#F5FFFA', + 'misty rose': '#FFE4E1', + 'MistyRose': '#FFE4E1', + 'MistyRose1': '#FFE4E1', + 'MistyRose2': '#EED5D2', + 'MistyRose3': '#CDB7B5', + 'MistyRose4': '#8B7D7B', + 'moccasin': '#FFE4B5', + 'navajo white': '#FFDEAD', + 'NavajoWhite': '#FFDEAD', + 'NavajoWhite1': '#FFDEAD', + 'NavajoWhite2': '#EECFA1', + 'NavajoWhite3': '#CDB38B', + 'NavajoWhite4': '#8B795E', + 'navy': '#000080', + 'navy blue': '#000080', + 'NavyBlue': '#000080', + 'old lace': '#FDF5E6', + 'OldLace': '#FDF5E6', + 'olive drab': '#6B8E23', + 'OliveDrab': '#6B8E23', + 'OliveDrab1': '#C0FF3E', + 'OliveDrab2': '#B3EE3A', + 'OliveDrab3': '#9ACD32', + 'OliveDrab4': '#698B22', + 'orange': '#FFA500', + 'orange red': '#FF4500', + 'orange1': '#FFA500', + 'orange2': '#EE9A00', + 'orange3': '#CD8500', + 'orange4': '#8B5A00', + 'OrangeRed': '#FF4500', + 'OrangeRed1': '#FF4500', + 'OrangeRed2': '#EE4000', + 'OrangeRed3': '#CD3700', + 'OrangeRed4': '#8B2500', + 'orchid': '#DA70D6', + 'orchid1': '#FF83FA', + 'orchid2': '#EE7AE9', + 'orchid3': '#CD69C9', + 'orchid4': '#8B4789', + 'pale goldenrod': '#EEE8AA', + 'pale green': '#98FB98', + 'pale turquoise': '#AFEEEE', + 'pale violet red': '#DB7093', + 'PaleGoldenrod': '#EEE8AA', + 'PaleGreen': '#98FB98', + 'PaleGreen1': '#9AFF9A', + 'PaleGreen2': '#90EE90', + 'PaleGreen3': '#7CCD7C', + 'PaleGreen4': '#548B54', + 'PaleTurquoise': '#AFEEEE', + 'PaleTurquoise1': '#BBFFFF', + 'PaleTurquoise2': '#AEEEEE', + 'PaleTurquoise3': '#96CDCD', + 'PaleTurquoise4': '#668B8B', + 'PaleVioletRed': '#DB7093', + 'PaleVioletRed1': '#FF82AB', + 'PaleVioletRed2': '#EE799F', + 'PaleVioletRed3': '#CD687F', + 'PaleVioletRed4': '#8B475D', + 'papaya whip': '#FFEFD5', + 'PapayaWhip': '#FFEFD5', + 'peach puff': '#FFDAB9', + 'PeachPuff': '#FFDAB9', + 'PeachPuff1': '#FFDAB9', + 'PeachPuff2': '#EECBAD', + 'PeachPuff3': '#CDAF95', + 'PeachPuff4': '#8B7765', + 'peru': '#CD853F', + 'pink': '#FFC0CB', + 'pink1': '#FFB5C5', + 'pink2': '#EEA9B8', + 'pink3': '#CD919E', + 'pink4': '#8B636C', + 'plum': '#DDA0DD', + 'plum1': '#FFBBFF', + 'plum2': '#EEAEEE', + 'plum3': '#CD96CD', + 'plum4': '#8B668B', + 'powder blue': '#B0E0E6', + 'PowderBlue': '#B0E0E6', + 'purple': '#A020F0', + 'purple1': '#9B30FF', + 'purple2': '#912CEE', + 'purple3': '#7D26CD', + 'purple4': '#551A8B', + 'red': '#FF0000', + 'red1': '#FF0000', + 'red2': '#EE0000', + 'red3': '#CD0000', + 'red4': '#8B0000', + 'rosy brown': '#BC8F8F', + 'RosyBrown': '#BC8F8F', + 'RosyBrown1': '#FFC1C1', + 'RosyBrown2': '#EEB4B4', + 'RosyBrown3': '#CD9B9B', + 'RosyBrown4': '#8B6969', + 'royal blue': '#4169E1', + 'RoyalBlue': '#4169E1', + 'RoyalBlue1': '#4876FF', + 'RoyalBlue2': '#436EEE', + 'RoyalBlue3': '#3A5FCD', + 'RoyalBlue4': '#27408B', + 'saddle brown': '#8B4513', + 'SaddleBrown': '#8B4513', + 'salmon': '#FA8072', + 'salmon1': '#FF8C69', + 'salmon2': '#EE8262', + 'salmon3': '#CD7054', + 'salmon4': '#8B4C39', + 'sandy brown': '#F4A460', + 'SandyBrown': '#F4A460', + 'sea green': '#2E8B57', + 'SeaGreen': '#2E8B57', + 'SeaGreen1': '#54FF9F', + 'SeaGreen2': '#4EEE94', + 'SeaGreen3': '#43CD80', + 'SeaGreen4': '#2E8B57', + 'seashell': '#FFF5EE', + 'seashell1': '#FFF5EE', + 'seashell2': '#EEE5DE', + 'seashell3': '#CDC5BF', + 'seashell4': '#8B8682', + 'sienna': '#A0522D', + 'sienna1': '#FF8247', + 'sienna2': '#EE7942', + 'sienna3': '#CD6839', + 'sienna4': '#8B4726', + 'sky blue': '#87CEEB', + 'SkyBlue': '#87CEEB', + 'SkyBlue1': '#87CEFF', + 'SkyBlue2': '#7EC0EE', + 'SkyBlue3': '#6CA6CD', + 'SkyBlue4': '#4A708B', + 'slate blue': '#6A5ACD', + 'slate gray': '#708090', + 'slate grey': '#708090', + 'SlateBlue': '#6A5ACD', + 'SlateBlue1': '#836FFF', + 'SlateBlue2': '#7A67EE', + 'SlateBlue3': '#6959CD', + 'SlateBlue4': '#473C8B', + 'SlateGray': '#708090', + 'SlateGray1': '#C6E2FF', + 'SlateGray2': '#B9D3EE', + 'SlateGray3': '#9FB6CD', + 'SlateGray4': '#6C7B8B', + 'SlateGrey': '#708090', + 'snow': '#FFFAFA', + 'snow1': '#FFFAFA', + 'snow2': '#EEE9E9', + 'snow3': '#CDC9C9', + 'snow4': '#8B8989', + 'spring green': '#00FF7F', + 'SpringGreen': '#00FF7F', + 'SpringGreen1': '#00FF7F', + 'SpringGreen2': '#00EE76', + 'SpringGreen3': '#00CD66', + 'SpringGreen4': '#008B45', + 'steel blue': '#4682B4', + 'SteelBlue': '#4682B4', + 'SteelBlue1': '#63B8FF', + 'SteelBlue2': '#5CACEE', + 'SteelBlue3': '#4F94CD', + 'SteelBlue4': '#36648B', + 'tan': '#D2B48C', + 'tan1': '#FFA54F', + 'tan2': '#EE9A49', + 'tan3': '#CD853F', + 'tan4': '#8B5A2B', + 'thistle': '#D8BFD8', + 'thistle1': '#FFE1FF', + 'thistle2': '#EED2EE', + 'thistle3': '#CDB5CD', + 'thistle4': '#8B7B8B', + 'tomato': '#FF6347', + 'tomato1': '#FF6347', + 'tomato2': '#EE5C42', + 'tomato3': '#CD4F39', + 'tomato4': '#8B3626', + 'turquoise': '#40E0D0', + 'turquoise1': '#00F5FF', + 'turquoise2': '#00E5EE', + 'turquoise3': '#00C5CD', + 'turquoise4': '#00868B', + 'violet': '#EE82EE', + 'violet red': '#D02090', + 'VioletRed': '#D02090', + 'VioletRed1': '#FF3E96', + 'VioletRed2': '#EE3A8C', + 'VioletRed3': '#CD3278', + 'VioletRed4': '#8B2252', + 'wheat': '#F5DEB3', + 'wheat1': '#FFE7BA', + 'wheat2': '#EED8AE', + 'wheat3': '#CDBA96', + 'wheat4': '#8B7E66', + 'white': '#FFFFFF', + 'white smoke': '#F5F5F5', + 'WhiteSmoke': '#F5F5F5', + 'yellow': '#FFFF00', + 'yellow green': '#9ACD32', + 'yellow1': '#FFFF00', + 'yellow2': '#EEEE00', + 'yellow3': '#CDCD00', + 'yellow4': '#8B8B00', + 'YellowGreen': '#9ACD32', +} + + + +sg.SetOptions(button_element_size=(16,1), auto_size_buttons=False, border_width=0, tooltip_time=100) + +#start layout with the tittle +layout = [[sg.Text('Hover mouse to see RGB value', + text_color='blue', + font=('Hevletica', 20), + relief=sg.RELIEF_SUNKEN, + justification='center', + size=(90,2), + background_color='#90EE90', + pad=(0,0)),]] + +# -- Create primary color viewer window by building rows and appending to layout -- +color_list = [key for key in color_map] +for rows in range(40): + row = [] + for i in range(12): + try: + color = color_list[rows+40*i] + row.append(sg.Button(color, button_color=('black', color_map[color]), key=color, tooltip=color_map[color]),) + except: + pass + layout.append(row) + +window = sg.Window('Color Viewer', font=('any 12'), default_button_element_size=(12,1), element_padding=(0,0)).Layout(layout) + +# -- Event loop -- +while True: + event, values = window.Read() + if event is None: + break + +window.Close() \ No newline at end of file diff --git a/PySimpleGUIWeb/Demo Programs/Web_Demo_Font_Sizer.py b/PySimpleGUIWeb/Demo Programs/Web_Demo_Font_Sizer.py new file mode 100644 index 00000000..26d4d88d --- /dev/null +++ b/PySimpleGUIWeb/Demo Programs/Web_Demo_Font_Sizer.py @@ -0,0 +1,29 @@ +import PySimpleGUIWeb as sg + +""" +Simple Demo that shows how Elements can effect other elements in the Window +In this case, the slider controls the size of the text font and the value shown in the spinner +Additionally, if the spinner is changed, the text size is changed and so is the slider +In other words, the slider and the spinner are essentially connected together +""" + +fontsize = 12 # initial and smallest font size to show + +layout = [[sg.Spin([sz for sz in range(6, 172)], size=(6,1), font=('Helvetica 20'), initial_value=fontsize, change_submits=True, key='spin'), + sg.Slider(range=(6,172), orientation='h', size=(10,20), change_submits=True, key='slider', font=('Helvetica 20')), + sg.Text("Aa", size=(2, 1), font="Helvetica " + str(fontsize), key='text')],] + +window = sg.Window("Font size selector").Layout(layout) + +while True: # the event loop + event, values= window.Read() + if event is None or event == 'Quit': + break + fontsize = int(values['spin']) if int(values['spin']) != fontsize else int(values['slider']) + font = "Helvetica " + str(fontsize) + window.FindElement('text').Update(font=font) + window.FindElement('slider').Update(fontsize, range=(10,20)) + window.FindElement('spin').Update(fontsize) +window.Close() + +print("Done.") diff --git a/PySimpleGUIWeb/Demo Programs/Web_Demo_HowDoI.py b/PySimpleGUIWeb/Demo Programs/Web_Demo_HowDoI.py new file mode 100644 index 00000000..0fc0a0f0 --- /dev/null +++ b/PySimpleGUIWeb/Demo Programs/Web_Demo_HowDoI.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python +import sys +import PySimpleGUIWeb as sg +import subprocess +import howdoi + + +# Test this command in a dos window if you are having trouble. +HOW_DO_I_COMMAND = 'python -m howdoi.howdoi' + +# if you want an icon on your taskbar for this gui, then change this line of code to point to the ICO file +DEFAULT_ICON = 'E:\\TheRealMyDocs\\Icons\\QuestionMark.ico' + +def HowDoI(): + ''' + Make and show a window (PySimpleGUI form) that takes user input and sends to the HowDoI web oracle + Excellent example of 2 GUI concepts + 1. Output Element that will show text in a scrolled window + 2. Non-Window-Closing Buttons - These buttons will cause the form to return with the form's values, but doesn't close the form + :return: never returns + ''' + # ------- Make a new Window ------- # + sg.ChangeLookAndFeel('GreenTan') # give our form a spiffy set of colors + + layout = [ + [sg.Text('Ask and your answer will appear here....', size=(40, 1))], + [sg.MultilineOutput(size_px=(980, 400),key='_OUTPUT_' )], + # [ sg.Spin(values=(1, 2, 3, 4), initial_value=1, size=(2, 1), key='Num Answers', font='Helvetica 15'), + [ sg.Checkbox('Display Full Text', key='full text', font='Helvetica 15'), + sg.T('Command History', font='Helvetica 15'), sg.T('', size=(40,3), text_color=sg.BLUES[0], key='history')], + [sg.Multiline(size=(85, 5), enter_submits=True, key='query', do_not_clear=False), + sg.ReadButton('SEND', button_color=(sg.YELLOWS[0], sg.BLUES[0]), bind_return_key=True), + sg.Button('EXIT', button_color=(sg.YELLOWS[0], sg.GREENS[0]))] + ] + + window = sg.Window('How Do I ??', default_element_size=(30,1), icon=DEFAULT_ICON, font=('Helvetica',' 17'), default_button_element_size=(8,2), return_keyboard_events=False, ) + window.Layout(layout) + # ---===--- Loop taking in user input and using it to query HowDoI --- # + command_history = [] + history_offset = 0 + while True: + event, values = window.Read() + # print(event, values) + if type(event) is int: + event = str(event) + if event == 'SEND': + query = values['query'].rstrip() + window.Element('_OUTPUT_').Update(query, append=True) + print(query) + QueryHowDoI(query, 1, values['full text'], window) # send the string to HowDoI + command_history.append(query) + history_offset = len(command_history)-1 + window.FindElement('query').Update('') # manually clear input because keyboard events blocks clear + window.FindElement('history').Update('\n'.join(command_history[-3:])) + elif event == None or event == 'EXIT': # if exit button or closed using X + break + elif 'Up' in event and len(command_history): # scroll back in history + command = command_history[history_offset] + history_offset -= 1 * (history_offset > 0) # decrement is not zero + window.FindElement('query').Update(command) + elif 'Down' in event and len(command_history): # scroll forward in history + history_offset += 1 * (history_offset < len(command_history)-1) # increment up to end of list + command = command_history[history_offset] + window.FindElement('query').Update(command) + elif 'Escape' in event: # clear currently line + window.FindElement('query').Update('') + + window.Close() + +def QueryHowDoI(Query, num_answers, full_text, window:sg.Window): + ''' + Kicks off a subprocess to send the 'Query' to HowDoI + Prints the result, which in this program will route to a gooeyGUI window + :param Query: text english question to ask the HowDoI web engine + :return: nothing + ''' + howdoi_command = HOW_DO_I_COMMAND + full_text_option = ' -a' if full_text else '' + t = subprocess.Popen(howdoi_command + ' \"'+ Query + '\" -n ' + str(num_answers)+full_text_option, stdout=subprocess.PIPE) + (output, err) = t.communicate() + window.Element('_OUTPUT_').Update('{:^88}'.format(Query.rstrip()), append=True) + window.Element('_OUTPUT_').Update('_'*60, append=True) + window.Element('_OUTPUT_').Update(output.decode("utf-8"), append=True) + exit_code = t.wait() + +if __name__ == '__main__': + HowDoI() + diff --git a/PySimpleGUIWeb/Demo Programs/Web_Desktop_Widget_CPU_Utilization.py b/PySimpleGUIWeb/Demo Programs/Web_Desktop_Widget_CPU_Utilization.py new file mode 100644 index 00000000..659b3af2 --- /dev/null +++ b/PySimpleGUIWeb/Demo Programs/Web_Desktop_Widget_CPU_Utilization.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python +import sys +import sys +import PySimpleGUIWeb as sg +import psutil +import time +from threading import Thread +import operator + + +""" + PSUTIL Desktop Widget + Creates a floating CPU utilization window that is always on top of other windows + You move it by grabbing anywhere on the window + Good example of how to do a non-blocking, polling program using PySimpleGUI + Use the spinner to adjust the number of seconds between readings of the CPU utilizaiton + + NOTE - you will get a warning message printed when you exit using exit button. + It will look something like: + invalid command name "1616802625480StopMove" +""" + +# globale used to communicate with thread.. yea yea... it's working fine +g_interval = 1 +g_cpu_percent = 0 +g_procs = None +g_exit = False + +def CPU_thread(args): + global g_interval, g_cpu_percent, g_procs, g_exit + + while not g_exit: + try: + g_cpu_percent = psutil.cpu_percent(interval=g_interval) + g_procs = psutil.process_iter() + except: + pass + + +def main(): + global g_interval, g_procs, g_exit + + # ---------------- Create Form ---------------- + sg.ChangeLookAndFeel('Black') + layout = [[sg.Text('', size=(8,1), font=('Helvetica', 20),text_color=sg.YELLOWS[0], + justification='center', key='text')], + [sg.Text('', size=(30, 8), font=('Courier New', 12),text_color='white', justification='left', key='processes')], + [sg.Exit(button_color=('white', 'firebrick4'), pad=((15,0), 0), size=(9,1)),] + ] + + window = sg.Window('CPU Utilization', + no_titlebar=True, + keep_on_top=True, + alpha_channel=.8, + grab_anywhere=True).Layout(layout) + + # start cpu measurement thread + thread = Thread(target=CPU_thread,args=(None,), daemon=True) + thread.start() + timeout_value = 1 # make first read really quick + g_interval = 1 + # ---------------- main loop ---------------- + while (True): + # --------- Read and update window -------- + event, values = window.Read(timeout=timeout_value, timeout_key='Timeout') + # --------- Do Button Operations -------- + if event is None or event == 'Exit': + break + + timeout_value = 1000 + + cpu_percent = g_cpu_percent + display_string = '' + if g_procs: + # --------- Create list of top % CPU porocesses -------- + try: + top = {proc.name() : proc.cpu_percent() for proc in g_procs} + except: pass + + + top_sorted = sorted(top.items(), key=operator.itemgetter(1), reverse=True) + if top_sorted: + top_sorted.pop(0) + display_string = '' + for proc, cpu in top_sorted: + display_string += '{:2.2f} {}\n'.format(cpu/10, proc) + + # --------- Display timer and proceses in window -------- + window.FindElement('text').Update('CPU {}'.format(cpu_percent)) + window.FindElement('processes').Update(display_string) + + window.Close() + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/PySimpleGUIWeb/Demo Programs/Web_Timer.py b/PySimpleGUIWeb/Demo Programs/Web_Timer.py index ff342585..17c82450 100644 --- a/PySimpleGUIWeb/Demo Programs/Web_Timer.py +++ b/PySimpleGUIWeb/Demo Programs/Web_Timer.py @@ -1,15 +1,16 @@ #!/usr/bin/env python import PySimpleGUIWeb as sg import time +import sys # ---------------- Create Form ---------------- layout = [ [sg.Text('', background_color='black')], - [sg.Text('test', size=(20, 1), font=('Helvetica', 30), justification='center', text_color='white', key='text', background_color='black')], + [sg.Text('00:00', size=(30, 1), font=('Helvetica', 30), justification='center', text_color='white', key='text', background_color='black')], [sg.Text('', background_color='black')], [sg.Button('Pause', key='button', button_color=('white', '#001480')), sg.Button('Reset', button_color=('white', '#007339'), key='Reset'), - sg.Exit(button_color=('white', '#8B1A1A'), key='Exit')] + sg.Exit(button_color=('white', '#8B1A1A'), key='Exit', )], ] window = sg.Window('Running Timer', background_color='black', font='Helvetica 18').Layout(layout) @@ -25,6 +26,7 @@ while (True): current_time = int(round(time.time() * 100)) - start_time else: event, values = window.Read() + print(event, values) if event != sg.TIMEOUT_KEY else None if event == 'button': event = window.FindElement(event).GetText() # --------- Do Button Operations -------- @@ -51,3 +53,5 @@ while (True): current_time % 100)) # --------- After loop -------- window.Close() +print('after loop') +sys.exit() \ No newline at end of file diff --git a/PySimpleGUIWeb/Demo Programs/Web_Widget_Summary.py b/PySimpleGUIWeb/Demo Programs/Web_Widget_Summary.py new file mode 100644 index 00000000..88b63ec5 --- /dev/null +++ b/PySimpleGUIWeb/Demo Programs/Web_Widget_Summary.py @@ -0,0 +1,45 @@ +import PySimpleGUIWeb as sg +import datetime + +DEFAULT_BASE64_ICON = b'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' + + +sg.ChangeLookAndFeel('GreenTan') + +layout = [ + [sg.Text('PySimpleGUIWeb running on the web and in your browser!', size=(60,1), font=('Comic sans ms', 20), text_color='red')], + [sg.Text('This program has been running for... ', size=(30,1)),sg.Text('', size=(30,1), key='_DATE_')], + [sg.Text('', size=(30,1), key='_TEXT_')], + [sg.Input('Single Line Input', do_not_clear=True, enable_events=True, size=(30,1))], + [sg.Multiline('Multiline Input', do_not_clear=True, size=(40,4), enable_events=True)], + [sg.Multiline('Multiline Output', size=(80,8), key='_MULTIOUT_', font='Courier 12')], + [sg.Checkbox('Checkbox 1', enable_events=True, key='_CB1_'), sg.Checkbox('Checkbox 2', default=True, enable_events=True, key='_CB2_')], + [sg.Combo(values=['Combo 1', 'Combo 2', 'Combo 3'], default_value='Combo 2', key='_COMBO_',enable_events=True, readonly=False, tooltip='Combo box', disabled=False, size=(12,1))], + [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(10,3))], + [sg.Slider((1,100), default_value=80, key='_SLIDER_', visible=True, enable_events=True, orientation='h')], + [sg.Spin(values=(1,2,3),initial_value=2, size=(4,1))], + [sg.Image(filename=r'dot:logo.jpg')], + [sg.OK(), sg.Button('Exit', button_color=('white', 'red'))] + ] + +window = sg.Window('My PySimpleGUIWeb Window', + default_element_size=(30,1), + font='Helvetica 18', + background_image=r'dot:logo.jpg' + ).Layout(layout) + +start_time = datetime.datetime.now() +while True: + event, values = window.Read(timeout=10) + if event != sg.TIMEOUT_KEY: + print(event, values) + window.Element('_MULTIOUT_').Update(str(event) + '\n' + str(values), append=True) + if event in (None, 'Exit'): + break + window.Element('_DATE_').Update(str(datetime.datetime.now()-start_time)) + +window.Close() + + + + diff --git a/PySimpleGUIWeb/Demo Programs/widgets_overview_app.py b/PySimpleGUIWeb/Demo Programs/widgets_overview_app.py new file mode 100644 index 00000000..d5b388df --- /dev/null +++ b/PySimpleGUIWeb/Demo Programs/widgets_overview_app.py @@ -0,0 +1,329 @@ +""" + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +""" + +import remi.gui as gui +from remi import start, App +from threading import Timer + + +class MyApp(App): + def __init__(self, *args): + super(MyApp, self).__init__(*args) + + def idle(self): + self.counter.set_text('Running Time: ' + str(self.count)) + self.progress.set_value(self.count%100) + + def main(self): + # the margin 0px auto centers the main container + verticalContainer = gui.Widget(width=540, margin='0px auto', style={'display': 'block', 'overflow': 'hidden'}) + + horizontalContainer = gui.Widget(width='100%', layout_orientation=gui.Widget.LAYOUT_HORIZONTAL, margin='0px', style={'display': 'block', 'overflow': 'auto'}) + + subContainerLeft = gui.Widget(width=320, style={'display': 'block', 'overflow': 'auto', 'text-align': 'center'}) + self.img = gui.Image('/res:logo.png', height=100, margin='10px') + self.img.onclick.connect(self.on_img_clicked) + + self.table = gui.Table.new_from_list([('ID', 'First Name', 'Last Name'), + ('101', 'Danny', 'Young'), + ('102', 'Christine', 'Holand'), + ('103', 'Lars', 'Gordon'), + ('104', 'Roberto', 'Robitaille'), + ('105', 'Maria', 'Papadopoulos')], width=300, height=200, margin='10px') + self.table.on_table_row_click.connect(self.on_table_row_click) + + # the arguments are width - height - layoutOrientationOrizontal + subContainerRight = gui.Widget(style={'width': '220px', 'display': 'block', 'overflow': 'auto', 'text-align': 'center'}) + self.count = 0 + self.counter = gui.Label('', width=200, height=30, margin='10px') + + self.lbl = gui.Label('This is a LABEL!', width=200, height=30, margin='10px') + + self.bt = gui.Button('Press me!', width=200, height=30, margin='10px') + # setting the listener for the onclick event of the button + self.bt.onclick.connect(self.on_button_pressed) + + self.txt = gui.TextInput(width=200, height=30, margin='10px') + self.txt.set_text('This is a TEXTAREA') + self.txt.onchange.connect(self.on_text_area_change) + + self.spin = gui.SpinBox(1, 0, 100, width=200, height=30, margin='10px') + self.spin.onchange.connect(self.on_spin_change) + + self.progress = gui.Progress(1, 100, width=200, height=5) + + self.check = gui.CheckBoxLabel('Label checkbox', True, width=200, height=30, margin='10px') + self.check.onchange.connect(self.on_check_change) + + self.btInputDiag = gui.Button('Open InputDialog', width=200, height=30, margin='10px') + self.btInputDiag.onclick.connect(self.open_input_dialog) + + self.btFileDiag = gui.Button('File Selection Dialog', width=200, height=30, margin='10px') + self.btFileDiag.onclick.connect(self.open_fileselection_dialog) + + self.btUploadFile = gui.FileUploader('./', width=200, height=30, margin='10px') + self.btUploadFile.onsuccess.connect(self.fileupload_on_success) + self.btUploadFile.onfailed.connect(self.fileupload_on_failed) + + items = ('Danny Young','Christine Holand','Lars Gordon','Roberto Robitaille') + self.listView = gui.ListView.new_from_list(items, width=300, height=120, margin='10px') + self.listView.onselection.connect(self.list_view_on_selected) + + self.link = gui.Link("http://localhost:8081", "A link to here", width=200, height=30, margin='10px') + + self.dropDown = gui.DropDown.new_from_list(('DropDownItem 0', 'DropDownItem 1'), + width=200, height=20, margin='10px') + self.dropDown.onchange.connect(self.drop_down_changed) + self.dropDown.select_by_value('DropDownItem 0') + + self.slider = gui.Slider(10, 0, 100, 5, width=200, height=20, margin='10px') + self.slider.onchange.connect(self.slider_changed) + + self.colorPicker = gui.ColorPicker('#ffbb00', width=200, height=20, margin='10px') + self.colorPicker.onchange.connect(self.color_picker_changed) + + self.date = gui.Date('2015-04-13', width=200, height=20, margin='10px') + self.date.onchange.connect(self.date_changed) + + self.video = gui.Widget( _type='iframe', width=290, height=200, margin='10px') + self.video.attributes['src'] = "https://drive.google.com/file/d/0B0J9Lq_MRyn4UFRsblR3UTBZRHc/preview" + self.video.attributes['width'] = '100%' + self.video.attributes['height'] = '100%' + self.video.attributes['controls'] = 'true' + self.video.style['border'] = 'none' + + self.tree = gui.TreeView(width='100%', height=300) + ti1 = gui.TreeItem("Item1") + ti2 = gui.TreeItem("Item2") + ti3 = gui.TreeItem("Item3") + subti1 = gui.TreeItem("Sub Item1") + subti2 = gui.TreeItem("Sub Item2") + subti3 = gui.TreeItem("Sub Item3") + subti4 = gui.TreeItem("Sub Item4") + subsubti1 = gui.TreeItem("Sub Sub Item1") + subsubti2 = gui.TreeItem("Sub Sub Item2") + subsubti3 = gui.TreeItem("Sub Sub Item3") + self.tree.append([ti1, ti2, ti3]) + ti2.append([subti1, subti2, subti3, subti4]) + subti4.append([subsubti1, subsubti2, subsubti3]) + + # appending a widget to another, the first argument is a string key + subContainerRight.append([self.counter, self.lbl, self.bt, self.txt, self.spin, self.progress, self.check, self.btInputDiag, self.btFileDiag]) + # use a defined key as we replace this widget later + fdownloader = gui.FileDownloader('download test', '../remi/res/logo.png', width=200, height=30, margin='10px') + subContainerRight.append(fdownloader, key='file_downloader') + subContainerRight.append([self.btUploadFile, self.dropDown, self.slider, self.colorPicker, self.date, self.tree]) + self.subContainerRight = subContainerRight + + subContainerLeft.append([self.img, self.table, self.listView, self.link, self.video]) + + horizontalContainer.append([subContainerLeft, subContainerRight]) + + menu = gui.Menu(width='100%', height='30px') + m1 = gui.MenuItem('File', width=100, height=30) + m2 = gui.MenuItem('View', width=100, height=30) + m2.onclick.connect(self.menu_view_clicked) + m11 = gui.MenuItem('Save', width=100, height=30) + m12 = gui.MenuItem('Open', width=100, height=30) + m12.onclick.connect(self.menu_open_clicked) + m111 = gui.MenuItem('Save', width=100, height=30) + m111.onclick.connect(self.menu_save_clicked) + m112 = gui.MenuItem('Save as', width=100, height=30) + m112.onclick.connect(self.menu_saveas_clicked) + m3 = gui.MenuItem('Dialog', width=100, height=30) + m3.onclick.connect(self.menu_dialog_clicked) + + menu.append([m1, m2, m3]) + m1.append([m11, m12]) + m11.append([m111, m112]) + + menubar = gui.MenuBar(width='100%', height='30px') + menubar.append(menu) + + verticalContainer.append([menubar, horizontalContainer]) + + #this flag will be used to stop the display_counter Timer + self.stop_flag = False + + # kick of regular display of counter + self.display_counter() + + # returning the root widget + return verticalContainer + + def display_counter(self): + self.count += 1 + if not self.stop_flag: + Timer(1, self.display_counter).start() + + def menu_dialog_clicked(self, widget): + self.dialog = gui.GenericDialog(title='Dialog Box', message='Click Ok to transfer content to main page', width='500px') + self.dtextinput = gui.TextInput(width=200, height=30) + self.dtextinput.set_value('Initial Text') + self.dialog.add_field_with_label('dtextinput', 'Text Input', self.dtextinput) + + self.dcheck = gui.CheckBox(False, width=200, height=30) + self.dialog.add_field_with_label('dcheck', 'Label Checkbox', self.dcheck) + values = ('Danny Young', 'Christine Holand', 'Lars Gordon', 'Roberto Robitaille') + self.dlistView = gui.ListView.new_from_list(values, width=200, height=120) + self.dialog.add_field_with_label('dlistView', 'Listview', self.dlistView) + + self.ddropdown = gui.DropDown.new_from_list(('DropDownItem 0', 'DropDownItem 1'), + width=200, height=20) + self.dialog.add_field_with_label('ddropdown', 'Dropdown', self.ddropdown) + + self.dspinbox = gui.SpinBox(min=0, max=5000, width=200, height=20) + self.dspinbox.set_value(50) + self.dialog.add_field_with_label('dspinbox', 'Spinbox', self.dspinbox) + + self.dslider = gui.Slider(10, 0, 100, 5, width=200, height=20) + self.dspinbox.set_value(50) + self.dialog.add_field_with_label('dslider', 'Slider', self.dslider) + + self.dcolor = gui.ColorPicker(width=200, height=20) + self.dcolor.set_value('#ffff00') + self.dialog.add_field_with_label('dcolor', 'Colour Picker', self.dcolor) + + self.ddate = gui.Date(width=200, height=20) + self.ddate.set_value('2000-01-01') + self.dialog.add_field_with_label('ddate', 'Date', self.ddate) + + self.dialog.confirm_dialog.connect(self.dialog_confirm) + self.dialog.show(self) + + def dialog_confirm(self, widget): + result = self.dialog.get_field('dtextinput').get_value() + self.txt.set_value(result) + + result = self.dialog.get_field('dcheck').get_value() + self.check.set_value(result) + + result = self.dialog.get_field('ddropdown').get_value() + self.dropDown.select_by_value(result) + + result = self.dialog.get_field('dspinbox').get_value() + self.spin.set_value(result) + + result = self.dialog.get_field('dslider').get_value() + self.slider.set_value(result) + + result = self.dialog.get_field('dcolor').get_value() + self.colorPicker.set_value(result) + + result = self.dialog.get_field('ddate').get_value() + self.date.set_value(result) + + result = self.dialog.get_field('dlistView').get_value() + self.listView.select_by_value(result) + + # listener function + def on_img_clicked(self, widget): + self.lbl.set_text('Image clicked!') + + def on_table_row_click(self, table, row, item): + self.lbl.set_text('Table Item clicked: ' + item.get_text()) + + def on_button_pressed(self, widget): + self.lbl.set_text('Button pressed! ') + self.bt.set_text('Hi!') + + def on_text_area_change(self, widget, newValue): + self.lbl.set_text('Text Area value changed!') + + def on_spin_change(self, widget, newValue): + self.lbl.set_text('SpinBox changed, new value: ' + str(newValue)) + + def on_check_change(self, widget, newValue): + self.lbl.set_text('CheckBox changed, new value: ' + str(newValue)) + + def open_input_dialog(self, widget): + self.inputDialog = gui.InputDialog('Input Dialog', 'Your name?', + initial_value='type here', + width=500, height=160) + self.inputDialog.confirm_value.connect( + self.on_input_dialog_confirm) + + # here is returned the Input Dialog widget, and it will be shown + self.inputDialog.show(self) + + def on_input_dialog_confirm(self, widget, value): + self.lbl.set_text('Hello ' + value) + + def open_fileselection_dialog(self, widget): + self.fileselectionDialog = gui.FileSelectionDialog('File Selection Dialog', 'Select files and folders', False, + '.') + self.fileselectionDialog.confirm_value.connect( + self.on_fileselection_dialog_confirm) + + # here is returned the Input Dialog widget, and it will be shown + self.fileselectionDialog.show(self) + + def on_fileselection_dialog_confirm(self, widget, filelist): + # a list() of filenames and folders is returned + self.lbl.set_text('Selected files: %s' % ','.join(filelist)) + if len(filelist): + f = filelist[0] + # replace the last download link + fdownloader = gui.FileDownloader("download selected", f, width=200, height=30) + self.subContainerRight.append(fdownloader, key='file_downloader') + + def list_view_on_selected(self, widget, selected_item_key): + """ The selection event of the listView, returns a key of the clicked event. + You can retrieve the item rapidly + """ + self.lbl.set_text('List selection: ' + self.listView.children[selected_item_key].get_text()) + + def drop_down_changed(self, widget, value): + self.lbl.set_text('New Combo value: ' + value) + + def slider_changed(self, widget, value): + self.lbl.set_text('New slider value: ' + str(value)) + + def color_picker_changed(self, widget, value): + self.lbl.set_text('New color value: ' + value) + + def date_changed(self, widget, value): + self.lbl.set_text('New date value: ' + value) + + def menu_save_clicked(self, widget): + self.lbl.set_text('Menu clicked: Save') + + def menu_saveas_clicked(self, widget): + self.lbl.set_text('Menu clicked: Save As') + + def menu_open_clicked(self, widget): + self.lbl.set_text('Menu clicked: Open') + + def menu_view_clicked(self, widget): + self.lbl.set_text('Menu clicked: View') + + def fileupload_on_success(self, widget, filename): + self.lbl.set_text('File upload success: ' + filename) + + def fileupload_on_failed(self, widget, filename): + self.lbl.set_text('File upload failed: ' + filename) + + def on_close(self): + """ Overloading App.on_close event to stop the Timer. + """ + self.stop_flag = True + super(MyApp, self).on_close() + + +if __name__ == "__main__": + # starts the webserver + # optional parameters + # start(MyApp,address='127.0.0.1', port=8081, multiple_instance=False,enable_file_cache=True, update_interval=0.1, start_browser=True) + import ssl + start(MyApp, debug=True, address='0.0.0.0', port=8081, start_browser=True, multiple_instance=True) diff --git a/PySimpleGUIWeb/PySimpleGUIWeb.py b/PySimpleGUIWeb/PySimpleGUIWeb.py index e4a4d4ab..18ead87f 100644 --- a/PySimpleGUIWeb/PySimpleGUIWeb.py +++ b/PySimpleGUIWeb/PySimpleGUIWeb.py @@ -6438,7 +6438,7 @@ def main(): [T('Up Time'), Text('Text', key='_TEXT_UPTIME_', font='Arial 18', text_color='black', size=(30,1))], [Input('Single Line Input', do_not_clear=True, enable_events=False, size=(30, 1), text_color='red')], [Multiline('Multiline Input', do_not_clear=True, size=(40, 4), enable_events=True, key='_MULTI_IN_')], - [MultilineOutput('Multiline Output', size=(80, 8), text_color='blue', font='Courier 12', key='_MULTIOUT_')], + [MultilineOutput('Multiline Output', size=(80, 8), text_color='blue', font='Courier 12', key='_MULTIOUT_', autoscroll=True)], [Checkbox('Checkbox 1', enable_events=True, key='_CB1_'), Checkbox('Checkbox 2', default=True, key='_CB2_', enable_events=True)], [Combo(values=['Combo 1', 'Combo 2', 'Combo 3'], default_value='Combo 2', key='_COMBO_', enable_events=True, readonly=False, tooltip='Combo box', disabled=False, size=(12, 1))], @@ -6448,7 +6448,7 @@ def main(): [OK(), Button('Hidden', visible=False, key='_HIDDEN_'), Button('Values'), Button('Exit', button_color=('white', 'red')), Button('UnHide')] ] - window = Window('PySimpleGUIWeb Window', font='Arial 18',default_element_size=(12,1), auto_size_buttons=False, + window = Window('PySimpleGUIWeb Window', font='Arial 18',default_element_size=(12,1), auto_size_buttons=False, background_image='' ).Layout(layout)